OSDN Git Service

* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Use SYMBOL_CALLS_LOCAL
authorAlan Modra <amodra@bigpond.net.au>
Sat, 17 May 2003 06:16:03 +0000 (06:16 +0000)
committerAlan Modra <amodra@bigpond.net.au>
Sat, 17 May 2003 06:16:03 +0000 (06:16 +0000)
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.

bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf32-ppc.c
bfd/elf64-ppc.c
bfd/elflink.c
bfd/elflink.h

index cafc614..3df4fc8 100644 (file)
@@ -1,3 +1,20 @@
+2003-05-17  Alan Modra  <amodra@bigpond.net.au>
+
+       * 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 <seufer@csv.ica.uni-stuttgart.de>
 
        * bfd.c (_bfd_get_gp_value): Prevent illegal access for abfd null
index b1a441a..cfcb7b3 100644 (file)
@@ -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.  */
index 212e5b3..1e1ab8c 100644 (file)
@@ -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;
index 2887d9b..f32d261 100644 (file)
@@ -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;
index bb5361e..3b0d353 100644 (file)
@@ -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;
index c9618b4..ab8c7de 100644 (file)
@@ -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)