aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2004-04-23 08:51:10 +0000
committerJakub Jelinek <jakub@redhat.com>2004-04-23 08:51:10 +0000
commit47a9f7b34f7a3421ea4d2f55406a24b8028337f9 (patch)
tree52357912bb667a0950846cfd83bd45d7880af605
parent1ffcab4b28f01b7b9933adff2c695a826136168c (diff)
downloadgdb-47a9f7b34f7a3421ea4d2f55406a24b8028337f9.zip
gdb-47a9f7b34f7a3421ea4d2f55406a24b8028337f9.tar.gz
gdb-47a9f7b34f7a3421ea4d2f55406a24b8028337f9.tar.bz2
* elf64-x86-64.c (elf64_x86_64_copy_indirect_symbol): Copy also
ELF_LINK_POINTER_EQUALITY_NEEDED. (elf64_x86_64_check_relocs): Set ELF_LINK_POINTER_EQUALITY_NEEDED if r_type is not R_X86_64_PC32. (elf64_x86_64_finish_dynamic_symbol): If ELF_LINK_POINTER_EQUALITY_NEEDED is not set, clear st_value of SHN_UNDEF symbols.
-rw-r--r--bfd/ChangeLog10
-rw-r--r--bfd/elf64-x86-64.c14
2 files changed, 21 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 60ba092..5177dc3 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,13 @@
+2004-04-22 Jakub Jelinek <jakub@redhat.com>
+
+ * elf64-x86-64.c (elf64_x86_64_copy_indirect_symbol): Copy also
+ ELF_LINK_POINTER_EQUALITY_NEEDED.
+ (elf64_x86_64_check_relocs): Set ELF_LINK_POINTER_EQUALITY_NEEDED
+ if r_type is not R_X86_64_PC32.
+ (elf64_x86_64_finish_dynamic_symbol): If
+ ELF_LINK_POINTER_EQUALITY_NEEDED is not set, clear st_value of
+ SHN_UNDEF symbols.
+
2004-04-22 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* elf32-sh.c (sh_elf_plt_sym_val): New function.
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 360d859..ee1b14e 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -561,7 +561,8 @@ elf64_x86_64_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);
}
@@ -812,6 +813,8 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
/* 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_X86_64_PC32)
+ h->elf_link_hash_flags |= ELF_LINK_POINTER_EQUALITY_NEEDED;
}
/* If we are creating a shared library, and this is a reloc
@@ -2519,11 +2522,16 @@ elf64_x86_64_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;
}
}