* elf64-ppc.c (ppc64_elf_size_stubs): When determining need for
[deliverable/binutils-gdb.git] / bfd / coffcode.h
index da8121fd77fea26ff0ebb7f64048c58e9ee56726..63a2c639b68cdd7da6edb7df5967fa966a176721 100644 (file)
@@ -1,6 +1,6 @@
 /* Support for the generic parts of most COFF variants, for BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003
+   2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -309,6 +309,9 @@ CODE_FRAGMENT
 
 #define STRING_SIZE_SIZE (4)
 
+#define DOT_DEBUG      ".debug"
+#define GNU_LINKONCE_WI ".gnu.linkonce.wi."
+
 static long sec_to_styp_flags
   PARAMS ((const char *, flagword));
 static bfd_boolean styp_to_sec_flags
@@ -333,7 +336,7 @@ static bfd_boolean coff_compute_section_file_positions
 static bfd_boolean coff_write_object_contents
   PARAMS ((bfd *)) ATTRIBUTE_UNUSED;
 static bfd_boolean coff_set_section_contents
-  PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+  PARAMS ((bfd *, asection *, const PTR, file_ptr, bfd_size_type));
 static PTR buy_and_read
   PARAMS ((bfd *, file_ptr, bfd_size_type));
 static bfd_boolean coff_slurp_line_table
@@ -362,6 +365,12 @@ static unsigned int coff_compute_checksum
 static bfd_boolean coff_apply_checksum
   PARAMS ((bfd *));
 #endif
+#ifdef TICOFF
+static bfd_boolean ticoff0_bad_format_hook
+    PARAMS ((bfd *, PTR ));
+static bfd_boolean ticoff1_bad_format_hook
+    PARAMS ((bfd *, PTR ));
+#endif
 \f
 /* void warning(); */
 
@@ -422,7 +431,7 @@ sec_to_styp_flags (sec_name, sec_flags)
       styp_flags = STYP_LIT;
 #endif /* _LIT */
     }
-  else if (!strncmp (sec_name, ".debug", 6))
+  else if (!strncmp (sec_name, DOT_DEBUG, sizeof (DOT_DEBUG) - 1))
     {
       /* Handle the XCOFF debug section and DWARF2 debug sections.  */
       if (!sec_name[6])
@@ -435,7 +444,7 @@ sec_to_styp_flags (sec_name, sec_flags)
       styp_flags = STYP_DEBUG_INFO;
     }
 #ifdef COFF_LONG_SECTION_NAMES
-  else if (!strncmp (sec_name, ".gnu.linkonce.wi.", 17))
+  else if (!strncmp (sec_name, GNU_LINKONCE_WI, sizeof (GNU_LINKONCE_WI) - 1))
     {
       styp_flags = STYP_DEBUG_INFO;
     }
@@ -512,7 +521,7 @@ sec_to_styp_flags (sec_name, sec_flags)
 
 static long
 sec_to_styp_flags (sec_name, sec_flags)
-     const char *sec_name ATTRIBUTE_UNUSED;
+     const char *sec_name;
      flagword sec_flags;
 {
   long styp_flags = 0;
@@ -525,6 +534,11 @@ sec_to_styp_flags (sec_name, sec_flags)
      PE files.  The STYP_* flags and the IMAGE_SCN_* flags overlap,
      but there are more IMAGE_SCN_* flags.  */
 
+  /* FIXME: There is no gas syntax to specify the debug section flag.  */
+  if (strncmp (sec_name, DOT_DEBUG, sizeof (DOT_DEBUG) - 1) == 0
+      || strncmp (sec_name, GNU_LINKONCE_WI, sizeof (GNU_LINKONCE_WI) - 1) == 0)
+    sec_flags = SEC_READONLY | SEC_DEBUGGING;
+
   /* skip LOAD */
   /* READONLY later */
   /* skip RELOC */
@@ -669,12 +683,12 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
 #endif
        sec_flags |= SEC_ALLOC;
     }
-  else if (strncmp (name, ".debug", 6) == 0
+  else if (strncmp (name, DOT_DEBUG, sizeof (DOT_DEBUG) - 1) == 0
 #ifdef _COMMENT
           || strcmp (name, _COMMENT) == 0
 #endif
 #ifdef COFF_LONG_SECTION_NAMES
-          || strncmp (name, ".gnu.linkonce.wi.", 17) == 0
+          || strncmp (name, GNU_LINKONCE_WI, sizeof (GNU_LINKONCE_WI) - 1) == 0
 #endif
           || strncmp (name, ".stab", 5) == 0)
     {
@@ -815,8 +829,6 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
                /* The first time we've seen the symbol.  */
                union internal_auxent aux;
 
-               seen_state = 1;
-
                /* If it isn't the stuff we're expecting, die;
                   The MS documentation is vague, but it
                   appears that the second entry serves BOTH
@@ -844,7 +856,10 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
                   function).  See comment above for more.  */
 
                if (strcmp (name, symname) != 0)
-                 abort ();
+                 _bfd_error_handler (_("%B: warning: COMDAT symbol '%s' does not match section name '%s'"),
+                                     abfd, symname, name);
+
+               seen_state = 1;
 
                /* This is the section symbol.  */
                bfd_coff_swap_aux_in (abfd, (PTR) (esym + bfd_coff_symesz (abfd)),
@@ -951,12 +966,13 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
                   Intel puts the two adjacent, but Alpha (at
                   least) spreads them out.  */
 
-               amt = sizeof (struct bfd_comdat_info);
-               section->comdat = bfd_alloc (abfd, amt);
-               if (section->comdat == NULL)
+               amt = sizeof (struct coff_comdat_info);
+               coff_section_data (abfd, section)->comdat
+                 = bfd_alloc (abfd, amt);
+               if (coff_section_data (abfd, section)->comdat == NULL)
                  abort ();
 
-               section->comdat->symbol =
+               coff_section_data (abfd, section)->comdat->symbol =
                  (esym - esymstart) / bfd_coff_symesz (abfd);
 
                amt = strlen (symname) + 1;
@@ -965,7 +981,8 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section)
                  abort ();
 
                strcpy (newname, symname);
-               section->comdat->name = newname;
+               coff_section_data (abfd, section)->comdat->name
+                 = newname;
              }
 
              goto breakloop;
@@ -1049,7 +1066,15 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
          unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
          break;
        case IMAGE_SCN_MEM_NOT_PAGED:
+#if 0
          unhandled = "IMAGE_SCN_MEM_NOT_PAGED";
+#else
+         /* Generate a warning message rather using the 'unhandled'
+            variable as this will allow some .sys files generate by
+            other toolchains to be processed.  See bugzilla issue 196.  */
+         _bfd_error_handler (_("%B: Warning: Ignoring section flag IMAGE_SCN_MEM_NOT_PAGED in section %s"),
+                             abfd, name);
+#endif
          break;
        case IMAGE_SCN_MEM_EXECUTE:
          sec_flags |= SEC_CODE;
@@ -1058,7 +1083,11 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
          sec_flags &= ~ SEC_READONLY;
          break;
        case IMAGE_SCN_MEM_DISCARDABLE:
-         sec_flags |= SEC_DEBUGGING;
+         /* The MS PE spec sets the DISCARDABLE flag on .reloc sections
+            but we do not want them to be labelled as debug section, since
+            then strip would remove them.  */
+         if (strncmp (name, ".reloc", sizeof ".reloc" - 1) != 0)
+           sec_flags |= SEC_DEBUGGING;
          break;
        case IMAGE_SCN_MEM_SHARED:
          sec_flags |= SEC_SHARED;
@@ -1099,8 +1128,8 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr)
       if (unhandled != NULL)
        {
          (*_bfd_error_handler)
-           (_("%s (%s): Section flag %s (0x%x) ignored"),
-            bfd_archive_filename (abfd), name, unhandled, flag);
+           (_("%B (%s): Section flag %s (0x%x) ignored"),
+            abfd, name, unhandled, flag);
          result = FALSE;
        }
     }
@@ -1439,6 +1468,36 @@ coff_bad_format_hook (abfd, filehdr)
   return TRUE;
 }
 
+#ifdef TICOFF
+static bfd_boolean
+ticoff0_bad_format_hook (abfd, filehdr)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     PTR filehdr;
+{
+  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+
+  if (COFF0_BADMAG (*internal_f))
+    return FALSE;
+
+  return TRUE;
+}
+#endif
+
+#ifdef TICOFF
+static bfd_boolean
+ticoff1_bad_format_hook (abfd, filehdr)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     PTR filehdr;
+{
+  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
+
+  if (COFF1_BADMAG (*internal_f))
+    return FALSE;
+
+  return TRUE;
+}
+#endif
+
 /* Check whether this section uses an alignment other than the
    default.  */
 
@@ -1536,7 +1595,7 @@ coff_new_section_hook (abfd, section)
     return FALSE;
 
   /* We don't need to set up n_name, n_value, or n_scnum in the native
-     symbol information, since they'll be overriden by the BFD symbol
+     symbol information, since they'll be overridden by the BFD symbol
      anyhow.  However, we do need to set the type and storage class,
      in case this symbol winds up getting written out.  The value 0
      for n_numaux is already correct.  */
@@ -1658,15 +1717,21 @@ coff_set_alignment_hook (abfd, section, scnhdr)
       struct external_reloc dst;
       struct internal_reloc n;
       file_ptr oldpos = bfd_tell (abfd);
+      bfd_size_type relsz = bfd_coff_relsz (abfd);
+      
       bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0);
-      if (bfd_bread ((PTR) &dst, (bfd_size_type) bfd_coff_relsz (abfd), abfd)
-         != bfd_coff_relsz (abfd))
+      if (bfd_bread ((PTR) &dst, relsz, abfd) != relsz)
        return;
 
       coff_swap_reloc_in (abfd, &dst, &n);
       bfd_seek (abfd, oldpos, 0);
-      section->reloc_count = hdr->s_nreloc = n.r_vaddr;
+      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
+      section->rel_filepos += relsz;
     }
+  else if (hdr->s_nreloc == 0xffff)
+    (*_bfd_error_handler)
+      ("%s: warning: claims to have 0xffff relocs, without overflow",
+       bfd_get_filename (abfd));
 }
 #undef ALIGN_SET
 #undef ELIFALIGN_SET
@@ -1883,43 +1948,26 @@ coff_set_arch_mach_hook (abfd, filehdr)
     case ARMPEMAGIC:
     case THUMBPEMAGIC:
       arch = bfd_arch_arm;
-      switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
+      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
+      if (machine == bfd_mach_arm_unknown)
        {
-        case F_ARM_2:  machine = bfd_mach_arm_2;  break;
-        case F_ARM_2a: machine = bfd_mach_arm_2a; break;
-        case F_ARM_3:  machine = bfd_mach_arm_3;  break;
-        default:
-        case F_ARM_3M: machine = bfd_mach_arm_3M; break;
-        case F_ARM_4:  machine = bfd_mach_arm_4;  break;
-        case F_ARM_4T: machine = bfd_mach_arm_4T; break;
-         /* The COFF header does not have enough bits available
-            to cover all the different ARM architectures.  So
-            we interpret F_ARM_5, the highest flag value to mean
-            "the highest ARM architecture known to BFD" which is
-            currently the XScale.  */
-        case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
+         switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
+           {
+           case F_ARM_2:  machine = bfd_mach_arm_2;  break;
+           case F_ARM_2a: machine = bfd_mach_arm_2a; break;
+           case F_ARM_3:  machine = bfd_mach_arm_3;  break;
+           default:
+           case F_ARM_3M: machine = bfd_mach_arm_3M; break;
+           case F_ARM_4:  machine = bfd_mach_arm_4;  break;
+           case F_ARM_4T: machine = bfd_mach_arm_4T; break;
+             /* The COFF header does not have enough bits available
+                to cover all the different ARM architectures.  So
+                we interpret F_ARM_5, the highest flag value to mean
+                "the highest ARM architecture known to BFD" which is
+                currently the XScale.  */
+           case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
+           }
        }
-
-      {
-       asection * arm_arch_section;
-  
-       arm_arch_section = bfd_get_section_by_name (abfd, ".note");
-
-       if (arm_arch_section)
-         {
-           bfd_byte buffer [4];
-
-           if (! bfd_get_section_contents (abfd, arm_arch_section, buffer,
-                                           (file_ptr) 0, sizeof buffer))
-             (*_bfd_error_handler)
-               (_("%s: warning: unable to retrieve .note section from %s"),
-                bfd_get_filename (abfd));
-             
-           /* We have to extract the value this way to allow for a
-              host whose endian-ness is different from the target.  */
-           machine = bfd_get_32 (abfd, buffer);
-         }
-      }
       break;
 #endif
 #ifdef MC68MAGIC
@@ -1938,6 +1986,12 @@ coff_set_arch_mach_hook (abfd, filehdr)
       machine = bfd_mach_m68020;
       break;
 #endif
+#ifdef MAXQ20MAGIC
+    case MAXQ20MAGIC:
+      arch = bfd_arch_maxq;
+      machine = 0;
+      break;
+#endif
 #ifdef MC88MAGIC
     case MC88MAGIC:
     case MC88DMAGIC:
@@ -2088,7 +2142,7 @@ coff_set_arch_mach_hook (abfd, filehdr)
     case H8300MAGIC:
       arch = bfd_arch_h8300;
       machine = bfd_mach_h8300;
-      /* !! FIXME this probably isn't the right place for this */
+      /* !! FIXME this probably isn't the right place for this */
       abfd->flags |= BFD_IS_RELAXABLE;
       break;
 #endif
@@ -2097,7 +2151,7 @@ coff_set_arch_mach_hook (abfd, filehdr)
     case H8300HMAGIC:
       arch = bfd_arch_h8300;
       machine = bfd_mach_h8300h;
-      /* !! FIXME this probably isn't the right place for this */
+      /* !! FIXME this probably isn't the right place for this */
       abfd->flags |= BFD_IS_RELAXABLE;
       break;
 #endif
@@ -2106,7 +2160,25 @@ coff_set_arch_mach_hook (abfd, filehdr)
     case H8300SMAGIC:
       arch = bfd_arch_h8300;
       machine = bfd_mach_h8300s;
-      /* !! FIXME this probably isn't the right place for this */
+      /* !! FIXME this probably isn't the right place for this.  */
+      abfd->flags |= BFD_IS_RELAXABLE;
+      break;
+#endif
+
+#ifdef H8300HNMAGIC
+    case H8300HNMAGIC:
+      arch = bfd_arch_h8300;
+      machine = bfd_mach_h8300hn;
+      /* !! FIXME this probably isn't the right place for this.  */
+      abfd->flags |= BFD_IS_RELAXABLE;
+      break;
+#endif
+
+#ifdef H8300SNMAGIC
+    case H8300SNMAGIC:
+      arch = bfd_arch_h8300;
+      machine = bfd_mach_h8300sn;
+      /* !! FIXME this probably isn't the right place for this.  */
       abfd->flags |= BFD_IS_RELAXABLE;
       break;
 #endif
@@ -2756,6 +2828,12 @@ coff_set_flags (abfd, magicp, flagsp)
        case bfd_mach_h8300s:
          *magicp = H8300SMAGIC;
          return TRUE;
+       case bfd_mach_h8300hn:
+         *magicp = H8300HNMAGIC;
+         return TRUE;
+       case bfd_mach_h8300sn:
+         *magicp = H8300SNMAGIC;
+         return TRUE;
        }
       break;
 #endif
@@ -2847,6 +2925,13 @@ coff_set_flags (abfd, magicp, flagsp)
       return TRUE;
 #endif
 
+#ifdef MAXQ20MAGIC
+    case bfd_arch_maxq:
+        *magicp = MAXQ20MAGIC;
+      return TRUE;
+      break;
+#endif
+
     default:                   /* Unknown architecture.  */
       /* Fall through to "return FALSE" below, to avoid
         "statement never reached" errors on the one below.  */
@@ -2951,10 +3036,10 @@ coff_compute_section_file_positions (abfd)
        {
          asection *dsec;
 
-         dsec = bfd_make_section_old_way (abfd, ".debug");
+         dsec = bfd_make_section_old_way (abfd, DOT_DEBUG);
          if (dsec == NULL)
            abort ();
-         dsec->_raw_size = sz;
+         dsec->size = sz;
          dsec->flags |= SEC_HAS_CONTENTS;
        }
     }
@@ -2965,6 +3050,11 @@ coff_compute_section_file_positions (abfd)
   if (coff_data (abfd)->link_info)
     {
       page_size = pe_data (abfd)->pe_opthdr.FileAlignment;
+
+      /* If no file alignment has been set, default to one.
+        This repairs 'ld -r' for arm-wince-pe target.  */
+      if (page_size == 0)
+        page_size = 1;
     }
   else
     page_size = PE_DEF_FILE_ALIGNMENT;
@@ -3048,7 +3138,7 @@ coff_compute_section_file_positions (abfd)
           a zero size and having real contents are different
           concepts: .bss has no contents, but (usually) non-zero
           size.  */
-       if (current->_raw_size == 0)
+       if (current->size == 0)
          {
            /* Discard.  However, it still might have (valid) symbols
               in it, so arbitrarily set it to section 1 (indexing is
@@ -3099,7 +3189,7 @@ coff_compute_section_file_positions (abfd)
            return FALSE;
        }
       if (pei_section_data (abfd, current)->virt_size == 0)
-       pei_section_data (abfd, current)->virt_size = current->_raw_size;
+       pei_section_data (abfd, current)->virt_size = current->size;
 #endif
 
       /* Only deal with sections which have contents.  */
@@ -3108,7 +3198,7 @@ coff_compute_section_file_positions (abfd)
 
 #ifdef COFF_IMAGE_WITH_PE
       /* Make sure we skip empty sections in a PE image.  */
-      if (current->_raw_size == 0)
+      if (current->size == 0)
        continue;
 #endif
 
@@ -3156,7 +3246,7 @@ coff_compute_section_file_positions (abfd)
            }
 #endif
          if (previous != (asection *) NULL)
-           previous->_raw_size += sofar - old_sofar;
+           previous->size += sofar - old_sofar;
        }
 
 #endif
@@ -3166,16 +3256,16 @@ coff_compute_section_file_positions (abfd)
 #ifdef COFF_PAGE_SIZE
       if ((abfd->flags & D_PAGED) != 0
          && (current->flags & SEC_ALLOC) != 0)
-       sofar += (current->vma - sofar) % page_size;
+       sofar += (current->vma - (bfd_vma) sofar) % page_size;
 #endif
       current->filepos = sofar;
 
 #ifdef COFF_IMAGE_WITH_PE
       /* Set the padded size.  */
-      current->_raw_size = (current->_raw_size + page_size -1) & -page_size;
+      current->size = (current->size + page_size -1) & -page_size;
 #endif
 
-      sofar += current->_raw_size;
+      sofar += current->size;
 
 #ifdef ALIGN_SECTIONS_IN_FILE
       /* Make sure that this section is of the right size too.  */
@@ -3183,26 +3273,26 @@ coff_compute_section_file_positions (abfd)
        {
          bfd_size_type old_size;
 
-         old_size = current->_raw_size;
-         current->_raw_size = BFD_ALIGN (current->_raw_size,
-                                         1 << current->alignment_power);
-         align_adjust = current->_raw_size != old_size;
-         sofar += current->_raw_size - old_size;
+         old_size = current->size;
+         current->size = BFD_ALIGN (current->size,
+                                    1 << current->alignment_power);
+         align_adjust = current->size != old_size;
+         sofar += current->size - old_size;
        }
       else
        {
          old_sofar = sofar;
          sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
          align_adjust = sofar != old_sofar;
-         current->_raw_size += sofar - old_sofar;
+         current->size += sofar - old_sofar;
        }
 #endif
 
 #ifdef COFF_IMAGE_WITH_PE
       /* For PE we need to make sure we pad out to the aligned
-         _raw_size, in case the caller only writes out data to the
-         unaligned _raw_size.  */
-      if (pei_section_data (abfd, current)->virt_size < current->_raw_size)
+         size, in case the caller only writes out data to the
+         unaligned size.  */
+      if (pei_section_data (abfd, current)->virt_size < current->size)
        align_adjust = TRUE;
 #endif
 
@@ -3574,7 +3664,7 @@ coff_write_object_contents (abfd)
 #endif
       section.s_vaddr = current->vma;
       section.s_paddr = current->lma;
-      section.s_size =  current->_raw_size;
+      section.s_size =  current->size;
 #ifdef coff_get_section_load_page
       section.s_page = coff_get_section_load_page (current);
 #endif
@@ -3593,8 +3683,8 @@ coff_write_object_contents (abfd)
 
       /* If this section has no size or is unloadable then the scnptr
         will be 0 too.  */
-      if (current->_raw_size == 0 ||
-         (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
+      if (current->size == 0
+         || (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
        section.s_scnptr = 0;
       else
        section.s_scnptr = current->filepos;
@@ -3828,9 +3918,13 @@ coff_write_object_contents (abfd)
 #ifdef COFF_IMAGE_WITH_PE
   if (! hasdebug)
     internal_f.f_flags |= IMAGE_FILE_DEBUG_STRIPPED;
+  if (pe_data (abfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE)
+    internal_f.f_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
 #endif
 
-#ifndef COFF_WITH_PE
+#ifdef COFF_WITH_PE
+  internal_f.f_flags |= IMAGE_FILE_32BIT_MACHINE;
+#else
   if (bfd_little_endian (abfd))
     internal_f.f_flags |= F_AR32WR;
   else
@@ -3982,6 +4076,11 @@ coff_write_object_contents (abfd)
     internal_a.magic = NMAGIC; /* Assume separate i/d.  */
 #endif
 
+#ifdef MAXQ20MAGIC
+#define __A_MAGIC_SET__
+      internal_a.magic = MAXQ20MAGIC;
+#endif
 #ifndef __A_MAGIC_SET__
 #include "Your aouthdr magic number is not being set!"
 #else
@@ -4062,17 +4161,17 @@ coff_write_object_contents (abfd)
 
   if (text_sec)
     {
-      internal_a.tsize = bfd_get_section_size_before_reloc (text_sec);
+      internal_a.tsize = text_sec->size;
       internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
     }
   if (data_sec)
     {
-      internal_a.dsize = bfd_get_section_size_before_reloc (data_sec);
+      internal_a.dsize = data_sec->size;
       internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
     }
   if (bss_sec)
     {
-      internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec);
+      internal_a.bsize = bss_sec->size;
       if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
        internal_a.data_start = bss_sec->vma;
     }
@@ -4220,7 +4319,7 @@ static bfd_boolean
 coff_set_section_contents (abfd, section, location, offset, count)
      bfd * abfd;
      sec_ptr section;
-     PTR location;
+     const PTR location;
      file_ptr offset;
      bfd_size_type count;
 {
@@ -4362,6 +4461,12 @@ coff_slurp_line_table (abfd, asect)
 
   amt = (bfd_size_type) bfd_coff_linesz (abfd) * asect->lineno_count;
   native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, amt);
+  if (native_lineno == NULL)
+    {
+      (*_bfd_error_handler)
+        (_("%B: warning: line number table read failed"), abfd);
+      return FALSE;
+    }
   amt = ((bfd_size_type) asect->lineno_count + 1) * sizeof (alent);
   lineno_cache = (alent *) bfd_alloc (abfd, amt);
   if (lineno_cache == NULL)
@@ -4391,8 +4496,8 @@ coff_slurp_line_table (abfd, asect)
                  || (bfd_vma) symndx >= obj_raw_syment_count (abfd))
                {
                  (*_bfd_error_handler)
-                   (_("%s: warning: illegal symbol index %ld in line numbers"),
-                    bfd_archive_filename (abfd), dst.l_addr.l_symndx);
+                   (_("%B: warning: illegal symbol index %ld in line numbers"),
+                    abfd, dst.l_addr.l_symndx);
                  symndx = 0;
                  warned = TRUE;
                }
@@ -4405,9 +4510,8 @@ coff_slurp_line_table (abfd, asect)
              if (sym->lineno != NULL && ! warned)
                {
                  (*_bfd_error_handler)
-                   (_("%s: warning: duplicate line number information for `%s'"),
-                    bfd_archive_filename (abfd),
-                    bfd_asymbol_name (&sym->symbol));
+                   (_("%B: warning: duplicate line number information for `%s'"),
+                    abfd, bfd_asymbol_name (&sym->symbol));
                }
              sym->lineno = cache_ptr;
            }
@@ -4623,7 +4727,7 @@ coff_slurp_symbol_table (abfd)
 #endif
            case C_REGPARM:     /* Register parameter.  */
            case C_REG:         /* register variable.  */
-              /* C_AUTOARG conflictes with TI COFF C_UEXT.  */
+              /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
 #if !defined (TIC80COFF) && !defined (TICOFF)
 #ifdef C_AUTOARG
            case C_AUTOARG:     /* 960-specific storage class.  */
@@ -4650,7 +4754,9 @@ coff_slurp_symbol_table (abfd)
            case C_RSYM:
            case C_RPSYM:
            case C_STSYM:
+           case C_TCSYM:
            case C_BCOMM:
+           case C_ECOML:
            case C_ECOMM:
            case C_DECL:
            case C_ENTRY:
@@ -4759,8 +4865,8 @@ coff_slurp_symbol_table (abfd)
            case C_HIDDEN:      /* Ext symbol in dmert public lib.  */
            default:
              (*_bfd_error_handler)
-               (_("%s: Unrecognized storage class %d for %s symbol `%s'"),
-                bfd_archive_filename (abfd), src->u.syment.n_sclass,
+               (_("%B: Unrecognized storage class %d for %s symbol `%s'"),
+                abfd, src->u.syment.n_sclass,
                 dst->symbol.section->name, dst->symbol.name);
              dst->symbol.flags = BSF_DEBUGGING;
              dst->symbol.value = (src->u.syment.n_value);
@@ -4892,9 +4998,8 @@ coff_classify_symbol (abfd, syment)
       char buf[SYMNMLEN + 1];
 
       (*_bfd_error_handler)
-       (_("warning: %s: local symbol `%s' has no section"),
-        bfd_archive_filename (abfd),
-        _bfd_coff_internal_syment_name (abfd, syment, buf));
+       (_("warning: %B: local symbol `%s' has no section"),
+        abfd, _bfd_coff_internal_syment_name (abfd, syment, buf));
     }
 
   return COFF_SYMBOL_LOCAL;
@@ -4999,8 +5104,8 @@ coff_slurp_reloc_table (abfd, asect, symbols)
          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_archive_filename (abfd), dst.r_symndx);
+               (_("%B: warning: illegal symbol index %ld in relocs"),
+                abfd, dst.r_symndx);
              cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
              ptr = NULL;
            }
@@ -5037,8 +5142,8 @@ coff_slurp_reloc_table (abfd, asect, symbols)
       if (cache_ptr->howto == NULL)
        {
          (*_bfd_error_handler)
-           (_("%s: illegal relocation type %d at address 0x%lx"),
-            bfd_archive_filename (abfd), dst.r_type, (long) dst.r_vaddr);
+           (_("%B: illegal relocation type %d at address 0x%lx"),
+            abfd, dst.r_type, (long) dst.r_vaddr);
          bfd_set_error (bfd_error_bad_value);
          return FALSE;
        }
@@ -5062,7 +5167,6 @@ static reloc_howto_type *coff_rtype_to_howto
           struct coff_link_hash_entry *, struct internal_syment *,
           bfd_vma *));
 
-/*ARGSUSED*/
 static reloc_howto_type *
 coff_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
      bfd *abfd ATTRIBUTE_UNUSED;
@@ -5331,6 +5435,92 @@ static const bfd_coff_backend_data bfd_coff_std_swap_table =
   coff_link_output_has_begun, coff_final_link_postscript
 };
 
+#ifdef TICOFF
+/* COFF0 differs in file/section header size and relocation entry size.  */
+static const bfd_coff_backend_data ticoff0_swap_table =
+{
+  coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
+  coff_SWAP_aux_out, coff_SWAP_sym_out,
+  coff_SWAP_lineno_out, coff_SWAP_reloc_out,
+  coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out,
+  coff_SWAP_scnhdr_out,
+  FILHSZ_V0, AOUTSZ, SCNHSZ_V01, SYMESZ, AUXESZ, RELSZ_V0, LINESZ, FILNMLEN,
+#ifdef COFF_LONG_FILENAMES
+  TRUE,
+#else
+  FALSE,
+#endif
+#ifdef COFF_LONG_SECTION_NAMES
+  TRUE,
+#else
+  FALSE,
+#endif
+  COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
+#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS
+  TRUE,
+#else
+  FALSE,
+#endif
+#ifdef COFF_DEBUG_STRING_WIDE_PREFIX
+  4,
+#else
+  2,
+#endif
+  coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
+  coff_SWAP_reloc_in, ticoff0_bad_format_hook, coff_set_arch_mach_hook,
+  coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
+  coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
+  coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
+  coff_classify_symbol, coff_compute_section_file_positions,
+  coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
+  coff_adjust_symndx, coff_link_add_one_symbol,
+  coff_link_output_has_begun, coff_final_link_postscript
+};
+#endif
+
+#ifdef TICOFF
+/* COFF1 differs in section header size.  */
+static const bfd_coff_backend_data ticoff1_swap_table =
+{
+  coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
+  coff_SWAP_aux_out, coff_SWAP_sym_out,
+  coff_SWAP_lineno_out, coff_SWAP_reloc_out,
+  coff_SWAP_filehdr_out, coff_SWAP_aouthdr_out,
+  coff_SWAP_scnhdr_out,
+  FILHSZ, AOUTSZ, SCNHSZ_V01, SYMESZ, AUXESZ, RELSZ, LINESZ, FILNMLEN,
+#ifdef COFF_LONG_FILENAMES
+  TRUE,
+#else
+  FALSE,
+#endif
+#ifdef COFF_LONG_SECTION_NAMES
+  TRUE,
+#else
+  FALSE,
+#endif
+  COFF_DEFAULT_SECTION_ALIGNMENT_POWER,
+#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS
+  TRUE,
+#else
+  FALSE,
+#endif
+#ifdef COFF_DEBUG_STRING_WIDE_PREFIX
+  4,
+#else
+  2,
+#endif
+  coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in,
+  coff_SWAP_reloc_in, ticoff1_bad_format_hook, coff_set_arch_mach_hook,
+  coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook,
+  coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook,
+  coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
+  coff_classify_symbol, coff_compute_section_file_positions,
+  coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
+  coff_adjust_symndx, coff_link_add_one_symbol,
+  coff_link_output_has_begun, coff_final_link_postscript
+};
+#endif
+
 #ifndef coff_close_and_cleanup
 #define        coff_close_and_cleanup              _bfd_generic_close_and_cleanup
 #endif
@@ -5347,6 +5537,10 @@ static const bfd_coff_backend_data bfd_coff_std_swap_table =
 #define coff_bfd_copy_private_symbol_data   _bfd_generic_bfd_copy_private_symbol_data
 #endif
 
+#ifndef coff_bfd_copy_private_header_data
+#define coff_bfd_copy_private_header_data   _bfd_generic_bfd_copy_private_header_data
+#endif
+
 #ifndef coff_bfd_copy_private_section_data
 #define coff_bfd_copy_private_section_data  _bfd_generic_bfd_copy_private_section_data
 #endif
@@ -5371,6 +5565,10 @@ static const bfd_coff_backend_data bfd_coff_std_swap_table =
 #define coff_bfd_is_local_label_name       _bfd_coff_is_local_label_name
 #endif
 
+#ifndef coff_bfd_is_target_special_symbol
+#define coff_bfd_is_target_special_symbol   ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#endif
+
 #ifndef coff_read_minisymbols
 #define coff_read_minisymbols              _bfd_generic_read_minisymbols
 #endif
@@ -5402,11 +5600,20 @@ static const bfd_coff_backend_data bfd_coff_std_swap_table =
 #define coff_bfd_merge_sections                    bfd_generic_merge_sections
 #endif
 
+#ifndef coff_bfd_is_group_section
+#define coff_bfd_is_group_section          bfd_generic_is_group_section
+#endif
+
 #ifndef coff_bfd_discard_group
 #define coff_bfd_discard_group             bfd_generic_discard_group
 #endif
 
-#define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE)        \
+#ifndef coff_section_already_linked
+#define coff_section_already_linked \
+  _bfd_generic_section_already_linked
+#endif
+
+#define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE)    \
 const bfd_target VAR =                                                 \
 {                                                                      \
   NAME ,                                                               \
@@ -5453,10 +5660,60 @@ const bfd_target VAR =                                                  \
                                                                        \
   ALTERNATIVE,                                                         \
                                                                        \
-  COFF_SWAP_TABLE                                                      \
+  SWAP_TABLE                                                           \
+};
+
+#define CREATE_BIGHDR_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE) \
+const bfd_target VAR =                                                 \
+{                                                                      \
+  NAME ,                                                               \
+  bfd_target_coff_flavour,                                             \
+  BFD_ENDIAN_LITTLE,           /* data byte order is little */         \
+  BFD_ENDIAN_BIG,              /* header byte order is big */          \
+  /* object flags */                                                   \
+  (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG |                       \
+   HAS_SYMS | HAS_LOCALS | WP_TEXT | EXTRA_O_FLAGS),                   \
+  /* section flags */                                                  \
+  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | EXTRA_S_FLAGS),\
+  UNDER,                       /* leading symbol underscore */         \
+  '/',                         /* ar_pad_char */                       \
+  15,                          /* ar_max_namelen */                    \
+                                                                       \
+  /* Data conversion functions.  */                                    \
+  bfd_getb64, bfd_getb_signed_64, bfd_putb64,                          \
+  bfd_getb32, bfd_getb_signed_32, bfd_putb32,                          \
+  bfd_getb16, bfd_getb_signed_16, bfd_putb16,                          \
+                                                                       \
+  /* Header conversion functions.  */                                  \
+  bfd_getb64, bfd_getb_signed_64, bfd_putb64,                          \
+  bfd_getb32, bfd_getb_signed_32, bfd_putb32,                          \
+  bfd_getb16, bfd_getb_signed_16, bfd_putb16,                          \
+                                                                       \
+       /* bfd_check_format */                                          \
+  { _bfd_dummy_target, coff_object_p, bfd_generic_archive_p,           \
+    _bfd_dummy_target },                                               \
+       /* bfd_set_format */                                            \
+  { bfd_false, coff_mkobject, _bfd_generic_mkarchive, bfd_false },     \
+       /* bfd_write_contents */                                        \
+  { bfd_false, coff_write_object_contents, _bfd_write_archive_contents,        \
+    bfd_false },                                                       \
+                                                                       \
+  BFD_JUMP_TABLE_GENERIC (coff),                                       \
+  BFD_JUMP_TABLE_COPY (coff),                                          \
+  BFD_JUMP_TABLE_CORE (_bfd_nocore),                                   \
+  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),                          \
+  BFD_JUMP_TABLE_SYMBOLS (coff),                                       \
+  BFD_JUMP_TABLE_RELOCS (coff),                                                \
+  BFD_JUMP_TABLE_WRITE (coff),                                         \
+  BFD_JUMP_TABLE_LINK (coff),                                          \
+  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),                             \
+                                                                       \
+  ALTERNATIVE,                                                         \
+                                                                       \
+  SWAP_TABLE                                                           \
 };
 
-#define CREATE_LITTLE_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE)     \
+#define CREATE_LITTLE_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE) \
 const bfd_target VAR =                                                 \
 {                                                                      \
   NAME ,                                                               \
@@ -5501,5 +5758,5 @@ const bfd_target VAR =                                                    \
                                                                        \
   ALTERNATIVE,                                                         \
                                                                        \
-  COFF_SWAP_TABLE                                                      \
+  SWAP_TABLE                                                           \
 };
This page took 0.035114 seconds and 4 git commands to generate.