Index: lld/ELF/Relocations.cpp =================================================================== --- lld/ELF/Relocations.cpp +++ lld/ELF/Relocations.cpp @@ -96,23 +96,9 @@ InputSectionBase &C, typename ELFT::uint Offset, int64_t Addend, RelExpr Expr) { if (isRelExprOneOf(Expr)) { - if (Got->addTlsIndex() && (Config->Pic || Config->EMachine == EM_ARM)) { - uint64_t Off = Got->getTlsIndexOff(); - - if (!Body.isPreemptible() && !Config->Pic && Config->EMachine == EM_ARM) { - // The Dynamic TLS Module Index Relocation can be statically resolved to - // 1 if we know that we are linking an executable. For ARM we resolve - // the relocation when writing the Got. MIPS has a custom Got - // implementation that writes the Module index in directly. Adding this - // relocation is an intricate way of setting it to 1, which needs - // improving. - Got->Relocations.push_back( - {R_ABS, Target->TlsModuleIndexRel, Off, 0, &Body}); - } else { - In::RelaDyn->addReloc( - {Target->TlsModuleIndexRel, Got, Off, false, nullptr, 0}); - } - } + if (Got->addTlsIndex() && (Config->Pic || Config->EMachine == EM_ARM)) + In::RelaDyn->addReloc({Target->TlsModuleIndexRel, Got, + Got->getTlsIndexOff(), false, nullptr, 0}); C.Relocations.push_back({Expr, Type, Offset, Addend, &Body}); return 1; @@ -122,14 +108,8 @@ if (Got->addDynTlsEntry(Body) && (Body.isPreemptible() || Config->EMachine == EM_ARM)) { uint64_t Off = Got->getGlobalDynOffset(Body); - - if (!Body.isPreemptible() && !Config->Pic && Config->EMachine == EM_ARM) { - Got->Relocations.push_back( - {R_ABS, Target->TlsModuleIndexRel, Off, 0, &Body}); - } else { - In::RelaDyn->addReloc( - {Target->TlsModuleIndexRel, Got, Off, false, &Body, 0}); - } + In::RelaDyn->addReloc( + {Target->TlsModuleIndexRel, Got, Off, false, &Body, 0}); if (Body.isPreemptible()) In::RelaDyn->addReloc({Target->TlsOffsetRel, Got, Index: lld/ELF/Target.cpp =================================================================== --- lld/ELF/Target.cpp +++ lld/ELF/Target.cpp @@ -1842,9 +1842,6 @@ case R_ARM_TLS_TPOFF32: write32le(Loc, Val); break; - case R_ARM_TLS_DTPMOD32: - write32le(Loc, 1); - break; case R_ARM_PREL31: checkInt<31>(Loc, Val, Type); write32le(Loc, (read32le(Loc) & 0x80000000) | (Val & ~0x80000000)); Index: lld/test/ELF/arm-tls-norelax-gd-le.s =================================================================== --- lld/test/ELF/arm-tls-norelax-gd-le.s +++ lld/test/ELF/arm-tls-norelax-gd-le.s @@ -2,7 +2,7 @@ // RUN: ld.lld %t1 --shared -o %t1.so // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi // RUN: ld.lld %t1.so %t.o -o %t -// RUN: llvm-objdump -s %t | FileCheck %s +// RUN: llvm-readobj -dyn-relocations %t | FileCheck %s // REQUIRES: arm // This tls global-dynamic sequence is with respect to a non-preemptible @@ -31,7 +31,5 @@ .space 4 .type x, %object -// CHECK: Contents of section .got: -// Module index is always 1 for executable -// CHECK-NEXT: 13060 01000000 00000000 - +// CHECK: Dynamic Relocations { +// CHECK-NEXT: 0x13078 R_ARM_TLS_DTPMOD32 - 0x0 Index: lld/test/ELF/arm-tls-norelax-ld-le.s =================================================================== --- lld/test/ELF/arm-tls-norelax-ld-le.s +++ lld/test/ELF/arm-tls-norelax-ld-le.s @@ -2,7 +2,7 @@ // RUN: ld.lld %t1 --shared -o %t1.so // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi // RUN: ld.lld %t1.so %t.o -o %t -// RUN: llvm-objdump -s %t | FileCheck %s +// RUN: llvm-readobj -dyn-relocations %t | FileCheck %s // REQUIRES: arm .global __tls_get_addr @@ -31,5 +31,5 @@ x: .word 10 -// CHECK: Contents of section .got: -// CHECK-NEXT: 13064 01000000 00000000 +// CHECK: Dynamic Relocations { +// CHECK-NEXT: 0x1307C R_ARM_TLS_DTPMOD32 - 0x0