aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-i386.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2003-11-22 10:45:44 +0000
committerJakub Jelinek <jakub@redhat.com>2003-11-22 10:45:44 +0000
commitc6585bbb101d8e377478a01b64d75d9d415dbd01 (patch)
tree384d6c3a25ee4722262bd804935dbb182400c7d0 /bfd/elf32-i386.c
parentf22b3cafc9a10cda728946d2fa7cc37ff905136f (diff)
downloadgdb-c6585bbb101d8e377478a01b64d75d9d415dbd01.zip
gdb-c6585bbb101d8e377478a01b64d75d9d415dbd01.tar.gz
gdb-c6585bbb101d8e377478a01b64d75d9d415dbd01.tar.bz2
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.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r--bfd/elf32-i386.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 9814543..8adaa0f 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -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;
}
}