From 0444bdd49c08f8fbabd7487823a213921e18c1da Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 4 May 2000 06:38:33 +0000 Subject: [PATCH] =?utf8?q?2000-05-03=20=20Martin=20v.=20L=C3=B6wis=20=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * elflink.h (elf_link_add_object_symbols): Reset dynindx for hidden and internal symbols. (elf_fix_symbol_flags): Clear NEEDS_PLT for symbols with visibility. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Do not assign a PLT or GOT entry to symbols with hidden and internal visibility. --- bfd/ChangeLog | 10 ++++++++++ bfd/elflink.c | 4 ++-- bfd/elflink.h | 24 +++++++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 31db2ae00ba..1d2e135af3b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +2000-05-03 Martin v. Löwis + + * elflink.h (elf_link_add_object_symbols): Reset dynindx for + hidden and internal symbols. + (elf_fix_symbol_flags): Clear NEEDS_PLT for symbols with + visibility. + * elflink.c (_bfd_elf_link_record_dynamic_symbol): Do not + assign a PLT or GOT entry to symbols with hidden and + internal visibility. + 2000-05-03 Mark Elbrecht * bfd/coff-go32.c (COFF_SECTION_ALIGNMENT_ENTRIES): Add entry for diff --git a/bfd/elflink.c b/bfd/elflink.c index 6534d84b18a..1b1548a707c 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -238,8 +238,8 @@ _bfd_elf_link_record_dynamic_symbol (info, h) } h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL; - break; - + return true; + default: break; } diff --git a/bfd/elflink.h b/bfd/elflink.h index b5e4eee9128..16f2f98486e 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -891,6 +891,7 @@ elf_link_add_object_symbols (abfd, info) Elf_External_Sym *esym; Elf_External_Sym *esymend; struct elf_backend_data *bed; + boolean visibility_changed = false; bed = get_elf_backend_data (abfd); add_symbol_hook = bed->elf_add_symbol_hook; @@ -1581,7 +1582,10 @@ elf_link_add_object_symbols (abfd, info) unsigned char symvis = ELF_ST_VISIBILITY (sym.st_other); if (symvis && (hvis > symvis || hvis == 0)) - h->other = sym.st_other; + { + visibility_changed = true; + h->other = sym.st_other; + } /* If neither has visibility, use the st_other of the definition. This is an arbitrary choice, since the @@ -1852,6 +1856,18 @@ elf_link_add_object_symbols (abfd, info) goto error_return; } } + else if (dynsym && h->dynindx != -1 && visibility_changed) + /* If the symbol already has a dynamic index, but + visibility says it should not be visible, turn it into + a local symbol. */ + switch (ELF_ST_VISIBILITY (h->other)) + { + case STV_INTERNAL: + case STV_HIDDEN: + h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL; + (*bed->elf_backend_hide_symbol) (h); + break; + } } } @@ -3339,10 +3355,12 @@ elf_fix_symbol_flags (h, eif) /* If -Bsymbolic was used (which means to bind references to global symbols to the definition within the shared object), and this symbol was defined in a regular object, then it actually doesn't - need a PLT entry. */ + need a PLT entry. Likewise, if the symbol has any kind of + visibility (internal, hidden, or protected), it doesn't need a + PLT. */ if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0 && eif->info->shared - && eif->info->symbolic + && (eif->info->symbolic || ELF_ST_VISIBILITY (h->other)) && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0) { h->elf_link_hash_flags &=~ ELF_LINK_HASH_NEEDS_PLT; -- 2.30.2