diff --git a/bfd/ChangeLog b/bfd/ChangeLog index bfe2aa293c..8ed9765100 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2018-07-03 Alan Modra + + PR 17550 + * elflink.c (_bfd_elf_fix_symbol_flags): Hide dynamic symbols + in discarded sections. + 2018-07-02 Maciej W. Rozycki * elfxx-mips.c (_bfd_mips_elf_create_dynamic_sections): Set diff --git a/bfd/elflink.c b/bfd/elflink.c index 36e0c37c8e..e5592b023a 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -2853,10 +2853,14 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h, && (h->root.u.def.section->owner->flags & (DYNAMIC | BFD_PLUGIN)) == 0) h->def_regular = 1; + /* Symbols defined in discarded sections shouldn't be dynamic. */ + if (h->root.type == bfd_link_hash_undefined && h->indx == -3) + (*bed->elf_backend_hide_symbol) (eif->info, h, TRUE); + /* If a weak undefined symbol has non-default visibility, we also hide it from the dynamic linker. */ - if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT - && h->root.type == bfd_link_hash_undefweak) + else if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + && h->root.type == bfd_link_hash_undefweak) (*bed->elf_backend_hide_symbol) (eif->info, h, TRUE); /* A hidden versioned symbol in executable should be forced local if