Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / ppc64-long-branch-pi.s
blob4c8c4cebf2742436b8918e62871f3c4094674974
1 # REQUIRES: ppc
2 # RUN: llvm-mc -filetype=obj -triple=ppc64le %s -o %t.o
3 # RUN: echo 'SECTIONS { \
4 # RUN: .text_low 0x2000: { *(.text_low) } \
5 # RUN: .text_high 0x2002000 : { *(.text_high) } \
6 # RUN: }' > %t.script
7 # RUN: ld.lld -pie -T %t.script %t.o -o %t
8 # RUN: llvm-readelf -S %t | FileCheck --check-prefix=SEC-PIE %s
9 # RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOC %s
10 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
12 ## RELATIVE relocs relocating NOBITS .branch_lt do not cause --check-dynamic-relocations errors.
13 # RUN: ld.lld -shared -T %t.script %t.o -o %t.so --apply-dynamic-relocs --check-dynamic-relocations
14 # RUN: llvm-readelf -S %t.so | FileCheck --check-prefix=SEC-SHARED %s
15 # RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck %s
17 # SEC-PIE: Name Type Address Off Size ES Flg Lk Inf Al
18 # SEC-PIE: .got PROGBITS 0000000002002110 2012110 000008 00 WA 0 0 8
19 # SEC-PIE: .branch_lt NOBITS 0000000002002120 2012120 000020 00 WA 0 0 8
21 # SEC-SHARED: Name Type Address Off Size ES Flg Lk Inf Al
22 # SEC-SHARED: .got PROGBITS 00000000020020f0 20120f0 000008 00 WA 0 0 8
23 # SEC-SHARED: .branch_lt NOBITS 0000000002002100 2012100 000020 00 WA 0 0 8
25 # RELOC: .rela.dyn {
26 # RELOC-NEXT: 0x2002118 R_PPC64_RELATIVE - 0x2012110
27 # RELOC-NEXT: 0x2002120 R_PPC64_RELATIVE - 0x2002000
28 # RELOC-NEXT: 0x2002128 R_PPC64_RELATIVE - 0x2002008
29 # RELOC-NEXT: 0x2002130 R_PPC64_RELATIVE - 0x200200C
30 # RELOC-NEXT: 0x2002138 R_PPC64_RELATIVE - 0x2000
31 # RELOC-NEXT: }
33 # CHECK: <_start>:
34 # CHECK-NEXT: 2000: bl 0x2010
35 # CHECK-NEXT: bl 0x2002000
36 # CHECK-NEXT: bl 0x2030
37 # CHECK-NEXT: bl 0x2050
39 ## &.branch_lt[0] - .TOC. = .branch_lt - (.got+0x8000) = -32752
40 # CHECK: <__long_branch_>:
41 # CHECK-NEXT: 2010: addis 12, 2, 0
42 # CHECK-NEXT: ld 12, -32752(12)
43 # CHECK-NEXT: mtctr 12
44 # CHECK-NEXT: bctr
46 ## &.branch_lt[1] - .TOC. = .branch_lt - (.got+0x8000) = -32744
47 # CHECK: <__long_branch_>:
48 # CHECK-NEXT: 2030: addis 12, 2, 0
49 # CHECK-NEXT: ld 12, -32744(12)
50 # CHECK-NEXT: mtctr 12
51 # CHECK-NEXT: bctr
53 ## &.branch_lt[2] - .TOC. = .branch_lt - (.got+0x8000) = -32736
54 # CHECK: <__long_branch_>:
55 # CHECK-NEXT: 2050: addis 12, 2, 0
56 # CHECK-NEXT: ld 12, -32736(12)
57 # CHECK-NEXT: mtctr 12
58 # CHECK-NEXT: bctr
60 .section .text_low, "ax", %progbits
61 .globl _start
62 _start:
63 bl .text_high # Need a thunk
64 bl .text_high
65 bl .text_high+8 # Need a thunk
66 bl .text_high+0xc # Need a thunk
68 # CHECK: <high_target>:
69 # CHECK-NEXT: 2002000: bl 0x2004
70 # CHECK-NEXT: bl 0x2004
71 # CHECK-NEXT: bl 0x2002010
73 ## &.branch_lt[3] - .TOC. = .branch_lt - (.got+0x8000) = -32728
74 # CHECK: <__long_branch_>:
75 # CHECK-NEXT: 2002010: addis 12, 2, 0
76 # CHECK-NEXT: ld 12, -32728(12)
77 # CHECK-NEXT: mtctr 12
78 # CHECK-NEXT: bctr
80 .section .text_high, "ax", %progbits
81 high_target:
82 bl .text_low+4
83 bl .text_low+4
84 bl .text_low # Need a thunk
85 blr
87 ## Force creation of .got
88 ## The R_PPC64_RELATIVE makes sure .rela.dyn survives removeUnusedSyntheticSections.
89 .section .data
90 .quad .TOC.@tocbase