[llvm-bugs] [Bug 42506] New: __efistub_stext_offset=stext-_text; ... _text=.; => isAbsolute() can be incorrect if a symbol in the expression is defined after the expression
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jul 4 01:14:22 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42506
Bug ID: 42506
Summary: __efistub_stext_offset=stext-_text;... _text=.; =>
isAbsolute() can be incorrect if a symbol in the
expression is defined after the expression
Product: lld
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: ELF
Assignee: unassignedbugs at nondot.org
Reporter: i at maskray.me
CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org
Originally reported at https://github.com/ClangBuiltLinux/linux/issues/561.
# 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
>>> defined in a.x:1
>>> referenced by a.o:(.text+0x4)
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
--
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/20190704/e8e5a39d/attachment.html>
More information about the llvm-bugs
mailing list