[llvm-bugs] [Bug 35929] New: lld unable to link compiler-rt on aarch64 (hwasan)
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jan 12 08:42:48 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=35929
Bug ID: 35929
Summary: lld unable to link compiler-rt on aarch64 (hwasan)
Product: lld
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: ELF
Assignee: unassignedbugs at nondot.org
Reporter: peter.smith at linaro.org
CC: llvm-bugs at lists.llvm.org
It is currently not possible to link the sanitizers on AArch64 using lld due to
relocations in the text section that can't be resolved with -znotext. These
relocations come from an AArch64 only sanitizer hwasan
(https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html)
because it compiles with -fPIE but links --shared.
The errors are caused by taking the address of preemptible code symbols that
are compiled into non-got generating pc-relative references.
An example of such a reference that can be reproduced on x86, Arm and AArch64
is:
typedef int fptr(void);
int func(void) {
return 0;
}
fptr* func2(void) {
return &func;
}
clang t.c --shared -fPIE -ffunction-sections -o t.so -fuse-ld=lld -Wl,-znotext
ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol func;
recompile with -fPIC
It just so happens that ld.bfd and ld.gold do not error when this occurs and
just resolve the relocation statically.
I think that this is definitely an error that lld should diagnose and I'm I'm
going to create a bug on hwasan to let them know that they are incompatible
with lld.
The interesting question is whether lld should allow this with -znotext. It
isn't possible (on AArch64 and Arm at least) to propagate the relocation into
.rel.dyn. Options include resolving the relocation statically as with bfd and
gold (perhaps only when a command line option is used), or indirecting via the
GOT.
I've marked as an enhancement rather than a bug as hwasan seems to using -fPIE
to reduce the number of relocations, at risk of possible symbol preemption
errors.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180112/b9f8fabf/attachment.html>
More information about the llvm-bugs
mailing list