diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 0d87f9a66071a..0f91c25da2d56 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -1061,8 +1061,8 @@ void MipsGotSection::build() { // for the TP-relative offset as we don't know how much other data will // be allocated before us in the static TLS block. if (s->isPreemptible || ctx.arg.shared) - ctx.mainPart->relaDyn->addReloc( - {ctx.target->tlsGotRel, this, offset, true, *s, 0, R_ABS}); + ctx.mainPart->relaDyn->addAddendOnlyRelocIfNonPreemptible( + ctx.target->tlsGotRel, *this, offset, *s, ctx.target->symbolicRel); } for (std::pair &p : got.dynTlsSymbols) { Symbol *s = p.first; @@ -1156,6 +1156,7 @@ void MipsGotSection::writeTo(uint8_t *buf) { // if we had to do this. writeUint(ctx, buf + ctx.arg.wordsize, (uint64_t)1 << (ctx.arg.wordsize * 8 - 1)); + ctx.target->relocateAlloc(*this, buf); for (const FileGot &g : gots) { auto write = [&](size_t i, const Symbol *s, int64_t a) { uint64_t va = a; @@ -1185,9 +1186,10 @@ void MipsGotSection::writeTo(uint8_t *buf) { write(p.second, p.first, 0); for (const std::pair &p : g.relocs) write(p.second, p.first, 0); - for (const std::pair &p : g.tls) - write(p.second, p.first, - p.first->isPreemptible || ctx.arg.shared ? 0 : -0x7000); + for (const std::pair &p : g.tls) { + if (!p.first->isPreemptible && !ctx.arg.shared) + write(p.second, p.first, -0x7000); + } for (const std::pair &p : g.dynTlsSymbols) { if (p.first == nullptr && !ctx.arg.shared) write(p.second, nullptr, 1); diff --git a/lld/test/ELF/mips-mgot.s b/lld/test/ELF/mips-mgot.s index 6978b5d9623b4..67bd5e6619f12 100644 --- a/lld/test/ELF/mips-mgot.s +++ b/lld/test/ELF/mips-mgot.s @@ -23,7 +23,7 @@ # CHECK: Contents of section .got: # CHECK-NEXT: 70000 00000000 80000000 [[FOO0]] [[FOO2]] -# CHECK-NEXT: 70010 00000000 00000004 00010000 00020000 +# CHECK-NEXT: 70010 00000000 00000000 00010000 00020000 # CHECK-NEXT: 70020 00030000 00040000 00050000 00060000 # CHECK-NEXT: 70030 00000000 00000000 00000000 00000000 # CHECK-NEXT: 70040 00000000 00000000 00000000 diff --git a/lld/test/ELF/mips-tls-64.s b/lld/test/ELF/mips-tls-64.s index 3976b50274be4..8a00b93c77e2f 100644 --- a/lld/test/ELF/mips-tls-64.s +++ b/lld/test/ELF/mips-tls-64.s @@ -75,7 +75,7 @@ # DIS-SO: Contents of section .got: # DIS-SO-NEXT: 30000 00000000 00000000 80000000 00000000 # DIS-SO-NEXT: 30010 00000000 00000000 00000000 00000000 -# DIS-SO-NEXT: 30020 00000000 00000004 00000000 00000000 +# DIS-SO-NEXT: 30020 00000000 00000000 00000000 00000000 # DIS-SO-NEXT: 30030 00000000 00000000 00000000 00000000 # DIS-SO-NEXT: 30040 00000000 00000000 00000000 00000000 # DIS-SO-NEXT: 30050 00000000 00000000 diff --git a/lld/test/ELF/mips-tls.s b/lld/test/ELF/mips-tls.s index b98f3bb53d18d..804b29cf724d9 100644 --- a/lld/test/ELF/mips-tls.s +++ b/lld/test/ELF/mips-tls.s @@ -71,7 +71,7 @@ # DIS-SO: Contents of section .got: # DIS-SO-NEXT: 30000 00000000 80000000 00000000 00000000 -# DIS-SO-NEXT: 30010 00000004 00000000 00000000 00000000 +# DIS-SO-NEXT: 30010 00000000 00000000 00000000 00000000 # DIS-SO-NEXT: 30020 00000000 00000000 00000000 # SO: Relocations [