<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 - __efistub_stext_offset=stext-_text;... _text=.; => isAbsolute() can be incorrect if a symbol in the expression is defined after the expression"
href="https://bugs.llvm.org/show_bug.cgi?id=42506">42506</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>__efistub_stext_offset=stext-_text;... _text=.; => isAbsolute() can be incorrect if a symbol in the expression is defined after the expression
</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>i@maskray.me
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
</td>
</tr></table>
<p>
<div>
<pre>Originally reported at <a href="https://github.com/ClangBuiltLinux/linux/issues/561">https://github.com/ClangBuiltLinux/linux/issues/561</a>.
# a.s: llvm-mc -filetype=obj -triple=aarch64 a.s -o a.o
.globl stext
# R_AARCH64_ABS32
ldr w21, =__efistub_stext_offset
# a.x
stext:
__efistub_stext_offset = stext - _text;
# In Linux kernel, this has been worked around by changing to
__efistub_stext_offset = ABSOLUTE(stext - _text;)
SECTIONS {
.text : {
_text = .; # Note, _text is evaluated after __efistub_stext_offset
*(.text)
}
}
% llvm-mc -filetype=obj -triple=aarch64 a.s -o a.o
% ld.lld -shared a.o a.x
ld.lld: error: can't create dynamic relocation R_AARCH64_ABS32 against symbol:
__efistub_stext_offset in readonly segment; recompile object files with -fPIC
or pass '-Wl,-z,notext' to allow text relocations in the output
<span class="quote">>>> defined in a.x:1
>>> referenced by a.o:(.text+0x4)</span >
Call tree:
link<ELF64LE>(Args);
Script->declareSymbols();
1) insert __efistub_stext_offset as an absolute Defined
2) insert stext. It already exists as a non-absolute (section relative)
Defined.
3) insert _text as an absolute Defined.
writeResult<ELFT>()
Writer<ELFT>().run();
Script->processSectionCommands();
addSymbol(Cmd); // this evaluates `stext - _text`: nonabsolute -
absolute = nonabsolute
__efistub_stext_offset is inserted as a non-absolute Defined
finalizeSections();
forEachRelSec(scanRelocations<ELFT>);
processRelocAux
An error is issued because in a -pie/-shared link, an absolute
relocation R_AARCH64_ABS32 cannot reference a non-absolute symbol</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>