[llvm-bugs] [Bug 45600] New: Support TLS relocations referencing non STT_TLS symbols (e.g. STT_SECTION or STT_NOTYPE)
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Apr 18 13:26:01 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45600
Bug ID: 45600
Summary: Support TLS relocations referencing non STT_TLS
symbols (e.g. STT_SECTION or STT_NOTYPE)
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, smithp352 at googlemail.com
Two weeks ago I was trying deleting a hack in MC (integrated assembler)
https://reviews.llvm.org/D77361 and I noticed I can't do that because lld does
not support a TLS relocation referencing a non-TLS symbol.
Related gABI discussion:
https://groups.google.com/forum/#!searchin/generic-abi/TLS%7Csort:date/generic-abi/dJ4_Y78aQ2M/WKggp9fKCgAJ
# a.o
movl %fs:.tdata+4 at tpoff, %eax
movl %fs:a at tpoff, %eax
.section .tdata,"awT"
.long 0
a:
.long 0
# lld
movl %fs:2105868, %eax # a TLS relocation referencing a STT_SECTION
movl %fs:-4, %eax
# gold and GNU ld
movl %fs:-4, %eax
movl %fs:-4, %eax
Supporting this requires to fix
// Symbols.cpp:getSymVA
if (d.isTls() && !config->relocatable) {
// Use the address of the TLS segment's first section rather than the
// segment's address, because segment addresses aren't initialized until
// after sections are finalized. (e.g. Measuring the size of .rela.dyn
// for Android relocation packing requires knowing TLS symbol addresses
// during section finalization.)
if (!Out::tlsPhdr || !Out::tlsPhdr->firstSec)
fatal(toString(d.file) +
" has an STT_TLS symbol but doesn't have an SHF_TLS section");
return va - Out::tlsPhdr->firstSec->addr;
and
// Relocations.cpp isStaticLinkTimeConstant
// For the target and the relocation, we want to know if they are
// absolute or relative.
bool absVal = isAbsoluteValue(sym); // STT_SECTION/STT_NOTYPE can be used as
TLS as well
bool relE = isRelExpr(e);
if (absVal && !relE)
return true;
if (!absVal && relE)
return true;
if (!absVal && !relE)
return target->usesOnlyLowPageBits(type);
--
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/20200418/e0ac14b8/attachment.html>
More information about the llvm-bugs
mailing list