From: Alan Modra Date: Sat, 17 May 2003 06:16:03 +0000 (+0000) Subject: * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Use SYMBOL_CALLS_LOCAL X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9c7a29a32e738b51793f7f2bcaa4b403373b478c;p=binutils-gdb.git * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Use SYMBOL_CALLS_LOCAL to trim plt entries. Move undefweak non-default visibility test.. (allocate_dynrelocs): ..from here. * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Don't test dynamic_sections_created here. Update comment. Move undefweak non-default visibility test.. (allocate_dynrelocs): ..from here. Fix comment. * elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Use SYMBOL_CALLS_LOCAL to trim plt entries. Move undefweak non-default visibility test.. (allocate_dynrelocs): ..from here. Fix comment. * elflink.h (elf_link_output_extsym): Compare ELF_ST_VISIBILITY with STV_DEFAULT rather than comparing with zero. * elflink.c (_bfd_elf_merge_symbol): Likewise. (_bfd_elf_fix_symbol_flags): Likewise. Format comment. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index cafc614640f..3df4fc8ed3f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,20 @@ +2003-05-17 Alan Modra + + * elf32-i386.c (elf_i386_adjust_dynamic_symbol): Use SYMBOL_CALLS_LOCAL + to trim plt entries. Move undefweak non-default visibility test.. + (allocate_dynrelocs): ..from here. + * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Don't test + dynamic_sections_created here. Update comment. Move undefweak + non-default visibility test.. + (allocate_dynrelocs): ..from here. Fix comment. + * elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Use SYMBOL_CALLS_LOCAL + to trim plt entries. Move undefweak non-default visibility test.. + (allocate_dynrelocs): ..from here. Fix comment. + * elflink.h (elf_link_output_extsym): Compare ELF_ST_VISIBILITY with + STV_DEFAULT rather than comparing with zero. + * elflink.c (_bfd_elf_merge_symbol): Likewise. + (_bfd_elf_fix_symbol_flags): Likewise. Format comment. + 2003-05-17 Thiemo Seufer * bfd.c (_bfd_get_gp_value): Prevent illegal access for abfd null diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index b1a441aaa7a..cfcb7b34c19 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1390,11 +1390,9 @@ elf_i386_adjust_dynamic_symbol (info, h) || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) { if (h->plt.refcount <= 0 - || (! info->shared - && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0 - && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0 - && h->root.type != bfd_link_hash_undefweak - && h->root.type != bfd_link_hash_undefined)) + || SYMBOL_CALLS_LOCAL (info, h) + || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + && h->root.type == bfd_link_hash_undefweak)) { /* This case can occur if we saw a PLT32 reloc in an input file, but the symbol was never referred to by a dynamic @@ -1558,9 +1556,7 @@ allocate_dynrelocs (h, inf) htab = elf_i386_hash_table (info); if (htab->elf.dynamic_sections_created - && h->plt.refcount > 0 - && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT - || h->root.type != bfd_link_hash_undefweak)) + && h->plt.refcount > 0) { /* Make sure this symbol is output as a dynamic symbol. Undefined weak syms won't yet be marked as dynamic. */ diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 212e5b34f4a..1e1ab8cce3b 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -2495,19 +2495,21 @@ ppc_elf_adjust_dynamic_symbol (info, h) { /* Clear procedure linkage table information for any symbol that won't need a .plt entry. */ - if (! htab->elf.dynamic_sections_created + if (h->plt.refcount <= 0 || SYMBOL_CALLS_LOCAL (info, h) - || h->plt.refcount <= 0) + || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + && h->root.type == bfd_link_hash_undefweak)) { /* A PLT entry is not required/allowed when: - 1. We are not using ld.so; because then the PLT entry - can't be set up, so we can't use one. + 1. We are not using ld.so; because then the PLT entry + can't be set up, so we can't use one. In this case, + ppc_elf_adjust_dynamic_symbol won't even be called. - 2. We know for certain that a call to this symbol - will go to this object. + 2. GC has rendered the entry unused. - 3. GC has rendered the entry unused. */ + 3. We know for certain that a call to this symbol + will go to this object, or will remain undefined. */ h->plt.offset = (bfd_vma) -1; h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; } @@ -2673,9 +2675,7 @@ allocate_dynrelocs (h, inf) htab = ppc_elf_hash_table (info); if (htab->elf.dynamic_sections_created - && h->plt.refcount > 0 - && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT - || h->root.type != bfd_link_hash_undefweak)) + && h->plt.refcount > 0) { /* Make sure this symbol is output as a dynamic symbol. */ if (h->dynindx == -1 @@ -2799,12 +2799,12 @@ allocate_dynrelocs (h, inf) if (info->shared) { - /* Relocs that use pc_count are those that appear on a call - insn, or certain REL relocs (see MUST_BE_DYN_RELOC) that can - generated via assembly. We want calls to protected symbols - to resolve directly to the function rather than going via the - plt. If people want function pointer comparisons to work as - expected then they should avoid writing weird assembly. */ + /* Relocs that use pc_count are those that appear on a call insn, + or certain REL relocs (see MUST_BE_DYN_RELOC) that can be + generated via assembly. We want calls to protected symbols to + resolve directly to the function rather than going via the plt. + If people want function pointer comparisons to work as expected + then they should avoid writing weird assembly. */ if (SYMBOL_CALLS_LOCAL (info, h)) { struct ppc_elf_dyn_relocs **pp; diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 2887d9bfef0..f32d261fe6e 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -4505,10 +4505,9 @@ ppc64_elf_adjust_dynamic_symbol (info, h) break; if (!((struct ppc_link_hash_entry *) h)->is_func_descriptor || ent == NULL - || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0 - || (! info->shared - && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0 - && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0)) + || SYMBOL_CALLS_LOCAL (info, h) + || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + && h->root.type == bfd_link_hash_undefweak)) { h->plt.plist = NULL; h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; @@ -5496,9 +5495,7 @@ allocate_dynrelocs (h, inf) if (htab->elf.dynamic_sections_created && h->dynindx != -1 - && WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h) - && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT - || h->root.type != bfd_link_hash_undefweak)) + && WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h)) { struct plt_entry *pent; bfd_boolean doneone = FALSE; @@ -5621,12 +5618,12 @@ allocate_dynrelocs (h, inf) if (info->shared) { - /* Relocs that use pc_count are those that appear on a call - insn, or certain REL relocs (see MUST_BE_DYN_RELOC) that can - generated via assembly. We want calls to protected symbols - to resolve directly to the function rather than going via the - plt. If people want function pointer comparisons to work as - expected then they should avoid writing weird assembly. */ + /* Relocs that use pc_count are those that appear on a call insn, + or certain REL relocs (see MUST_BE_DYN_RELOC) that can be + generated via assembly. We want calls to protected symbols to + resolve directly to the function rather than going via the plt. + If people want function pointer comparisons to work as expected + then they should avoid writing weird assembly. */ if (SYMBOL_CALLS_LOCAL (info, h)) { struct ppc_dyn_relocs **pp; diff --git a/bfd/elflink.c b/bfd/elflink.c index bb5361ef227..3b0d3531f2d 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -855,7 +855,7 @@ _bfd_elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, skip, /* If the old symbol has non-default visibility, we ignore the new definition from a dynamic object. */ if (newdyn - && ELF_ST_VISIBILITY (h->other) + && ELF_ST_VISIBILITY (h->other) != STV_DEFAULT && !bfd_is_und_section (sec)) { *skip = TRUE; @@ -871,7 +871,7 @@ _bfd_elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, skip, return TRUE; } else if (!newdyn - && ELF_ST_VISIBILITY (sym->st_other) + && ELF_ST_VISIBILITY (sym->st_other) != STV_DEFAULT && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0) { /* If the new symbol with non-default visibility comes from a @@ -2427,8 +2427,8 @@ _bfd_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. Likewise, if the symbol has non-default - visibility. If the symbol has hidden or internal visibility, we + need a PLT entry. Likewise, if the symbol has non-default + visibility. If the symbol has hidden or internal visibility, we will force it local. */ if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0 && eif->info->shared @@ -2449,7 +2449,7 @@ _bfd_elf_fix_symbol_flags (h, eif) /* If a weak undefined symbol has non-default visibility, we also hide it from the dynamic linker. */ - if (ELF_ST_VISIBILITY (h->other) + if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT && h->root.type == bfd_link_hash_undefweak) { struct elf_backend_data *bed; diff --git a/bfd/elflink.h b/bfd/elflink.h index c9618b47771..ab8c7dec3b4 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -4620,7 +4620,7 @@ elf_link_output_extsym (h, data) /* If a non-weak symbol with non-default visibility is not defined locally, it is a fatal error. */ if (! finfo->info->relocateable - && ELF_ST_VISIBILITY (sym.st_other) + && ELF_ST_VISIBILITY (sym.st_other) != STV_DEFAULT && ELF_ST_BIND (sym.st_info) != STB_WEAK && h->root.type != bfd_link_hash_undefweak && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)