2003-11-22 Jakub Jelinek <jakub@redhat.com>
authorJakub Jelinek <jakub@redhat.com>
Sat, 22 Nov 2003 10:45:44 +0000 (10:45 +0000)
committerJakub Jelinek <jakub@redhat.com>
Sat, 22 Nov 2003 10:45:44 +0000 (10:45 +0000)
* elf-bfd.h (ELF_LINK_POINTER_EQUALITY_NEEDED): Define new flag.
* elf.c (_bfd_elf_link_hash_copy_indirect): Copy it.
* elf32-i386.c (elf_i386_copy_indirect_symbol): Likewise.
(elf_i386_check_relocs): Set it.
(elf_i386_finish_dynamic_symbol): If it is not set,
clear st_value of SHN_UNDEF symbol.

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

index 69d676ff310bace2bc40afe879b3dbc6bd996919..9010d72188a01ab141a2e3f518c61045dec083b2 100644 (file)
@@ -1,3 +1,12 @@
+2003-11-22  Jakub Jelinek  <jakub@redhat.com>
+
+       * elf-bfd.h (ELF_LINK_POINTER_EQUALITY_NEEDED): Define new flag.
+       * elf.c (_bfd_elf_link_hash_copy_indirect): Copy it.
+       * elf32-i386.c (elf_i386_copy_indirect_symbol): Likewise.
+       (elf_i386_check_relocs): Set it.
+       (elf_i386_finish_dynamic_symbol): If it is not set,
+       clear st_value of SHN_UNDEF symbol.
+
 2003-11-20  Jim Blandy  <jimb@redhat.com>
 
        * cpu-powerpc.c (powerpc_compatible): Any ISA in the PowerPC
index d5965d3ffb94b18a3552484e4d39aa0b20085a8c..5cb7efaa17bf03cd8a4605c19992c88e9bada57b 100644 (file)
@@ -200,6 +200,9 @@ struct elf_link_hash_entry
 #define ELF_LINK_DYNAMIC_DEF 020000
   /* Symbol is weak in all shared objects.  */
 #define ELF_LINK_DYNAMIC_WEAK 040000
+  /* Symbol is referenced with a relocation where C/C++ pointer equality
+     matters.  */
+#define ELF_LINK_POINTER_EQUALITY_NEEDED 0100000
 };
 
 /* Will references to this symbol always reference the symbol
index e6965af375e0c719a06c1b4c47c970f22d6f360c..31003d7508a37910a864ae01e1a46e8c6bf9e354 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1359,7 +1359,8 @@ _bfd_elf_link_hash_copy_indirect (const struct elf_backend_data *bed,
                                    | ELF_LINK_HASH_REF_REGULAR
                                    | ELF_LINK_HASH_REF_REGULAR_NONWEAK
                                    | ELF_LINK_NON_GOT_REF
-                                   | ELF_LINK_HASH_NEEDS_PLT));
+                                   | ELF_LINK_HASH_NEEDS_PLT
+                                   | ELF_LINK_POINTER_EQUALITY_NEEDED));
 
   if (ind->root.type != bfd_link_hash_indirect)
     return;
index 9814543e9649b53da3225eb62d058c69a95bb8c8..8adaa0faac382f837441672f8186e8fb230f147d 100644 (file)
@@ -771,7 +771,8 @@ elf_i386_copy_indirect_symbol (const struct elf_backend_data *bed,
       (ind->elf_link_hash_flags & (ELF_LINK_HASH_REF_DYNAMIC
                                   | ELF_LINK_HASH_REF_REGULAR
                                   | ELF_LINK_HASH_REF_REGULAR_NONWEAK
-                                  | ELF_LINK_HASH_NEEDS_PLT));
+                                  | ELF_LINK_HASH_NEEDS_PLT
+                                  | ELF_LINK_POINTER_EQUALITY_NEEDED));
   else
     _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
 }
@@ -1001,6 +1002,8 @@ elf_i386_check_relocs (bfd *abfd,
              /* We may need a .plt entry if the function this reloc
                 refers to is in a shared lib.  */
              h->plt.refcount += 1;
+             if (r_type != R_386_PC32)
+               h->elf_link_hash_flags |= ELF_LINK_POINTER_EQUALITY_NEEDED;
            }
 
          /* If we are creating a shared library, and this is a reloc
@@ -3004,11 +3007,16 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd,
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
        {
          /* Mark the symbol as undefined, rather than as defined in
-            the .plt section.  Leave the value alone.  This is a clue
+            the .plt section.  Leave the value if there were any
+            relocations where pointer equality matters (this is a clue
             for the dynamic linker, to make function pointer
             comparisons work between an application and shared
-            library.  */
+            library), otherwise set it to zero.  If a function is only
+            called from a binary, there is no need to slow down
+            shared libraries because of that.  */
          sym->st_shndx = SHN_UNDEF;
+         if ((h->elf_link_hash_flags & ELF_LINK_POINTER_EQUALITY_NEEDED) == 0)
+           sym->st_value = 0;
        }
     }
 
This page took 0.036501 seconds and 4 git commands to generate.