* elf-bfd.h (_bfd_elf_link_renumber_dynsyms): Delete.
authorAlan Modra <amodra@gmail.com>
Fri, 18 Mar 2005 13:21:11 +0000 (13:21 +0000)
committerAlan Modra <amodra@gmail.com>
Fri, 18 Mar 2005 13:21:11 +0000 (13:21 +0000)
* elflink.c (_bfd_elf_link_renumber_dynsyms): Make static, add
section_sym_count param, and return number of section symbols.
(bfd_elf_size_dynamic_sections): Clear section symbol area of
.dynsym contents.  Don't bother calling swap_symbol_out on the
first all-zero dynsym.
(elf_mark_used_section): Formatting.  Avoid twiddling flags in
special sections like bfd_abs_section.
(bfd_elf_gc_sections): Spelling fix.

bfd/ChangeLog
bfd/elf-bfd.h
bfd/elflink.c

index 9e049e7a9ce14f8fac09f472722d311dc422b316..dd8612d452c81f2cdf88d76c178c45acf432f5d8 100644 (file)
@@ -1,3 +1,15 @@
+2005-03-18  Alan Modra  <amodra@bigpond.net.au>
+
+       * elf-bfd.h (_bfd_elf_link_renumber_dynsyms): Delete.
+       * elflink.c (_bfd_elf_link_renumber_dynsyms): Make static, add
+       section_sym_count param, and return number of section symbols.
+       (bfd_elf_size_dynamic_sections): Clear section symbol area of
+       .dynsym contents.  Don't bother calling swap_symbol_out on the
+       first all-zero dynsym.
+       (elf_mark_used_section): Formatting.  Avoid twiddling flags in
+       special sections like bfd_abs_section.
+       (bfd_elf_gc_sections): Spelling fix.
+
 2005-03-16  Fred Fish  <fnf@specifixinc.com>
 
        PR binutils/790
index d714974573f5b981fe792d53256fc55e56b72c72..b27aed09486991e8028e8bcfb74c82ff2323a40b 100644 (file)
@@ -1592,8 +1592,6 @@ extern bfd_boolean _bfd_elf_create_dynamic_sections
   (bfd *, struct bfd_link_info *);
 extern bfd_boolean _bfd_elf_create_got_section
   (bfd *, struct bfd_link_info *);
-extern unsigned long _bfd_elf_link_renumber_dynsyms
-  (bfd *, struct bfd_link_info *);
 
 extern bfd_boolean _bfd_elfcore_make_pseudosection
   (bfd *, char *, size_t, ufile_ptr);
index 9f1be5f4a357054f894fdee4a144caeecd757fc1..0bb49ea1c8df4b0b88f4dddf8785b75dc70bec19 100644 (file)
@@ -707,8 +707,10 @@ _bfd_elf_link_omit_section_dynsym (bfd *output_bfd ATTRIBUTE_UNUSED,
    allocated local dynamic syms, followed by the rest of the global
    symbols.  */
 
-unsigned long
-_bfd_elf_link_renumber_dynsyms (bfd *output_bfd, struct bfd_link_info *info)
+static unsigned long
+_bfd_elf_link_renumber_dynsyms (bfd *output_bfd,
+                               struct bfd_link_info *info,
+                               unsigned long *section_sym_count)
 {
   unsigned long dynsymcount = 0;
 
@@ -722,6 +724,7 @@ _bfd_elf_link_renumber_dynsyms (bfd *output_bfd, struct bfd_link_info *info)
            && !(*bed->elf_backend_omit_section_dynsym) (output_bfd, info, p))
          elf_section_data (p)->dynindx = ++dynsymcount;
     }
+  *section_sym_count = dynsymcount;
 
   elf_link_hash_traverse (elf_hash_table (info),
                          elf_link_renumber_local_hash_table_dynsyms,
@@ -5273,6 +5276,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       bfd_size_type dynsymcount;
+      unsigned long section_sym_count;
       asection *s;
       size_t bucketcount = 0;
       size_t hash_entry_size;
@@ -5639,7 +5643,8 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
         Next come all of the back-end allocated local dynamic syms,
         followed by the rest of the global symbols.  */
 
-      dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info);
+      dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info,
+                                                   &section_sym_count);
 
       /* Work out the size of the symbol version section.  */
       s = bfd_get_section_by_name (dynobj, ".gnu.version");
@@ -5651,7 +5656,8 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
          _bfd_strip_section_from_output (info, s);
          /* The DYNSYMCOUNT might have changed if we were going to
             output a dynamic symbol table entry for S.  */
-         dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info);
+         dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info,
+                                                       &section_sym_count);
        }
       else
        {
@@ -5673,22 +5679,17 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
       s = bfd_get_section_by_name (dynobj, ".dynsym");
       BFD_ASSERT (s != NULL);
       s->size = dynsymcount * bed->s->sizeof_sym;
-      s->contents = bfd_alloc (output_bfd, s->size);
-      if (s->contents == NULL && s->size != 0)
-       return FALSE;
 
       if (dynsymcount != 0)
        {
-         Elf_Internal_Sym isym;
+         s->contents = bfd_alloc (output_bfd, s->size);
+         if (s->contents == NULL)
+           return FALSE;
 
-         /* The first entry in .dynsym is a dummy symbol.  */
-         isym.st_value = 0;
-         isym.st_size = 0;
-         isym.st_name = 0;
-         isym.st_info = 0;
-         isym.st_other = 0;
-         isym.st_shndx = 0;
-         bed->s->swap_symbol_out (output_bfd, &isym, s->contents, 0);
+         /* The first entry in .dynsym is a dummy symbol.
+            Clear all the section syms, in case we don't output them all.  */
+         ++section_sym_count;
+         memset (s->contents, 0, section_sym_count * bed->s->sizeof_sym);
        }
 
       /* Compute the size of the hashing table.  As a side effect this
@@ -9002,17 +9003,17 @@ elf_gc_mark_dynamic_ref_symbol (struct elf_link_hash_entry *h,
 
 static bfd_boolean
 elf_mark_used_section (struct elf_link_hash_entry *h,
-                    void *global ATTRIBUTE_UNUSED)
+                      void *data ATTRIBUTE_UNUSED)
 {
   if (h->root.type == bfd_link_hash_warning)
     h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
-  if ((h->root.type == bfd_link_hash_defined
-       || h->root.type == bfd_link_hash_defweak))
+  if (h->root.type == bfd_link_hash_defined
+      || h->root.type == bfd_link_hash_defweak)
     {
-      asection *s = h->root.u.def.section->output_section;
-      if (s)
-       s->flags |= SEC_KEEP;
+      asection *s = h->root.u.def.section;
+      if (s != NULL && s->output_section != NULL && s->output_section != s)
+       s->output_section->flags |= SEC_KEEP;
     }
 
   return TRUE;
@@ -9032,7 +9033,7 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info)
   if (!info->gc_sections)
     {
       /* If we are called when info->gc_sections is 0, we will mark
-        all sections containing global symbols for non-relocable
+        all sections containing global symbols for non-relocatable
         link.  */
       if (!info->relocatable)
        elf_link_hash_traverse (elf_hash_table (info),
This page took 0.036971 seconds and 4 git commands to generate.