• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: ppc
2# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o
3# RUN: echo '.globl __tls_get_addr; __tls_get_addr:' | llvm-mc -filetype=obj -triple=powerpc - -o %tga.o
4
5# RUN: ld.lld -shared %t.o -o %t.so
6# RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=LD-REL %s
7# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck --check-prefix=LD %s
8
9# RUN: ld.lld %t.o %tga.o -o %t
10# RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s
11# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s
12
13# LD-REL:      .rela.dyn {
14# LD-REL-NEXT:   0x202C4 R_PPC_DTPMOD32 - 0x0
15# LD-REL-NEXT: }
16
17## .got - _GLOBAL_OFFSET_TABLE_ = 0
18# LD:      addi 3, 30, 0
19# LD-NEXT: bl 0x101f8
20## a@dtprel = st_value(a)-0x8000 = 65540-0x8000 = 65536*1-32764
21## b@dtprel = st_value(a)-0x8000 = 131080-0x8000 = 65536*2-32760
22# LD-NEXT: addis 9, 3, 1
23# LD-NEXT: addis 10, 3, 2
24# LD-NEXT: addi 9, 9, -32764
25# LD-NEXT: addi 10, 10, -32760
26## small@dtprel = st_value(small)-0x8000 = 4-0x8000 = -32764
27# LD-NEXT: addi 9, 3, -32764
28
29## Check that b@got@tlsld does not allocate another GOT entry.
30## It shares In.Got->TlsIndexOff allocated when processing a@got@tlsld.
31## .got - _GLOBAL_OFFSET_TABLE_ = 0
32# LD-NEXT: addi 3, 9, 0
33# LD-NEXT: bl 0x101f8
34## b@dtprel = st_value(a)-0x8000 = 131080-0x8000 = 65536*2-32760
35# LD-NEXT: addis 29, 3, 2
36# LD-NEXT: addi 29, 29, -32760
37
38## When producing an executable, the LD code sequence can be relaxed to LE.
39## It is the same as GD->LE.
40## tpoff(_TLS_MODULE_BASE_) = 0, tpoff(a) = -8, tpoff(b) = -4
41
42# NOREL: no relocations
43
44## Set r3 to r2+4096
45# LE:      addis 3, 2, 0
46# LE-NEXT: addi 3, 3, 4096
47## a@tprel = 65540-0x7000 = 65536*1-32764
48## b@tprel = 131080-0x7000 = 65536*2-32760
49# LE-NEXT: addis 9, 3, 1
50# LE-NEXT: addis 10, 3, 2
51# LE-NEXT: addi 9, 9, -32764
52# LE-NEXT: addi 10, 10, -32760
53## small@tprel = 4-0x7000 = -32764
54# LE-NEXT: addi 9, 3, -32764
55
56## Set r3 to r2+4096
57# LE-NEXT: addis 3, 2, 0
58# LE-NEXT: addi 3, 3, 4096
59## b@tprel = 131080-0x7000 = 65536*2-32760
60# LE-NEXT: addis 29, 3, 2
61# LE-NEXT: addi 29, 29, -32760
62
63addi 3, 30, a@got@tlsld
64bl __tls_get_addr(a@tlsld)
65addis 9, 3, a@dtprel@ha
66addis 10, 3, b@dtprel@ha
67addi 9, 9, a@dtprel@l
68addi 10, 10, b@dtprel@l
69addi 9, 3, small@dtprel
70
71addi 3, 9, b@got@tlsld
72bl __tls_get_addr(b@tlsld)
73addis 29, 3, b@dtprel@ha
74addi 29, 29, b@dtprel@l
75
76.section .tbss
77.zero 4
78small:
79.zero 65536
80a:
81.zero 65540
82b:
83