Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / ppc64-toc-relax.s
blob59aed15b394fff5c12fce7e5fe4fef631350a698
1 # REQUIRES: ppc
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
35 # RELOCS-LE-NEXT: }
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
46 # RELOCS-BE-NEXT: }
48 # RELOCS: .rela.toc {
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
53 # RELOCS-NEXT: }
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
63 # COMMON: lwa 3, 0(3)
64 addis 3, 2, .Lhidden@toc@ha
65 ld 3, .Lhidden@toc@l(3)
66 lwa 3, 0(3)
68 # address(hidden2) - (.got+0x8000) = 0x100403b0 - (0x10020390+0x8000) = (2<<16) - 32736
69 # COMMON: addis 3, 2, 2
70 # COMMON: addi 3, 3, -32736
71 # COMMON: lwa 3, 0(3)
72 addis 3, 2, .Lhidden2@toc@ha
73 ld 3, .Lhidden2@toc@l(3)
74 lwa 3, 0(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.
79 # COMMON: nop
80 # COMMON: ld 4, -32752(2)
81 # COMMON: lwa 4, 0(4)
82 addis 4, 2, .Lshared@toc@ha
83 ld 4, .Lshared@toc@l(4)
84 lwa 4, 0(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
88 # EXE: addis 5, 2, 1
89 # EXE: addi 5, 5, -32736
90 # EXE: lwa 5, 0(5)
92 # SHARED: nop
93 # SHARED: ld 5, -32744(2)
94 # SHARED: lwa 5, 0(5)
95 addis 5, 2, .Ldefault@toc@ha
96 ld 5, .Ldefault@toc@l(5)
97 lwa 5, 0(5)
99 .section .toc,"aw",@progbits
100 .Lhidden:
101 .tc hidden[TC], hidden
102 .Lhidden2:
103 .tc hidden2[TC], hidden2
104 .Lshared:
105 .tc shared[TC], shared
106 .Ldefault:
107 .tc default[TC], default