* elf-bfd.h (ELF_LINK_NON_GOT_REF): Define.
authorIan Lance Taylor <ian@airs.com>
Sat, 4 Sep 1999 16:26:08 +0000 (16:26 +0000)
committerIan Lance Taylor <ian@airs.com>
Sat, 4 Sep 1999 16:26:08 +0000 (16:26 +0000)
* elflink.h (elf_adjust_dynamic_symbol): Copy REF_REGULAR_NONWEAK
and NON_GOT_REF from weak defined symbol to real symbol.
* elf32-i386.c (elf_i386_check_relocs): Set NON_GOT_REF.
(elf_i386_adjust_dynamic_symbol): If NON_GOT_REF is not set, don't
create a COPY reloc.
* elf32-sparc.c (elf32_sparc_check_relocs): Set NON_GOT_REF.
(elf32_sparc_adjust_dynamic_symbol): If NON_GOT_REF is not set,
don't create a COPY reloc.

bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf32-i386.c
bfd/elf32-sparc.c
bfd/elflink.h

index 412262f91aba627ce89f01e9df2066299f01229a..0e3c2ca8ec46fe785042d66cdd84cc3778581cae 100644 (file)
@@ -1,3 +1,15 @@
+1999-09-04  Ian Lance Taylor  <ian@zembu.com>
+
+       * elf-bfd.h (ELF_LINK_NON_GOT_REF): Define.
+       * elflink.h (elf_adjust_dynamic_symbol): Copy REF_REGULAR_NONWEAK
+       and NON_GOT_REF from weak defined symbol to real symbol.
+       * elf32-i386.c (elf_i386_check_relocs): Set NON_GOT_REF.
+       (elf_i386_adjust_dynamic_symbol): If NON_GOT_REF is not set, don't
+       create a COPY reloc.
+       * elf32-sparc.c (elf32_sparc_check_relocs): Set NON_GOT_REF.
+       (elf32_sparc_adjust_dynamic_symbol): If NON_GOT_REF is not set,
+       don't create a COPY reloc.
+
 1999-09-03  Ian Lance Taylor  <ian@zembu.com>
 
        * elflink.h (elf_bfd_final_link): When counting relocations, don't
index 3fa25136fd2d32aa992c666ec3ded9c0cc71767e..1868cb675940d5bb7c4853c9df67aa63c2acc6cf 100644 (file)
@@ -189,6 +189,9 @@ struct elf_link_hash_entry
 #define ELF_LINK_FORCED_LOCAL 02000
   /* Symbol was marked during garbage collection.  */
 #define ELF_LINK_HASH_MARK 04000
+  /* Symbol is referenced by a non-GOT/non-PLT relocation.  This is
+     not currently set by all the backends.  */
+#define ELF_LINK_NON_GOT_REF 010000
 };
 
 /* Records local symbols to be emitted in the dynamic symbol table.  */
index 0790af5eb0b15bf725f499453ac24eb0ec1779c1..33514ac9bff7f1a921cf76e4e92644d737a3d0f0 100644 (file)
@@ -591,6 +591,9 @@ elf_i386_check_relocs (abfd, info, sec, relocs)
 
        case R_386_32:
        case R_386_PC32:
+         if (h != NULL)
+           h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
+
          /* If we are creating a shared library, and this is a reloc
              against a global symbol, or a non PC relative reloc
              against a local symbol, then we need to copy the reloc
@@ -889,6 +892,11 @@ elf_i386_adjust_dynamic_symbol (info, h)
   if (info->shared)
     return true;
 
+  /* If there are no references to this symbol that do not use the
+     GOT, we don't need to generate a copy reloc.  */
+  if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
+    return true;
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
index bb11c070d36a764fe8a080efced17dc0b753a288..979d25b595a1071d384a17ecd6f3d8e2d670c008 100644 (file)
@@ -510,6 +510,9 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs)
 
        case R_SPARC_PC10:
        case R_SPARC_PC22:
+         if (h != NULL)
+           h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
+
          if (h != NULL
              && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
            break;
@@ -521,6 +524,9 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs)
        case R_SPARC_WDISP22:
        case R_SPARC_WDISP19:
        case R_SPARC_WDISP16:
+         if (h != NULL)
+           h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
+
          /* If we are linking with -Bsymbolic, we do not need to copy
              a PC relative reloc against a global symbol which is
              defined in an object we are including in the link (i.e.,
@@ -543,6 +549,9 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs)
        case R_SPARC_13:
        case R_SPARC_LO10:
        case R_SPARC_UA32:
+         if (h != NULL)
+           h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
+
          if (info->shared)
            {
              /* When creating a shared object, we must copy these
@@ -834,6 +843,11 @@ elf32_sparc_adjust_dynamic_symbol (info, h)
   if (info->shared)
     return true;
 
+  /* If there are no references to this symbol that do not use the
+     GOT, we don't need to generate a copy reloc.  */
+  if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
+    return true;
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
index e60beae8a7c08746ebf8e880f32f873335a18e28..e9ba45adffb8b03354ea0cb2068c17fc76bd92c1 100644 (file)
@@ -3349,10 +3349,11 @@ elf_adjust_dynamic_symbol (h, data)
        {
          /* There is an implicit reference by a regular object file
             via the weak symbol.  */
-         weakdef->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR;
-         if (h->weakdef->elf_link_hash_flags
-             & ELF_LINK_HASH_REF_REGULAR_NONWEAK)
-           weakdef->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR_NONWEAK;
+         weakdef->elf_link_hash_flags |=
+           (ELF_LINK_HASH_REF_REGULAR
+            | (h->elf_link_hash_flags
+               & (ELF_LINK_HASH_REF_REGULAR_NONWEAK
+                  | ELF_LINK_NON_GOT_REF)));
          if (! elf_adjust_dynamic_symbol (weakdef, (PTR) eif))
            return false;
        }
This page took 0.035782 seconds and 4 git commands to generate.