<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - lld unable to link compiler-rt on aarch64 (hwasan)"
href="https://bugs.llvm.org/show_bug.cgi?id=35929">35929</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>lld unable to link compiler-rt on aarch64 (hwasan)
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>ELF
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>peter.smith@linaro.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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
(<a href="https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html">https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html</a>)
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>