<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 - Support TLS relocations referencing non STT_TLS symbols (e.g. STT_SECTION or STT_NOTYPE)"
href="https://bugs.llvm.org/show_bug.cgi?id=45600">45600</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Support TLS relocations referencing non STT_TLS symbols (e.g. STT_SECTION or STT_NOTYPE)
</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, smithp352@googlemail.com
</td>
</tr></table>
<p>
<div>
<pre>Two weeks ago I was trying deleting a hack in MC (integrated assembler)
<a href="https://reviews.llvm.org/D77361">https://reviews.llvm.org/D77361</a> and I noticed I can't do that because lld does
not support a TLS relocation referencing a non-TLS symbol.
Related gABI discussion:
<a href="https://groups.google.com/forum/#!searchin/generic-abi/TLS%7Csort:date/generic-abi/dJ4_Y78aQ2M/WKggp9fKCgAJ">https://groups.google.com/forum/#!searchin/generic-abi/TLS%7Csort:date/generic-abi/dJ4_Y78aQ2M/WKggp9fKCgAJ</a>
# a.o
movl %fs:.tdata+4@tpoff, %eax
movl %fs:a@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);</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>