2 # RUN: split-file %s %t
3 # RUN: llvm-mc --triple=ppc64le %t/a.s --filetype=obj -o %t/a.o
4 # RUN: llvm-mc --triple=ppc64le %t/b.s --filetype=obj -o %t/b.o
5 # RUN: llvm-mc --triple=ppc64le %t/tga.s --filetype=obj -o %t/tga.o
7 ## User code can call __tls_get_addr by specifying the tls_index parameter.
8 ## We need to allow R_PPC64_REL24/R_PPC64_REL24_NOTOC referencing __tls_get_addr
9 ## without a pairing R_PPC64_TLSGD/R_PPC64_TLSLD.
10 # RUN: ld.lld --shared --fatal-warnings %t/b.o -o /dev/null
12 ## Warn missing R_PPC64_TLSGD/R_PPC64_TLSLD.
13 # RUN: ld.lld --shared %t/a.o -o %t.so 2>&1 | FileCheck %s --check-prefix=WARN
14 # RUN: llvm-objdump -d --no-leading-addr %t.so | FileCheck %s --check-prefix=DIS
16 # RUN: ld.lld %t/a.o %t/tga.o -o %t2 2>&1 | FileCheck %s --check-prefix=WARN
17 # RUN: llvm-readelf -x .got %t2 | FileCheck %s --check-prefix=HEX
18 # RUN: llvm-objdump -d --no-leading-addr %t2 | FileCheck %s --check-prefix=DIS
20 # WARN: warning: {{.*}}.o: disable TLS relaxation due to R_PPC64_GOT_TLS* relocations without R_PPC64_TLSGD/R_PPC64_TLSLD relocations
22 ## .got+0: x is local - relaxed to LE - its DTPMOD/DTPREL slots are link-time constants.
23 ## DTPMOD is 1. DTPREL is st_value-0x8000 = -0x8000.
24 ## .got+16: DTPMOD/DTPREL for _TLS_MODULE_BASE_ is 1 and 0, respectively.
25 ## .got+32: TPOFFSET for x = st_value-0x7000
26 # HEX: section '.got':
27 # HEX-NEXT: [[#%x,IGNORE:]] 50820210 00000000 01000000 00000000
28 # HEX-NEXT: [[#%x,IGNORE:]] 00000000 00000000 01000000 00000000
29 # HEX-NEXT: [[#%x,IGNORE:]] 0080ffff ffffffff 0090ffff ffffffff
31 ## .TOC.-32768 = (.got+0x8000)-32768 = .got
32 # DIS-LABEL: <GeneralDynamic>:
33 # DIS-NEXT: addis 3, 2, 0
34 # DIS-NEXT: addi 3, 3, -32744
35 # DIS-NEXT: bl [[#%x,TGA:]]
36 # DIS-LABEL: <GeneralDynamic_NOTOC>:
37 # DIS-NEXT: addis 3, 2, 0
38 # DIS-NEXT: addi 3, 3, -32744
39 # DIS-NEXT: bl [[#TGA]]
41 ## LocalDynamic references _TLS_MODULE_BASE_.
42 ## .TOC.-32752 = (.got+0x8000)-32752 = .got+16
43 # DIS-LABEL: <LocalDynamic>:
44 # DIS-NEXT: addis 3, 2, 0
45 # DIS-NEXT: addi 3, 3, -32760
46 # DIS-NEXT: bl [[#TGA]]
47 # DIS-LABEL: <LocalDynamic_NOTOC>:
48 # DIS-NEXT: addis 3, 2, 0
49 # DIS-NEXT: addi 3, 3, -32760
50 # DIS-NEXT: bl [[#TGA]]
52 ## Technically we don't have to disable IE to LE relaxation,
53 ## but disabling it for implementation simplicity does not hurt.
54 # DIS-LABEL: <InitialExec>:
55 # DIS-NEXT: addis 3, 2, 0
56 # DIS-NEXT: ld 3, -32728(3)
57 # DIS-NEXT: add 3, 3, 13
61 addis 3, 2, x@got@tlsgd@ha
62 addi 3, 3, x@got@tlsgd@
l
67 addis 3, 2, x@got@tlsgd@ha
68 addi 3, 3, x@got@tlsgd@
l
69 bl __tls_get_addr@notoc
73 addis 3, 2, x@got@tlsld@ha
74 addi 3, 3, x@got@tlsld@
l
79 addis 3, 2, x@got@tlsld@ha
80 addi 3, 3, x@got@tlsld@
l
81 bl __tls_get_addr@notoc
85 addis 3, 2, x@got@tprel@ha
86 ld 3, x@got@tprel@
l(3)
92 .section .tbss,"awT",@nobits
104 .globl __tls_get_addr