2 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
3 # RUN: echo '.tbss; .globl b, c; b: .zero 4; c:' | llvm-mc -filetype=obj -triple=powerpc64le - -o %t1.o
4 # RUN: ld.lld -shared -soname=t1.so %t1.o -o %t1.so
6 # RUN: ld.lld -shared %t.o %t1.o -o %t.so
7 # RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=GD-REL %s
8 # RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck --check-prefix=GD %s
10 # RUN: ld.lld %t.o %t1.o -o %t
11 # RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s
12 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s
14 # RUN: ld.lld %t.o %t1.so -o %t
15 # RUN: llvm-readobj -r %t | FileCheck --check-prefix=IE-REL %s
16 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=IE %s
19 # GD-REL-NEXT: 0x20550 R_PPC64_DTPMOD64 a 0x0
20 # GD-REL-NEXT: 0x20558 R_PPC64_DTPREL64 a 0x0
21 # GD-REL-NEXT: 0x20560 R_PPC64_DTPMOD64 b 0x0
22 # GD-REL-NEXT: 0x20568 R_PPC64_DTPREL64 b 0x0
23 # GD-REL-NEXT: 0x20570 R_PPC64_DTPMOD64 c 0x0
24 # GD-REL-NEXT: 0x20578 R_PPC64_DTPREL64 c 0x0
27 ## Start with .got[1] as .got[0] is the .TOC.
28 ## &DTPMOD(a) - .TOC. = &.got[1] - (.got+0x8000) = -32760
30 # GD-NEXT: addi 3, 3, -32760
32 # GD-NEXT: ld 2, 24(1)
34 ## &DTPMOD(b) - .TOC. = &.got[3] - (.got+0x8000) = -32744
35 # GD-NEXT: addis 3, 2, 0
36 # GD-NEXT: addi 3, 3, -32744
38 # GD-NEXT: ld 2, 24(1)
40 ## &DTPMOD(b) - .TOC. = &.got[5] - (.got+0x8000) = -32728
41 # GD-NEXT: li 3, -32728
43 # GD-NEXT: ld 2, 24(1)
45 # NOREL: no relocations
47 ## a@tprel = st_value(a)-0x7000 = -28664
49 # LE-NEXT: addis 3, 13, 0
51 # LE-NEXT: addi 3, 3, -28664
52 ## b@tprel = st_value(b)-0x7000 = -28660
54 # LE-NEXT: addis 3, 13, 0
56 # LE-NEXT: addi 3, 3, -28660
57 ## c@tprel = st_value(c)-0x7000 = -28656
58 # LE-NEXT: addis 3, 13, 0
60 # LE-NEXT: addi 3, 3, -28656
63 # IE-REL-NEXT: 0x10020420 R_PPC64_TPREL64 b 0x0
64 # IE-REL-NEXT: 0x10020428 R_PPC64_TPREL64 c 0x0
67 ## a is relaxed to use LE.
68 ## a@tprel = st_value(a)-0x7000 = -28664
70 # IE-NEXT: addis 3, 13, 0
72 # IE-NEXT: addi 3, 3, -28664
73 ## &DTPMOD(b) - .TOC. = &.got[1] - (.got+0x8000) = -32760
74 # IE-NEXT: addis 3, 2, 0
75 # IE-NEXT: ld 3, -32760(3)
77 # IE-NEXT: add 3, 3, 13
78 ## &DTPMOD(c) - .TOC. = &.got[2] - (.got+0x8000) = -32752
79 ## r0 is wrong. R_PPC64_GOT_TLS16 cannot be relaxed to IE but the behavior is
80 ## consistent with ld.bfd
81 # IE-NEXT: ld 3, -32752(0)
83 # IE-NEXT: add 3, 3, 13
85 addis 3, 2, a@got@tlsgd@ha
86 addi 3, 3, a@got@tlsgd@
l
87 bl __tls_get_addr
(a@tlsgd
)
90 addis 3, 2, b@got@tlsgd@ha
91 addi 3, 3, b@got@tlsgd@
l
92 bl __tls_get_addr
(b@tlsgd
)
95 addi 3, 0, c@got@tlsgd
96 bl __tls_get_addr
(c@tlsgd
)