2 # RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o
3 # RUN: echo '.tbss; .globl b, c; b: .zero 4; c:' | llvm-mc -filetype=obj -triple=powerpc - -o %t1.o
4 # RUN: ld.lld -shared -soname=t1.so %t1.o -o %t1.so
5 # RUN: echo '.globl __tls_get_addr; __tls_get_addr:' | llvm-mc -filetype=obj -triple=powerpc - -o %tga.o
7 # RUN: ld.lld -shared %t.o %t1.o -o %t.so
8 # RUN: llvm-readobj -d %t.so | FileCheck --check-prefix=GD-DYN %s
9 # RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=GD-REL %s
10 # RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck --check-prefix=GD %s
12 # RUN: ld.lld %t.o %t1.o %tga.o -o %t
13 # RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s
14 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s
16 # RUN: ld.lld %t.o %t1.so -o %t
17 # RUN: llvm-readobj -r %t | FileCheck --check-prefix=IE-REL %s
18 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=IE %s
20 ## DT_PPC_GOT represents the address of _GLOBAL_OFFSET_TABLE_.
21 # GD-DYN: PPC_GOT 0x20358
24 # GD-REL-NEXT: 0x20364 R_PPC_DTPMOD32 a 0x0
25 # GD-REL-NEXT: 0x20368 R_PPC_DTPREL32 a 0x0
26 # GD-REL-NEXT: 0x2036C R_PPC_DTPMOD32 b 0x0
27 # GD-REL-NEXT: 0x20370 R_PPC_DTPREL32 b 0x0
28 # GD-REL-NEXT: 0x20374 R_PPC_DTPMOD32 c 0x0
29 # GD-REL-NEXT: 0x20378 R_PPC_DTPREL32 c 0x0
32 ## &DTPMOD(a) - _GLOBAL_OFFSET_TABLE_ = 12
35 # GD-NEXT: lwz 3, 0(3)
37 ## &DTPMOD(b) - _GLOBAL_OFFSET_TABLE_ = 20
38 # GD-NEXT: addi 3, 31, 20
40 # GD-NEXT: lwz 3, 0(3)
42 ## &DTPMOD(c) - _GLOBAL_OFFSET_TABLE_ = 28
43 # GD-NEXT: addi 3, 9, 28
45 # GD-NEXT: lwz 3, 0(3)
47 # NOREL: no relocations
49 ## a@tprel = 8-0x7000 = -28664
51 # LE-NEXT: addi 3, 3, -28664
52 # LE-NEXT: lwz 3, 0(3)
53 ## b@tprel = 12-0x7000 = -28660
54 # LE-NEXT: addis 3, 2, 0
55 # LE-NEXT: addi 3, 3, -28660
56 # LE-NEXT: lwz 3, 0(3)
57 ## c@tprel = 16-0x7000 = -28656
58 # LE-NEXT: addis 3, 2, 0
59 # LE-NEXT: addi 3, 3, -28656
60 # LE-NEXT: lwz 3, 0(3)
63 # IE-REL-NEXT: 0x10020280 R_PPC_TPREL32 b 0x0
64 # IE-REL-NEXT: 0x10020284 R_PPC_TPREL32 c 0x0
67 ## a is relaxed to use LE.
68 ## a@tprel = st_value(a)-0x8000 = -28664
70 # IE-NEXT: addi 3, 3, -28664
71 # IE-NEXT: lwz 3, 0(3)
72 ## &.got[3] - _GLOBAL_OFFSET_TABLE_ = 12
73 # IE-NEXT: lwz 3, 12(31)
74 # IE-NEXT: add 3, 3, 2
75 # IE-NEXT: lwz 3, 0(3)
76 ## &.got[4] - _GLOBAL_OFFSET_TABLE_ = 16
77 # IE-NEXT: lwz 3, 16(9)
78 # IE-NEXT: add 3, 3, 2
79 # IE-NEXT: lwz 3, 0(3)
81 addi 3, 31, a@got@tlsgd
82 bl __tls_get_addr
(a@tlsgd
)
85 addi 3, 31, b@got@tlsgd
86 bl __tls_get_addr
(b@tlsgd
)
89 ## -fpic may use a different register (e.g. r9).
90 addi 3, 9, c@got@tlsgd
91 bl __tls_get_addr
(c@tlsgd
)