aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-x86-64
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 /ld/testsuite/ld-x86-64
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 'ld/testsuite/ld-x86-64')
-rw-r--r--ld/testsuite/ld-x86-64/pr19031.out1
-rw-r--r--ld/testsuite/ld-x86-64/pr19031a.c4
-rw-r--r--ld/testsuite/ld-x86-64/pr19031b.S18
-rw-r--r--ld/testsuite/ld-x86-64/pr19031c.c14
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp16
5 files changed, 53 insertions, 0 deletions
diff --git a/ld/testsuite/ld-x86-64/pr19031.out b/ld/testsuite/ld-x86-64/pr19031.out
new file mode 100644
index 0000000..d86bac9
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr19031.out
@@ -0,0 +1 @@
+OK
diff --git a/ld/testsuite/ld-x86-64/pr19031a.c b/ld/testsuite/ld-x86-64/pr19031a.c
new file mode 100644
index 0000000..fa34d37
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr19031a.c
@@ -0,0 +1,4 @@
+void
+f (void)
+{
+}
diff --git a/ld/testsuite/ld-x86-64/pr19031b.S b/ld/testsuite/ld-x86-64/pr19031b.S
new file mode 100644
index 0000000..ccc9125
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr19031b.S
@@ -0,0 +1,18 @@
+ .text
+ .globl g
+ .type g, @function
+g:
+ movq f@GOTPCREL(%rip), %rax
+ retq
+
+ .globl h
+ .type h, @function
+h:
+ leaq zed, %rax
+ movslq zed, %rbx
+ addq %rbx, %rax
+ retq
+
+ .data
+zed:
+ .long f - .
diff --git a/ld/testsuite/ld-x86-64/pr19031c.c b/ld/testsuite/ld-x86-64/pr19031c.c
new file mode 100644
index 0000000..60eccaf
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr19031c.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+extern void *h (void);
+extern void *g (void);
+
+int
+main (void)
+{
+
+ if (h () == g ())
+ printf ("OK\n");
+
+ return 0;
+}
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 5de67ca..69728c2 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -503,6 +503,14 @@ if { [isnative] && [which $CC] != 0 } {
{{readelf {-Wrd} pr18900b.rd}} \
"pr18900b" \
] \
+ [list \
+ "Build pr19031.so" \
+ "-shared" \
+ "-fPIC" \
+ { pr19031a.c } \
+ "" \
+ "pr19031.so" \
+ ] \
]
run_ld_link_exec_tests [] [list \
@@ -557,6 +565,14 @@ if { [isnative] && [which $CC] != 0 } {
"pr18900" \
"pr18900.out" \
] \
+ [list \
+ "Run pr19031" \
+ "tmpdir/pr19031.so" \
+ "" \
+ { pr19031b.S pr19031c.c } \
+ "pr19031" \
+ "pr19031.out" \
+ ] \
]
if { [istarget "x86_64-*-linux*"] \