aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-12-19 12:21:56 -0800
committerH.J. Lu <hjl.tools@gmail.com>2018-12-19 12:22:12 -0800
commitb9519cfe9828b9ee5a73e74b4be83d46f33e6886 (patch)
treeaecea8a8890eb3cc814a80abdf7c0a976a889f01 /ld
parentfc999e8020ffe8e1136da70f275bceafaa62a588 (diff)
downloadbinutils-b9519cfe9828b9ee5a73e74b4be83d46f33e6886.zip
binutils-b9519cfe9828b9ee5a73e74b4be83d46f33e6886.tar.gz
binutils-b9519cfe9828b9ee5a73e74b4be83d46f33e6886.tar.bz2
x86: Properly handle PLT expression in directive
For PLT expressions, we should subtract the PLT relocation size only for jump instructions. Since PLT relocations are PC relative, we only allow "symbol@PLT" in PLT expression. gas/ PR gas/23997 * config/tc-i386.c (x86_cons): Check for invalid PLT expression. (md_apply_fix): Subtract the PLT relocation size only for jump instructions. * testsuite/gas/i386/reloc32.s: Add test for invalid PLT expression. * testsuite/gas/i386/reloc64.s: Likewise. * testsuite/gas/i386/ilp32/reloc64.s: Likewise. * testsuite/gas/i386/reloc32.l: Updated. * testsuite/gas/i386/reloc64.l: Likewise. * testsuite/gas/i386/ilp32/reloc64.l: Likewise. ld/ PR gas/23997 * testsuite/ld-i386/i386.exp: Run PR gas/23997 test. * testsuite/ld-x86-64/x86-64.exp: Likewise. * testsuite/ld-x86-64/pr23997a.s: New file. * testsuite/ld-x86-64/pr23997b.c: Likewise. * testsuite/ld-x86-64/pr23997c.c: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog9
-rw-r--r--ld/testsuite/ld-i386/i386.exp9
-rw-r--r--ld/testsuite/ld-x86-64/pr23997a.s6
-rw-r--r--ld/testsuite/ld-x86-64/pr23997b.c25
-rw-r--r--ld/testsuite/ld-x86-64/pr23997c.c7
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp8
6 files changed, 64 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 17a2e45..c7d4a0c 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,14 @@
2018-12-19 H.J. Lu <hongjiu.lu@intel.com>
+ PR gas/23997
+ * testsuite/ld-i386/i386.exp: Run PR gas/23997 test.
+ * testsuite/ld-x86-64/x86-64.exp: Likewise.
+ * testsuite/ld-x86-64/pr23997a.s: New file.
+ * testsuite/ld-x86-64/pr23997b.c: Likewise.
+ * testsuite/ld-x86-64/pr23997c.c: Likewise.
+
+2018-12-19 H.J. Lu <hongjiu.lu@intel.com>
+
* testsuite/ld-x86-64/x86-64.exp: Rename PR ld/22842 run-time
test to "Run pr22842".
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index f86a54d..b3c489a 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -1420,6 +1420,15 @@ if { [isnative]
"pr22842" \
"pass.out" \
] \
+ [list \
+ "Run pr23997" \
+ "" \
+ "" \
+ { ../ld-x86-64/pr23997a.s ../ld-x86-64/pr23997b.c \
+ ../ld-x86-64/pr23997c.c } \
+ "pr23997" \
+ "pass.out" \
+ ] \
]
if { [at_least_gcc_version 5 0] } {
diff --git a/ld/testsuite/ld-x86-64/pr23997a.s b/ld/testsuite/ld-x86-64/pr23997a.s
new file mode 100644
index 0000000..8d72c62
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr23997a.s
@@ -0,0 +1,6 @@
+ .text
+ .p2align 3
+ .globl foo_p
+foo_p:
+ .long foo@plt
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/pr23997b.c b/ld/testsuite/ld-x86-64/pr23997b.c
new file mode 100644
index 0000000..02cb8f8
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr23997b.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+
+typedef void (*func_t) (void);
+
+extern func_t get_foo (void);
+
+void
+foo (void)
+{
+}
+
+int
+main ()
+{
+ func_t p;
+
+ foo ();
+ p = get_foo ();
+ p ();
+
+ if (foo == p)
+ printf ("PASS\n");
+
+ return 0;
+}
diff --git a/ld/testsuite/ld-x86-64/pr23997c.c b/ld/testsuite/ld-x86-64/pr23997c.c
new file mode 100644
index 0000000..3573157
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr23997c.c
@@ -0,0 +1,7 @@
+extern int foo_p;
+
+void *
+get_foo (void)
+{
+ return (void *) ((long) &foo_p + foo_p);
+}
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 75e2546..c9e8ecb 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -1594,6 +1594,14 @@ if { [isnative] && [which $CC] != 0 } {
"pr22842" \
"pass.out" \
] \
+ [list \
+ "Run pr23997" \
+ "" \
+ "" \
+ { pr23997a.s pr23997b.c pr23997c.c } \
+ "pr23997" \
+ "pass.out" \
+ ] \
]
# Run-time tests which require working ifunc attribute support.