From c46cec3a8cfe02fbe0f6c67ba53abc5369c5c659 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Mon, 24 Apr 2017 20:13:28 +0100 Subject: [PATCH] ELF/BFD: Limit `_bfd_elf_link_renumber_dynsyms' call in section GC 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."), . 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 | 6 ++++++ bfd/elflink.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 7fb1baf18e..0e6ac1b451 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2017-04-26 Maciej W. Rozycki + + * 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 PR binutils/21431 diff --git a/bfd/elflink.c b/bfd/elflink.c index 0d42c4c5f9..05b12112ce 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -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, §ion_sym_count); + if (elf_hash_table (info)->dynamic_sections_created) + _bfd_elf_link_renumber_dynsyms (output_bfd, info, §ion_sym_count); } /* Any syms created from now on start with -1 in -- 2.34.1