Skip to content

Commit 4afc92e

Browse files
authored
[NFC][ELF] Remove pointless NEEDS_TLSGD_TO_IE (#171046)
NEEDS_TLSGD_TO_IE is only ever set when the symbol is preeptible, in which case addTpOffsetGotEntry will just add the symbol to the GOT and emit a symbolic tlsGotRel anyway, so there is no need to give it its own special case. As well as simplifying the code upstream, this is useful downstream for Morello, which doesn't really have a proper GD/IE-to-LE relaxation, and so for GD-to-IE can benefit from being able to use the optimisations addTpOffsetGotEntry has for non-preemptible symbols, rather than having to reimplement them here.
1 parent 6960b63 commit 4afc92e

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

lld/ELF/Relocations.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ unsigned RelocScan::handleTlsRelocation(RelExpr expr, RelType type,
12951295
// label, so TLSDESC=>IE will be categorized as R_RELAX_TLS_GD_TO_LE. We fix
12961296
// the categorization in RISCV::relocateAllosec->
12971297
if (sym.isPreemptible) {
1298-
sym.setFlags(NEEDS_TLSGD_TO_IE);
1298+
sym.setFlags(NEEDS_TLSIE);
12991299
sec->addReloc({ctx.target->adjustTlsExpr(type, R_RELAX_TLS_GD_TO_IE),
13001300
type, offset, addend, &sym});
13011301
} else {
@@ -1635,18 +1635,13 @@ void elf::postScanRelocations(Ctx &ctx) {
16351635
else
16361636
got->addConstant({R_ABS, ctx.target->tlsOffsetRel, offsetOff, 0, &sym});
16371637
}
1638-
if (flags & NEEDS_TLSGD_TO_IE) {
1639-
got->addEntry(sym);
1640-
ctx.mainPart->relaDyn->addSymbolReloc(ctx.target->tlsGotRel, *got,
1641-
sym.getGotOffset(ctx), sym);
1642-
}
16431638
if (flags & NEEDS_GOT_DTPREL) {
16441639
got->addEntry(sym);
16451640
got->addConstant(
16461641
{R_ABS, ctx.target->tlsOffsetRel, sym.getGotOffset(ctx), 0, &sym});
16471642
}
16481643

1649-
if ((flags & NEEDS_TLSIE) && !(flags & NEEDS_TLSGD_TO_IE))
1644+
if (flags & NEEDS_TLSIE)
16501645
addTpOffsetGotEntry(ctx, sym);
16511646
};
16521647

lld/ELF/Symbols.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum {
4848
NEEDS_COPY = 1 << 3,
4949
NEEDS_TLSDESC = 1 << 4,
5050
NEEDS_TLSGD = 1 << 5,
51-
NEEDS_TLSGD_TO_IE = 1 << 6,
51+
// 1 << 6 unused
5252
NEEDS_GOT_DTPREL = 1 << 7,
5353
NEEDS_TLSIE = 1 << 8,
5454
NEEDS_GOT_AUTH = 1 << 9,
@@ -352,7 +352,7 @@ class Symbol {
352352
bool needsDynReloc() const {
353353
return flags.load(std::memory_order_relaxed) &
354354
(NEEDS_COPY | NEEDS_GOT | NEEDS_PLT | NEEDS_TLSDESC | NEEDS_TLSGD |
355-
NEEDS_TLSGD_TO_IE | NEEDS_GOT_DTPREL | NEEDS_TLSIE);
355+
NEEDS_GOT_DTPREL | NEEDS_TLSIE);
356356
}
357357
void allocateAux(Ctx &ctx) {
358358
assert(auxIdx == 0);

0 commit comments

Comments
 (0)