mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-28 18:10:46 +00:00
elf: Renumber local dynamic symbols only if needed
Only hppa, ia64 and sparc ELF targets use local dynamic symbols. But elf_link_renumber_local_hash_table_dynsyms is always called to renumber local dynamic symbols even if there is none. Add has_local_dynsyms to elf_link_hash_table and set it to true only if there are local dynamic symbols. Renumber local dynamic symbols only if there are local dynamic symbols. * elf-bfd.h (elf_link_hash_table): Add has_local_dynsyms. * elflink.c (_bfd_elf_link_renumber_dynsyms): Renumber local dynamic symbols only if there are local dynamic symbols. (_bfd_elf_adjust_dynamic_symbol): Set has_local_dynsyms if there are local dynamic symbols. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
@@ -637,6 +637,9 @@ struct elf_link_hash_table
|
||||
/* Whether dynamic relocations are present. */
|
||||
bool dynamic_relocs;
|
||||
|
||||
/* TRUE if there are local dynamic symbols. */
|
||||
bool has_local_dynsyms;
|
||||
|
||||
/* True if this target has relocatable executables, so needs dynamic
|
||||
section symbols. */
|
||||
bool is_relocatable_executable;
|
||||
|
||||
@@ -1064,9 +1064,10 @@ _bfd_elf_link_renumber_dynsyms (bfd *output_bfd,
|
||||
if (do_sec)
|
||||
*section_sym_count = dynsymcount;
|
||||
|
||||
elf_link_hash_traverse (elf_hash_table (info),
|
||||
elf_link_renumber_local_hash_table_dynsyms,
|
||||
&dynsymcount);
|
||||
if (elf_hash_table (info)->has_local_dynsyms)
|
||||
elf_link_hash_traverse (elf_hash_table (info),
|
||||
elf_link_renumber_local_hash_table_dynsyms,
|
||||
&dynsymcount);
|
||||
|
||||
if (elf_hash_table (info)->dynlocal)
|
||||
{
|
||||
@@ -3269,6 +3270,10 @@ _bfd_elf_adjust_dynamic_symbol (struct elf_link_hash_entry *h, void *data)
|
||||
if (! is_elf_hash_table (eif->info->hash))
|
||||
return false;
|
||||
|
||||
htab = elf_hash_table (eif->info);
|
||||
if (h->forced_local && h->dynindx != -1)
|
||||
htab->has_local_dynsyms = true;
|
||||
|
||||
/* Ignore indirect symbols. These are added by the versioning code. */
|
||||
if (h->root.type == bfd_link_hash_indirect)
|
||||
return true;
|
||||
@@ -3277,7 +3282,6 @@ _bfd_elf_adjust_dynamic_symbol (struct elf_link_hash_entry *h, void *data)
|
||||
if (! _bfd_elf_fix_symbol_flags (h, eif))
|
||||
return false;
|
||||
|
||||
htab = elf_hash_table (eif->info);
|
||||
bed = get_elf_backend_data (htab->dynobj);
|
||||
|
||||
if (h->root.type == bfd_link_hash_undefweak)
|
||||
|
||||
Reference in New Issue
Block a user