2 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-toc-relax-shared.s -o %t.o
3 # RUN: ld.lld -shared -soname=t.so %t.o -o %t.so
4 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t1.o
5 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-toc-relax.s -o %t2.o
6 # RUN: llvm-readobj -r %t1.o | FileCheck --check-prefixes=RELOCS-LE,RELOCS %s
7 # RUN: ld.lld %t1.o %t2.o %t.so -o %t
8 # RUN: llvm-nm %t | FileCheck --check-prefix=NM %s
9 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefixes=COMMON,EXE %s
11 # RUN: ld.lld -shared %t1.o %t2.o %t.so -o %t2.so
12 # RUN: llvm-objdump -d --no-show-raw-insn %t2.so | FileCheck --check-prefixes=COMMON,SHARED %s
14 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-toc-relax-shared.s -o %t.o
15 # RUN: ld.lld -shared -soname=t.so %t.o -o %t.so
16 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t1.o
17 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-toc-relax.s -o %t2.o
18 # RUN: llvm-readobj -r %t1.o | FileCheck --check-prefixes=RELOCS-BE,RELOCS %s
19 # RUN: ld.lld %t1.o %t2.o %t.so -o %t
20 # RUN: llvm-nm %t | FileCheck --check-prefix=NM %s
21 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefixes=COMMON,EXE %s
23 # RUN: ld.lld -shared %t1.o %t2.o %t.so -o %t2.so
24 # RUN: llvm-objdump -d --no-show-raw-insn %t2.so | FileCheck --check-prefixes=COMMON,SHARED %s
26 # RELOCS-LE: .rela.text {
27 # RELOCS-LE-NEXT: 0x0 R_PPC64_TOC16_HA .toc 0x0
28 # RELOCS-LE-NEXT: 0x4 R_PPC64_TOC16_LO_DS .toc 0x0
29 # RELOCS-LE-NEXT: 0xC R_PPC64_TOC16_HA .toc 0x8
30 # RELOCS-LE-NEXT: 0x10 R_PPC64_TOC16_LO_DS .toc 0x8
31 # RELOCS-LE-NEXT: 0x18 R_PPC64_TOC16_HA .toc 0x10
32 # RELOCS-LE-NEXT: 0x1C R_PPC64_TOC16_LO_DS .toc 0x10
33 # RELOCS-LE-NEXT: 0x24 R_PPC64_TOC16_HA .toc 0x18
34 # RELOCS-LE-NEXT: 0x28 R_PPC64_TOC16_LO_DS .toc 0x18
37 # RELOCS-BE: .rela.text {
38 # RELOCS-BE-NEXT: 0x2 R_PPC64_TOC16_HA .toc 0x0
39 # RELOCS-BE-NEXT: 0x6 R_PPC64_TOC16_LO_DS .toc 0x0
40 # RELOCS-BE-NEXT: 0xE R_PPC64_TOC16_HA .toc 0x8
41 # RELOCS-BE-NEXT: 0x12 R_PPC64_TOC16_LO_DS .toc 0x8
42 # RELOCS-BE-NEXT: 0x1A R_PPC64_TOC16_HA .toc 0x10
43 # RELOCS-BE-NEXT: 0x1E R_PPC64_TOC16_LO_DS .toc 0x10
44 # RELOCS-BE-NEXT: 0x26 R_PPC64_TOC16_HA .toc 0x18
45 # RELOCS-BE-NEXT: 0x2A R_PPC64_TOC16_LO_DS .toc 0x18
49 # RELOCS-NEXT: 0x0 R_PPC64_ADDR64 hidden 0x0
50 # RELOCS-NEXT: 0x8 R_PPC64_ADDR64 hidden2 0x0
51 # RELOCS-NEXT: 0x10 R_PPC64_ADDR64 shared 0x0
52 # RELOCS-NEXT: 0x18 R_PPC64_ADDR64 default 0x0
55 # NM-DAG: 00000000100303b0 D default
56 # NM-DAG: 00000000100303b0 d hidden
57 # NM-DAG: 00000000100403b0 d hidden2
59 # 'hidden' is non-preemptable. It is relaxed.
60 # address(hidden) - (.got+0x8000) = 0x100303b0 - (0x10020390+0x8000) = (1<<16) - 32736
61 # COMMON: addis 3, 2, 1
62 # COMMON: addi 3, 3, -32736
64 addis 3, 2, .Lhidden@toc@ha
65 ld 3, .Lhidden@toc@l(3)
68 # address(hidden2) - (.got+0x8000) = 0x100403b0 - (0x10020390+0x8000) = (2<<16) - 32736
69 # COMMON: addis 3, 2, 2
70 # COMMON: addi 3, 3, -32736
72 addis 3, 2, .Lhidden2@toc@ha
73 ld 3, .Lhidden2@toc@l(3)
76 # 'shared' is not defined in an object file. Its definition is determined at
77 # runtime by the dynamic linker, so the extra indirection cannot be relaxed.
78 # The first addis can still be relaxed to nop, though.
80 # COMMON: ld 4, -32752(2)
82 addis 4, 2, .Lshared@toc@ha
83 ld 4, .Lshared@toc@l(4)
86 # 'default' has default visibility. It is non-preemptable when producing an executable.
87 # address(default) - (.got+0x8000) = 0x100303b0 - (0x10020390+0x8000) = (1<<16) - 32736
89 # EXE: addi 5, 5, -32736
93 # SHARED: ld 5, -32744(2)
95 addis 5, 2, .Ldefault@toc@ha
96 ld 5, .Ldefault@toc@l(5)
99 .section .toc,"aw",@progbits
101 .tc hidden[TC], hidden
103 .tc hidden2[TC], hidden2
105 .tc shared[TC], shared
107 .tc default[TC], default