aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-i386
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2022-06-25 10:44:26 -0700
committerH.J. Lu <hjl.tools@gmail.com>2022-07-19 08:41:52 -0700
commitd19a265487eda186b6977d9d15648cda9fad3298 (patch)
treeb5a00da21278e636f234bd0c9c002f463ac1533e /ld/testsuite/ld-i386
parente9061058b4fb26a6b4a7243f5dca1eb9066f2671 (diff)
downloadgdb-d19a265487eda186b6977d9d15648cda9fad3298.zip
gdb-d19a265487eda186b6977d9d15648cda9fad3298.tar.gz
gdb-d19a265487eda186b6977d9d15648cda9fad3298.tar.bz2
x86: Make protected symbols local for -shared
Call _bfd_elf_symbol_refs_local_p with local_protected==true. This has 2 noticeable effects for -shared: * GOT-generating relocations referencing a protected data symbol no longer lead to a GLOB_DAT (similar to a hidden symbol). * Direct access relocations (e.g. R_X86_64_PC32) no longer has the confusing diagnostic below. __attribute__((visibility("protected"))) void *foo() { return (void *)foo; } // gcc -fpic -shared -fuse-ld=bfd relocation R_X86_64_PC32 against protected symbol `foo' can not be used when making a shared object The new behavior matches arm, aarch64 (commit 83c325007c5599fa9b60b8d5f7b84842160e1d1b), and powerpc ports, and other linkers: gold and ld.lld. Note: if some code tries to use direct access relocations to take the address of foo, the pointer equality will break, but the error should be reported on the executable link, not on the innocent shared object link. glibc 2.36 will give a warning at relocation resolving time. With this change, `#define elf_backend_extern_protected_data 1` is no longer effective. Just remove it. Remove the test "Run protected-func-1 without PIE" since -fno-pic address taken operation in the executable doesn't work with protected symbol in a shared object by default. Similarly, remove protected-data-1a and protected-data-1b. protected-data-1b can be made working by removing HAVE_LD_PIE_COPYRELOC from GCC (https://sourceware.org/pipermail/gcc-patches/2022-June/596678.html).
Diffstat (limited to 'ld/testsuite/ld-i386')
-rw-r--r--ld/testsuite/ld-i386/protected1.d4
-rw-r--r--ld/testsuite/ld-i386/protected3.d2
-rw-r--r--ld/testsuite/ld-i386/protected6a.d4
3 files changed, 7 insertions, 3 deletions
diff --git a/ld/testsuite/ld-i386/protected1.d b/ld/testsuite/ld-i386/protected1.d
index a3cb5ce..531645b 100644
--- a/ld/testsuite/ld-i386/protected1.d
+++ b/ld/testsuite/ld-i386/protected1.d
@@ -1,3 +1,5 @@
#as: --32
#ld: -shared -melf_i386
-#error: .*relocation R_386_GOTOFF against protected function `foo' can not be used when making a shared object
+#readelf: -rW
+#...
+There are no relocations in this file.
diff --git a/ld/testsuite/ld-i386/protected3.d b/ld/testsuite/ld-i386/protected3.d
index c3a6888..77367c4 100644
--- a/ld/testsuite/ld-i386/protected3.d
+++ b/ld/testsuite/ld-i386/protected3.d
@@ -8,7 +8,7 @@
Disassembly of section .text:
0+[a-f0-9]+ <bar>:
-[ ]*[a-f0-9]+: 8b 81 [a-f0-9][a-f0-9] [a-f0-9][a-f0-9] ff ff mov -0x[a-f0-9]+\(%ecx\),%eax
+[ ]*[a-f0-9]+: 8d 81 00 00 00 00 lea 0x0\(%ecx\),%eax
[ ]*[a-f0-9]+: 8b 00 mov \(%eax\),%eax
[ ]*[a-f0-9]+: c3 ret
#pass
diff --git a/ld/testsuite/ld-i386/protected6a.d b/ld/testsuite/ld-i386/protected6a.d
index 7dc3504..4d38732 100644
--- a/ld/testsuite/ld-i386/protected6a.d
+++ b/ld/testsuite/ld-i386/protected6a.d
@@ -1,4 +1,6 @@
#source: protected6.s
#as: --32
#ld: -shared -melf_i386
-#error: .*relocation R_386_GOTOFF against protected data `foo' can not be used when making a shared object
+#readelf: -rW
+#...
+There are no relocations in this file.