aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-x86-64.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-10-01 10:49:33 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-10-01 10:49:33 -0700
commit5db4f0d383e3de40e594cf05dd8f6d743233a487 (patch)
treef5231fc84b681e870f9d1c84cb9273b5b1b79353 /bfd/elf64-x86-64.c
parentdd0a637a3d8f5ca7229131c085ef6b8e255d01f6 (diff)
downloadgdb-5db4f0d383e3de40e594cf05dd8f6d743233a487.zip
gdb-5db4f0d383e3de40e594cf05dd8f6d743233a487.tar.gz
gdb-5db4f0d383e3de40e594cf05dd8f6d743233a487.tar.bz2
Create a PLT entry for R_X86_64_PC32 in non-code sections
Since something like ".long foo - ." may be used as pointer, we make sure that PLT is used if foo is a function defined in a shared library. bfd/ PR ld/19031 * elf64-x86-64.c (elf_x86_64_check_relocs): Set pointer_equality_needed for R_X86_64_PC32 reloc in non-code sections. ld/testsuite/ PR ld/19031 * ld-x86-64/x86-64.exp: Run PR ld/19031 test. * ld-x86-64/pr19031.out: New file. * ld-x86-64/pr19031a.c: Likewise. * ld-x86-64/pr19031b.S: Likewise. * ld-x86-64/pr19031c.c: Likewise.
Diffstat (limited to 'bfd/elf64-x86-64.c')
-rw-r--r--bfd/elf64-x86-64.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index cbb8cfb..29639d8 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1961,9 +1961,16 @@ pointer:
/* 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
- && r_type != R_X86_64_PC32_BND
- && r_type != R_X86_64_PC64)
+ if (r_type == R_X86_64_PC32)
+ {
+ /* Since something like ".long foo - ." may be used
+ as pointer, make sure that PLT is used if foo is
+ a function defined in a shared library. */
+ if ((sec->flags & SEC_CODE) == 0)
+ h->pointer_equality_needed = 1;
+ }
+ else if (r_type != R_X86_64_PC32_BND
+ && r_type != R_X86_64_PC64)
{
h->pointer_equality_needed = 1;
/* At run-time, R_X86_64_64 can be resolved for both