diff options
| author | Fangrui Song <maskray@google.com> | 2020-01-17 11:50:00 -0800 |
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2020-01-17 18:54:52 -0800 |
| commit | 9aacec8331d9bc1f80046e5954be1f5e0e0acd42 (patch) | |
| tree | 5f810e17c815538599c93bb87ca955462644a287 /lld/test | |
| parent | b28326516ca3ad9d51688532e944f491ce8b7908 (diff) | |
| download | bcm5719-llvm-9aacec8331d9bc1f80046e5954be1f5e0e0acd42.tar.gz bcm5719-llvm-9aacec8331d9bc1f80046e5954be1f5e0e0acd42.zip | |
[ELF] Allow R_PLT_PC (R_PC) to a hidden undefined weak symbol
This essentially reverts b841e119d77ed0502e3a2e710f26a899bef28b3c.
Such code construct can be used in the following way:
// glibc/stdlib/exit.c
// clang -fuse-ld=lld => succeeded
// clang -fuse-ld=lld -fpie -pie => relocation R_PLT_PC cannot refer to absolute symbol
__attribute__((weak, visibility("hidden"))) extern void __call_tls_dtors();
void __run_exit_handlers() {
if (__call_tls_dtors)
__call_tls_dtors();
}
Since we allow R_PLT_PC in -no-pie mode, it makes sense to allow it in
-pie mode as well.
Reviewed By: pcc
Differential Revision: https://reviews.llvm.org/D72943
(cherry picked from commit 6ab89c3c5df8b679e6ee240a13356309c048fc71)
Diffstat (limited to 'lld/test')
| -rw-r--r-- | lld/test/ELF/weak-undef-hidden.s | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lld/test/ELF/weak-undef-hidden.s b/lld/test/ELF/weak-undef-hidden.s index 632e051ffdc..2baad5738c3 100644 --- a/lld/test/ELF/weak-undef-hidden.s +++ b/lld/test/ELF/weak-undef-hidden.s @@ -2,6 +2,11 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o // RUN: ld.lld %t.o -o %t.so -shared // RUN: llvm-readobj -r -S --section-data %t.so | FileCheck %s +// RUN: ld.lld %t.o -o %t -pie +// RUN: llvm-readobj -r -S --section-data %t | FileCheck %s + +/// This is usually guarded with a comparison. Don't report an error. +call g .data .weak g |

