aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-i386
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-04-10 14:02:23 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-04-10 14:02:23 -0700
commit3d9499950a94df8577fa01ba98ec0d58f07fd9c0 (patch)
tree4ec8ffff58a0fa7867665e53f261b04d9cc4d9c0 /ld/testsuite/ld-i386
parent9ee417720b2f25c56a9738569b63f686cbc8584f (diff)
downloadgdb-3d9499950a94df8577fa01ba98ec0d58f07fd9c0.zip
gdb-3d9499950a94df8577fa01ba98ec0d58f07fd9c0.tar.gz
gdb-3d9499950a94df8577fa01ba98ec0d58f07fd9c0.tar.bz2
Check GOTOFF reloc against protected data on x86
R_386_GOTOFF/R_X86_64_GOTOFF64 relocation shouldn't be used against protected data symbol on x86 since with copy relocation, address of protected data defined in the shared library may be external. This patch will break building shared libraries with protected data symbols using GCCs older than GCC 5 without the bug fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248 GCC backport request should be made in the GCC bug report above. bfd/ PR ld/pr17709 * elf32-i386.c (elf_i386_relocate_section): Also check R_386_GOTOFF against protected data symbol when building shared library. * elf64-x86-64.c (elf_x86_64_relocate_section): Also check R_X86_64_GOTOFF64 against protected data symbol when building shared library. ld/testsuite/ PR ld/pr17709 * ld-i386/protected6.d: New file. * ld-i386/protected6.s: Likewise. * ld-x86-64/protected6.d: Likewise. * ld-x86-64/protected6.s: Likewise. * ld-x86-64/protected7.d: Likewise. * ld-x86-64/protected7.s: Likewise. * ld-x86-64/protected7a.d: Likewise. * ld-x86-64/protected7b.d: Likewise.
Diffstat (limited to 'ld/testsuite/ld-i386')
-rw-r--r--ld/testsuite/ld-i386/i386.exp1
-rw-r--r--ld/testsuite/ld-i386/protected6.d3
-rw-r--r--ld/testsuite/ld-i386/protected6.s14
3 files changed, 18 insertions, 0 deletions
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 3fdd39c..3dd1139 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -236,6 +236,7 @@ run_dump_test "protected2"
run_dump_test "protected3"
run_dump_test "protected4"
run_dump_test "protected5"
+run_dump_test "protected6"
run_dump_test "tlspie1"
run_dump_test "tlspie2"
run_dump_test "nogot1"
diff --git a/ld/testsuite/ld-i386/protected6.d b/ld/testsuite/ld-i386/protected6.d
new file mode 100644
index 0000000..37d5132
--- /dev/null
+++ b/ld/testsuite/ld-i386/protected6.d
@@ -0,0 +1,3 @@
+#as: --32
+#ld: -shared -melf_i386
+#error: .*relocation R_386_GOTOFF against protected data `foo' can not be used when making a shared object
diff --git a/ld/testsuite/ld-i386/protected6.s b/ld/testsuite/ld-i386/protected6.s
new file mode 100644
index 0000000..f57900e
--- /dev/null
+++ b/ld/testsuite/ld-i386/protected6.s
@@ -0,0 +1,14 @@
+ .data
+ .protected foo
+ .globl foo
+ .align 4
+ .type foo, @object
+ .size foo, 4
+foo:
+ .long 1
+ .text
+ .globl bar
+ .type bar, @function
+bar:
+ movl foo@GOTOFF(%ecx), %eax
+ .size bar, .-bar