ELF/BFD: Limit `_bfd_elf_link_renumber_dynsyms' call in section GC
authorMaciej W. Rozycki <macro@imgtec.com>
Mon, 24 Apr 2017 19:13:28 +0000 (20:13 +0100)
committerMaciej W. Rozycki <macro@imgtec.com>
Wed, 26 Apr 2017 12:15:17 +0000 (13:15 +0100)
Consistently call `_bfd_elf_link_renumber_dynsyms' only if linking a
dynamic binary, complementing code in `bfd_elf_size_dynsym_hash_dynstr'
and commit ccabcbe51e85 ("New attempt at fixing MIPS --gc-sections et
al."), <https://sourceware.org/ml/binutils/2005-08/msg00258.html>.

bfd/
* elflink.c (bfd_elf_size_dynamic_sections): Only call
`_bfd_elf_link_renumber_dynsyms' after section GC if dynamic
sections have been created.

bfd/ChangeLog
bfd/elflink.c

index 7fb1baf..0e6ac1b 100644 (file)
@@ -1,3 +1,9 @@
+2017-04-26  Maciej W. Rozycki  <macro@imgtec.com>
+
+       * elflink.c (bfd_elf_size_dynamic_sections): Only call
+       `_bfd_elf_link_renumber_dynsyms' after section GC if dynamic
+       sections have been created.
+
 2017-04-26  Nick Clifton  <nickc@redhat.com>
 
        PR binutils/21431
index 0d42c4c..05b1211 100644 (file)
@@ -6460,7 +6460,8 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
       elf_link_hash_traverse (elf_hash_table (info), elf_gc_sweep_symbol,
                              &sweep_info);
 
-      _bfd_elf_link_renumber_dynsyms (output_bfd, info, &section_sym_count);
+      if (elf_hash_table (info)->dynamic_sections_created)
+       _bfd_elf_link_renumber_dynsyms (output_bfd, info, &section_sym_count);
     }
 
   /* Any syms created from now on start with -1 in