aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2019-02-05 18:45:23 -0800
committerH.J. Lu <hjl.tools@gmail.com>2019-02-10 05:51:45 -0800
commitc83ac8021a7649c148cb344870d8ce711eecc3c6 (patch)
tree06396273c0ed2c5b3e80a0c100c0f46c500a0274 /ld
parent1532a937c64105681d74055389f0e846244fb830 (diff)
downloadfsf-binutils-gdb-c83ac8021a7649c148cb344870d8ce711eecc3c6.zip
fsf-binutils-gdb-c83ac8021a7649c148cb344870d8ce711eecc3c6.tar.gz
fsf-binutils-gdb-c83ac8021a7649c148cb344870d8ce711eecc3c6.tar.bz2
x86-64: Restore PIC check for PCREL reloc against protected symbol
commit bd7ab16b4537788ad53521c45469a1bdae84ad4a Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Feb 13 07:34:22 2018 -0800 x86-64: Generate branch with PLT32 relocation removed check R_X86_64_PC32 relocation against protected symbols in shared objects. Since elf_x86_64_check_relocs is called after we have seen all input files, we can check for PC-relative relocations in elf_x86_64_check_relocs. We should not allow PC-relative relocations against protected symbols since address of protected function and location of protected data may not be in the shared object. bfd/ PR ld/24151 * elf64-x86-64.c (elf_x86_64_need_pic): Check SYMBOL_DEFINED_NON_SHARED_P instead of def_regular. (elf_x86_64_relocate_section): Move PIC check for PC-relative relocations to ... (elf_x86_64_check_relocs): Here. (elf_x86_64_finish_dynamic_symbol): Use SYMBOL_DEFINED_NON_SHARED_P to check if a symbol is defined in a non-shared object. * elfxx-x86.h (SYMBOL_DEFINED_NON_SHARED_P): New. ld/ PR ld/24151 * testsuite/ld-x86-64/pr24151a-x32.d: New file. * testsuite/ld-x86-64/pr24151a.d: Likewise. * testsuite/ld-x86-64/pr24151a.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr24151a and pr24151a-x32. (cherry picked from commit 83924b3846361f2f76f9a6e7b5afa01c0eebbd4f)
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog8
-rw-r--r--ld/testsuite/ld-x86-64/pr24151a-x32.d4
-rw-r--r--ld/testsuite/ld-x86-64/pr24151a.d3
-rw-r--r--ld/testsuite/ld-x86-64/pr24151a.s9
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp2
5 files changed, 26 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index fcc8aed..00c0785 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,11 @@
+2019-02-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/24151
+ * testsuite/ld-x86-64/pr24151a-x32.d: New file.
+ * testsuite/ld-x86-64/pr24151a.d: Likewise.
+ * testsuite/ld-x86-64/pr24151a.s: Likewise.
+ * testsuite/ld-x86-64/x86-64.exp: Run pr24151a and pr24151a-x32.
+
2019-01-29 Eric Botcazou <ebotcazou@adacore.com>
* testsuite/ld-ifunc/ifunc.exp: Skip pr23169 on SPARC.
diff --git a/ld/testsuite/ld-x86-64/pr24151a-x32.d b/ld/testsuite/ld-x86-64/pr24151a-x32.d
new file mode 100644
index 0000000..130611d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr24151a-x32.d
@@ -0,0 +1,4 @@
+#source: pr24151a.s
+#as: --x32
+#ld: -shared -melf32_x86_64
+#error: .*relocation R_X86_64_PC32 against protected symbol `foo' can not be used when making a shared object
diff --git a/ld/testsuite/ld-x86-64/pr24151a.d b/ld/testsuite/ld-x86-64/pr24151a.d
new file mode 100644
index 0000000..783b85a
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr24151a.d
@@ -0,0 +1,3 @@
+#as: --64
+#ld: -shared -melf_x86_64
+#error: .*relocation R_X86_64_PC32 against protected symbol `foo' can not be used when making a shared object
diff --git a/ld/testsuite/ld-x86-64/pr24151a.s b/ld/testsuite/ld-x86-64/pr24151a.s
new file mode 100644
index 0000000..e4ec7c8
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr24151a.s
@@ -0,0 +1,9 @@
+ .text
+ .globl bar
+ .type bar,@function
+bar:
+ movl $30, foo(%rip)
+ .size bar, .-bar
+ .protected foo
+ .type foo,@object
+ .comm foo,4,4
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 9abafd2..ac41d8e 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -408,6 +408,8 @@ run_dump_test "pr23486a-x32"
run_dump_test "pr23486b"
run_dump_test "pr23486b-x32"
run_dump_test "pr23854"
+run_dump_test "pr24151a"
+run_dump_test "pr24151a-x32"
if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
return