Apply Bruno de Bus's patch to record the ARM mapping symbol state on a per-
[deliverable/binutils-gdb.git] / bfd / cofflink.c
index 09f03f03ef0ec567f7790f53cb1f2644d57f529c..4ad566cc22ed3ef6cb0ea0fcacde1e9168fc1d14 100644 (file)
@@ -27,6 +27,7 @@
 #include "libbfd.h"
 #include "coff/internal.h"
 #include "libcoff.h"
+#include "safe-ctype.h"
 
 static bfd_boolean coff_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info);
 static bfd_boolean coff_link_check_archive_element (bfd *abfd, struct bfd_link_info *info, bfd_boolean *pneeded);
@@ -570,19 +571,24 @@ coff_link_add_symbols (bfd *abfd,
       && info->hash->creator->flavour == bfd_get_flavour (abfd)
       && (info->strip != strip_all && info->strip != strip_debugger))
     {
-      asection *stab, *stabstr;
+      asection *stabstr;
 
-      stab = bfd_get_section_by_name (abfd, ".stab");
-      if (stab != NULL)
-       {
-         stabstr = bfd_get_section_by_name (abfd, ".stabstr");
+      stabstr = bfd_get_section_by_name (abfd, ".stabstr");
 
-         if (stabstr != NULL)
+      if (stabstr != NULL)
+       {
+         bfd_size_type string_offset = 0;
+         asection *stab;
+         
+         for (stab = abfd->sections; stab; stab = stab->next)
+           if (strncmp (".stab", stab->name, 5) == 0
+               && (!stab->name[5]
+                   || (stab->name[5] == '.' && ISDIGIT (stab->name[6]))))
            {
              struct coff_link_hash_table *table;
-             struct coff_section_tdata *secdata;
-
-             secdata = coff_section_data (abfd, stab);
+             struct coff_section_tdata *secdata
+               = coff_section_data (abfd, stab);
+             
              if (secdata == NULL)
                {
                  amt = sizeof (struct coff_section_tdata);
@@ -596,7 +602,8 @@ coff_link_add_symbols (bfd *abfd,
 
              if (! _bfd_link_section_stabs (abfd, &table->stab_info,
                                             stab, stabstr,
-                                            &secdata->stab_info))
+                                            &secdata->stab_info,
+                                            &string_offset))
                goto error_return;
            }
        }
@@ -1028,10 +1035,27 @@ _bfd_coff_final_link (bfd *abfd,
              bfd_coff_swap_reloc_out (abfd, irel, erel);
            }
 
-         if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
-             || (bfd_bwrite (external_relocs,
-                            (bfd_size_type) relsz * o->reloc_count, abfd)
-                 != (bfd_size_type) relsz * o->reloc_count))
+         if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0)
+           goto error_return;
+         if (obj_pe (abfd) && o->reloc_count >= 0xffff)
+           {
+             /* In PE COFF, write the count of relocs as the first
+                reloc.  The header overflow bit will be set
+                elsewhere. */
+             struct internal_reloc incount;
+             bfd_byte *excount = (bfd_byte *)bfd_malloc (relsz);
+             
+             memset (&incount, 0, sizeof (incount));
+             incount.r_vaddr = o->reloc_count + 1;
+             bfd_coff_swap_reloc_out (abfd, (PTR) &incount, (PTR) excount);
+             if (bfd_bwrite (excount, relsz, abfd) != relsz)
+               /* We'll leak, but it's an error anyway. */
+               goto error_return;
+             free (excount);
+           }
+         if (bfd_bwrite (external_relocs,
+                         (bfd_size_type) relsz * o->reloc_count, abfd)
+             != (bfd_size_type) relsz * o->reloc_count)
            goto error_return;
        }
 
@@ -1481,13 +1505,12 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *finfo, bfd *input_bfd)
       /* Skip section symbols for sections which are not going to be
         emitted.  */
       if (!skip
+         && dont_skip_symbol == 0
          && isym.n_sclass == C_STAT
          && isym.n_type == T_NULL
-          && isym.n_numaux > 0)
-        {
-          if ((*secpp)->output_section == bfd_abs_section_ptr)
-           skip = TRUE;
-        }
+          && isym.n_numaux > 0
+         && (*secpp)->output_section == bfd_abs_section_ptr)
+       skip = TRUE;
 #endif
 
       /* If we stripping debugging symbols, and this is a debugging
@@ -2542,7 +2565,7 @@ _bfd_coff_write_global_sym (struct coff_link_hash_entry *h, void *data)
       isym.n_sclass = C_STAT;
     }
 
-  /* When a weak symbol is not overriden by a strong one,
+  /* When a weak symbol is not overridden by a strong one,
      turn it into an external symbol when not building a
      shared or relocatable object.  */
   if (! finfo->info->shared
This page took 0.024269 seconds and 4 git commands to generate.