* sunos.c (sunos_create_dynamic_sections): We need the dynamic
[deliverable/binutils-gdb.git] / bfd / coffcode.h
index 8de83a543b73ef244b156a68c2968c2c50de2890..ae07e91d9c0a5d22ede8f6abc86c5a4752840904 100644 (file)
@@ -1533,6 +1533,12 @@ coff_set_arch_mach_hook (abfd, filehdr)
       break;
 #endif
 
+#ifdef TIC80_ARCH_MAGIC
+    case TIC80_ARCH_MAGIC:
+      arch = bfd_arch_tic80;
+      break;
+#endif
+
     default:                   /* Unreadable input file type */
       arch = bfd_arch_obscure;
       break;
@@ -1931,9 +1937,14 @@ coff_set_flags (abfd, magicp, flagsp)
     case bfd_arch_m68k:
 #ifdef APOLLOM68KMAGIC
       *magicp = APOLLO_COFF_VERSION_NUMBER;
+#else
+      /* NAMES_HAVE_UNDERSCORE may be defined by coff-u68k.c.  */
+#ifdef NAMES_HAVE_UNDERSCORE
+      *magicp = MC68KBCSMAGIC;
 #else
       *magicp = MC68MAGIC;
 #endif
+#endif
 #ifdef LYNXOS
       /* Just overwrite the usual value if we're doing Lynx. */
       *magicp = LYNXCOFFMAGIC;
@@ -2217,8 +2228,14 @@ coff_compute_section_file_positions (abfd)
 #ifndef I960
       /* make sure that this section is of the right size too */
       if ((abfd->flags & EXEC_P) == 0)
-       current->_raw_size = BFD_ALIGN (current->_raw_size,
-                                       1 << current->alignment_power);
+       {
+         bfd_size_type old_size;
+
+         old_size = current->_raw_size;
+         current->_raw_size = BFD_ALIGN (current->_raw_size,
+                                         1 << current->alignment_power);
+         sofar += current->_raw_size - old_size;
+       }
       else
        {
          old_sofar = sofar;
@@ -2710,6 +2727,10 @@ coff_write_object_contents (abfd)
       internal_a.magic = NMAGIC; /* Assume separate i/d */
 #define __A_MAGIC_SET__
 #endif /* A29K */
+#ifdef TIC80
+    internal_a.magic = TIC80MAGIC;
+#define __A_MAGIC_SET__
+#endif /* TIC80 */
 #ifdef I860
     /* FIXME: What are the a.out magic numbers for the i860?  */
     internal_a.magic = 0;
@@ -2986,7 +3007,7 @@ coff_set_section_contents (abfd, section, location, offset, count)
   if (abfd->output_has_begun == false) /* set by bfd.c handler */
     coff_compute_section_file_positions (abfd);
 
-#ifdef _LIB
+#if defined(_LIB) && !defined(TARG_AUX)
 
    /* The physical address field of a .lib section is used to hold the
       number of shared libraries in the section.  This code counts the
@@ -3138,11 +3159,27 @@ coff_slurp_line_table (abfd, asect)
 
          if (cache_ptr->line_number == 0)
            {
-             coff_symbol_type *sym =
-             (coff_symbol_type *) (dst.l_addr.l_symndx
-                     + obj_raw_syments (abfd))->u.syment._n._n_n._n_zeroes;
+             boolean warned;
+             long symndx;
+             coff_symbol_type *sym;
+
+             warned = false;
+             symndx = dst.l_addr.l_symndx;
+             if (symndx < 0 || symndx >= obj_raw_syment_count (abfd))
+               {
+                 (*_bfd_error_handler)
+                   ("%s: warning: illegal symbol index %ld in line numbers",
+                    bfd_get_filename (abfd), dst.l_addr.l_symndx);
+                 symndx = 0;
+                 warned = true;
+               }
+             /* FIXME: We should not be casting between ints and
+                 pointers like this.  */
+             sym = ((coff_symbol_type *)
+                    ((symndx + obj_raw_syments (abfd))
+                     ->u.syment._n._n_n._n_zeroes));
              cache_ptr->u.sym = (asymbol *) sym;
-             if (sym->lineno != NULL)
+             if (sym->lineno != NULL && ! warned)
                {
                  (*_bfd_error_handler)
                    ("%s: warning: duplicate line number information for `%s'",
@@ -3604,11 +3641,20 @@ coff_slurp_reloc_table (abfd, asect, symbols)
 
       if (dst.r_symndx != -1)
        {
-         /* @@ Should never be greater than count of symbols!  */
-         if (dst.r_symndx >= obj_conv_table_size (abfd))
-           abort ();
-         cache_ptr->sym_ptr_ptr = symbols + obj_convert (abfd)[dst.r_symndx];
-         ptr = *(cache_ptr->sym_ptr_ptr);
+         if (dst.r_symndx < 0 || dst.r_symndx >= obj_conv_table_size (abfd))
+           {
+             (*_bfd_error_handler)
+               ("%s: warning: illegal symbol index %ld in relocs",
+                bfd_get_filename (abfd), dst.r_symndx);
+             cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+             ptr = 0;
+           }
+         else
+           {
+             cache_ptr->sym_ptr_ptr = (symbols
+                                       + obj_convert (abfd)[dst.r_symndx]);
+             ptr = *(cache_ptr->sym_ptr_ptr);
+           }
        }
       else
        {
@@ -3633,6 +3679,14 @@ coff_slurp_reloc_table (abfd, asect, symbols)
       RTYPE2HOWTO (cache_ptr, &dst);
 #endif
 
+      if (cache_ptr->howto == NULL)
+       {
+         (*_bfd_error_handler)
+           ("%s: illegal relocation type %d at address 0x%lx",
+            bfd_get_filename (abfd), dst.r_type, (long) dst.r_vaddr);
+         bfd_set_error (bfd_error_bad_value);
+         return false;
+       }
     }
 
   asect->relocation = reloc_cache;
This page took 0.025013 seconds and 4 git commands to generate.