Skip to content

Commit 32400cb

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.5
1 parent dd36a69 commit 32400cb

File tree

5 files changed

+12
-19
lines changed

5 files changed

+12
-19
lines changed

lld/ELF/SyntheticSections.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,9 +1065,8 @@ void MipsGotSection::build() {
10651065
// for the TP-relative offset as we don't know how much other data will
10661066
// be allocated before us in the static TLS block.
10671067
if (s->isPreemptible || ctx.arg.shared)
1068-
ctx.mainPart->relaDyn->addReloc(
1069-
{ctx.target->tlsGotRel, this, offset,
1070-
DynamicReloc::AgainstSymbolWithTargetVA, *s, 0, R_ABS});
1068+
ctx.mainPart->relaDyn->addAddendOnlyRelocIfNonPreemptible(
1069+
ctx.target->tlsGotRel, *this, offset, *s, ctx.target->symbolicRel);
10711070
}
10721071
for (std::pair<Symbol *, size_t> &p : got.dynTlsSymbols) {
10731072
Symbol *s = p.first;
@@ -1160,6 +1159,7 @@ void MipsGotSection::writeTo(uint8_t *buf) {
11601159
// if we had to do this.
11611160
writeUint(ctx, buf + ctx.arg.wordsize,
11621161
(uint64_t)1 << (ctx.arg.wordsize * 8 - 1));
1162+
ctx.target->relocateAlloc(*this, buf);
11631163
for (const FileGot &g : gots) {
11641164
auto write = [&](size_t i, const Symbol *s, int64_t a) {
11651165
uint64_t va = a;
@@ -1189,9 +1189,10 @@ void MipsGotSection::writeTo(uint8_t *buf) {
11891189
write(p.second, p.first, 0);
11901190
for (const std::pair<Symbol *, size_t> &p : g.relocs)
11911191
write(p.second, p.first, 0);
1192-
for (const std::pair<Symbol *, size_t> &p : g.tls)
1193-
write(p.second, p.first,
1194-
p.first->isPreemptible || ctx.arg.shared ? 0 : -0x7000);
1192+
for (const std::pair<Symbol *, size_t> &p : g.tls) {
1193+
if (!p.first->isPreemptible && !ctx.arg.shared)
1194+
write(p.second, p.first, -0x7000);
1195+
}
11951196
for (const std::pair<Symbol *, size_t> &p : g.dynTlsSymbols) {
11961197
if (p.first == nullptr && !ctx.arg.shared)
11971198
write(p.second, nullptr, 1);
@@ -1653,8 +1654,7 @@ int64_t DynamicReloc::computeAddend(Ctx &ctx) const {
16531654
case AgainstSymbol:
16541655
assert(sym != nullptr);
16551656
return addend;
1656-
case AddendOnlyWithTargetVA:
1657-
case AgainstSymbolWithTargetVA: {
1657+
case AddendOnlyWithTargetVA: {
16581658
uint64_t ca = inputSec->getRelocTargetVA(
16591659
ctx, Relocation{expr, type, 0, addend, sym}, getOffset());
16601660
return ctx.arg.is64 ? ca : SignExtend64<32>(ca);

lld/ELF/SyntheticSections.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,6 @@ class DynamicReloc {
429429
/// The resulting dynamic relocation references symbol #sym from the dynamic
430430
/// symbol table and uses #addend as the value of computeAddend(ctx).
431431
AgainstSymbol,
432-
/// The resulting dynamic relocation references symbol #sym from the dynamic
433-
/// symbol table and uses InputSection::getRelocTargetVA() + #addend for the
434-
/// final addend. It can be used for relocations that write the symbol VA as
435-
// the addend (e.g. R_MIPS_TLS_TPREL64) but still reference the symbol.
436-
AgainstSymbolWithTargetVA,
437432
/// This is used by the MIPS multi-GOT implementation. It relocates
438433
/// addresses of 64kb pages that lie inside the output section.
439434
MipsMultiGotPage,
@@ -460,9 +455,7 @@ class DynamicReloc {
460455

461456
uint64_t getOffset() const;
462457
uint32_t getSymIndex(SymbolTableBaseSection *symTab) const;
463-
bool needsDynSymIndex() const {
464-
return kind == AgainstSymbol || kind == AgainstSymbolWithTargetVA;
465-
}
458+
bool needsDynSymIndex() const { return kind == AgainstSymbol; }
466459

467460
/// Computes the addend of the dynamic relocation. Note that this is not the
468461
/// same as the #addend member variable as it may also include the symbol

lld/test/ELF/mips-mgot.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# CHECK: Contents of section .got:
2525
# CHECK-NEXT: 70000 00000000 80000000 [[FOO0]] [[FOO2]]
26-
# CHECK-NEXT: 70010 00000000 00000004 00010000 00020000
26+
# CHECK-NEXT: 70010 00000000 00000000 00010000 00020000
2727
# CHECK-NEXT: 70020 00030000 00040000 00050000 00060000
2828
# CHECK-NEXT: 70030 00000000 00000000 00000000 00000000
2929
# CHECK-NEXT: 70040 00000000 00000000 00000000

lld/test/ELF/mips-tls-64.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
# DIS-SO: Contents of section .got:
7676
# DIS-SO-NEXT: 30000 00000000 00000000 80000000 00000000
7777
# DIS-SO-NEXT: 30010 00000000 00000000 00000000 00000000
78-
# DIS-SO-NEXT: 30020 00000000 00000004 00000000 00000000
78+
# DIS-SO-NEXT: 30020 00000000 00000000 00000000 00000000
7979
# DIS-SO-NEXT: 30030 00000000 00000000 00000000 00000000
8080
# DIS-SO-NEXT: 30040 00000000 00000000 00000000 00000000
8181
# DIS-SO-NEXT: 30050 00000000 00000000

lld/test/ELF/mips-tls.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
# DIS-SO: Contents of section .got:
7373
# DIS-SO-NEXT: 30000 00000000 80000000 00000000 00000000
74-
# DIS-SO-NEXT: 30010 00000004 00000000 00000000 00000000
74+
# DIS-SO-NEXT: 30010 00000000 00000000 00000000 00000000
7575
# DIS-SO-NEXT: 30020 00000000 00000000 00000000
7676

7777
# SO: Relocations [

0 commit comments

Comments
 (0)