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
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
38
49@gd = thread_local global i32 0
510@ld = internal thread_local global i32 0
914; CHECK-LABEL: get_gd:
1015; X86: leal gd@TLSGD(%ebx), %eax
1116; X86: calll *___tls_get_addr@GOT(%ebx)
17+ ; X86-PLT: calll ___tls_get_addr@PLT
1218
1319; X64: leaq gd@TLSGD(%rip), %rdi
1420; X64: callq *__tls_get_addr@GOTPCREL(%rip)
21+ ; X64-PLT: callq __tls_get_addr@PLT
1522 ret i32* @gd
1623}
1724
@@ -20,9 +27,11 @@ define i32* @get_ld() {
2027; CHECK-LABEL: get_ld:
2128; X86: leal ld@TLSLDM(%ebx), %eax
2229; X86: calll *___tls_get_addr@GOT(%ebx)
30+ ; X86-PLT: calll ___tls_get_addr@PLT
2331
2432; X64: leaq ld@TLSLD(%rip), %rdi
2533; X64: callq *__tls_get_addr@GOTPCREL(%rip)
34+ ; X64-PLT: callq __tls_get_addr@PLT
2635 ret i32* @ld
2736}
2837
0 commit comments