Skip to content

Commit 2679e8b

Browse files
committed
[X86] Revert -fno-plt __tls_get_addr workaround for old GNU ld
ENABLE_X86_RELAX_RELOCATIONS has defaulted to on in 2020. This workaround is not exercised for a long time.
1 parent 83cec14 commit 2679e8b

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

llvm/lib/Target/X86/X86MCInstLower.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,14 +1024,7 @@ void X86AsmPrinter::LowerTlsAddr(X86MCInstLower &MCInstLowering,
10241024

10251025
const MCSymbolRefExpr *Sym = MCSymbolRefExpr::create(
10261026
MCInstLowering.GetSymbolFromOperand(MI.getOperand(3)), SRVK, Ctx);
1027-
1028-
// As of binutils 2.32, ld has a bogus TLS relaxation error when the GD/LD
1029-
// code sequence using R_X86_64_GOTPCREL (instead of R_X86_64_GOTPCRELX) is
1030-
// attempted to be relaxed to IE/LE (binutils PR24784). Work around the bug by
1031-
// only using GOT when GOTPCRELX is enabled.
1032-
// TODO Delete the workaround when GOTPCRELX becomes commonplace.
1033-
bool UseGot = MMI->getModule()->getRtLibUseGOT() &&
1034-
Ctx.getAsmInfo()->canRelaxRelocations();
1027+
const bool UseGot = MMI->getModule()->getRtLibUseGOT();
10351028

10361029
if (Is64Bits) {
10371030
bool NeedsPadding = SRVK == MCSymbolRefExpr::VK_TLSGD;

llvm/test/CodeGen/X86/tls-no-plt.ll

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
; RUN: llc < %s -mtriple=i386-linux-musl -relocation-model=pic -relax-elf-relocations=true | FileCheck --check-prefixes=CHECK,X86 %s
2-
; RUN: llc < %s -mtriple=x86_64-linux-musl -relocation-model=pic -relax-elf-relocations=true | FileCheck --check-prefixes=CHECK,X64 %s
3-
4-
;; If GOTPCRELX is disabled, don't use GOT for __tls_get_addr to work around
5-
;; a ld.bfd bug (binutils PR24784).
6-
; RUN: llc < %s -mtriple=i386-linux-musl -relocation-model=pic | FileCheck --check-prefixes=CHECK,X86-PLT %s
7-
; RUN: llc < %s -mtriple=x86_64-linux-musl -relocation-model=pic | FileCheck --check-prefixes=CHECK,X64-PLT %s
1+
; RUN: llc < %s -mtriple=i386-linux-musl -relocation-model=pic | FileCheck --check-prefixes=CHECK,X86 %s
2+
; RUN: llc < %s -mtriple=x86_64-linux-musl -relocation-model=pic | FileCheck --check-prefixes=CHECK,X64 %s
83

94
@gd = thread_local global i32 0
105
@ld = internal thread_local global i32 0
@@ -14,11 +9,9 @@ entry:
149
; CHECK-LABEL: get_gd:
1510
; X86: leal gd@TLSGD(%ebx), %eax
1611
; X86: calll *___tls_get_addr@GOT(%ebx)
17-
; X86-PLT: calll ___tls_get_addr@PLT
1812

1913
; X64: leaq gd@TLSGD(%rip), %rdi
2014
; X64: callq *__tls_get_addr@GOTPCREL(%rip)
21-
; X64-PLT: callq __tls_get_addr@PLT
2215
ret ptr @gd
2316
}
2417

@@ -27,11 +20,9 @@ define ptr @get_ld() {
2720
; CHECK-LABEL: get_ld:
2821
; X86: leal ld@TLSLDM(%ebx), %eax
2922
; X86: calll *___tls_get_addr@GOT(%ebx)
30-
; X86-PLT: calll ___tls_get_addr@PLT
3123

3224
; X64: leaq ld@TLSLD(%rip), %rdi
3325
; X64: callq *__tls_get_addr@GOTPCREL(%rip)
34-
; X64-PLT: callq __tls_get_addr@PLT
3526
ret ptr @ld
3627
}
3728

0 commit comments

Comments
 (0)