[ELF] Make section member orders consistent
[llvm-project.git] / lld / test / ELF / ppc64-pcrel-cross-link.s
blobeaf0464a492f7a398d66a215a5e82acc00312001
1 # REQUIRES: ppc
2 # RUN: split-file %s %t
4 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/callees.s -o %t-callees.o
5 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/callertoc.s -o %t-callertoc.o
6 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/callernotoc.s -o %t-callernotoc.o
7 # RUN: ld.lld -T %t/lds %t-callees.o %t-callernotoc.o %t-callertoc.o -o %t-r12setup
8 # RUN: ld.lld -T %t/ldsswap %t-callees.o %t-callernotoc.o %t-callertoc.o -o %t-r2save
10 # RUN: llvm-objdump -d --no-show-raw-insn %t-r12setup | \
11 # RUN: FileCheck %s --check-prefix=NOSWAP
12 # RUN: llvm-objdump -d --no-show-raw-insn %t-r2save | \
13 # RUN: FileCheck %s --check-prefix=SWAP
15 ## This test checks that it is possible to mix TOC and NOTOC functions and have
16 ## the correct thunks for all of the calls.
18 # NOSWAP-LABEL: 01001000 <func>:
19 # NOSWAP-NEXT: blr
20 # NOSWAP-LABEL: 01002000 <callee_toc>:
21 # NOSWAP: bl 0x1001000
22 # NOSWAP: blr
23 # NOSWAP-LABEL: 01002018 <callee_notoc>:
24 # NOSWAP: bl 0x1001000
25 # NOSWAP: blr
26 # NOSWAP-LABEL: 10030000 <caller_notoc>:
27 # NOSWAP-NEXT: bl 0x10030010
28 # NOSWAP-NEXT: bl 0x10030030
29 # NOSWAP-NEXT: blr
30 # NOSWAP-LABEL: 10030010 <__gep_setup_callee_toc>:
31 # NOSWAP: bctr
32 # NOSWAP-LABEL: 10030030 <__gep_setup_callee_notoc>:
33 # NOSWAP: bctr
34 # NOSWAP-LABEL: 10040000 <caller_toc>:
35 # NOSWAP: bl 0x10040020
36 # NOSWAP-NEXT: nop
37 # NOSWAP-NEXT: bl 0x10040040
38 # NOSWAP-NEXT: ld 2, 24(1)
39 # NOSWAP-NEXT: blr
40 # NOSWAP-LABEL: 10040020 <__long_branch_callee_toc>:
41 # NOSWAP: bctr
42 # NOSWAP-LABEL: 10040040 <__toc_save_callee_notoc>:
43 # NOSWAP-NEXT: std 2, 24(1)
44 # NOSWAP: bctr
46 # SWAP-LABEL: 01001000 <func>:
47 # SWAP-NEXT: blr
48 # SWAP-LABEL: 01002000 <callee_toc>:
49 # SWAP: bl 0x1001000
50 # SWAP: blr
51 # SWAP-LABEL: 01002018 <callee_notoc>:
52 # SWAP: bl 0x1001000
53 # SWAP: blr
54 # SWAP-LABEL: 10030000 <caller_toc>:
55 # SWAP: bl 0x10030020
56 # SWAP-NEXT: nop
57 # SWAP-NEXT: bl 0x10030040
58 # SWAP-NEXT: ld 2, 24(1)
59 # SWAP-NEXT: blr
60 # SWAP-LABEL: 10030020 <__long_branch_callee_toc>:
61 # SWAP: bctr
62 # SWAP-LABEL: 10030040 <__toc_save_callee_notoc>:
63 # SWAP-NEXT: std 2, 24(1)
64 # SWAP: bctr
65 # SWAP-LABEL: 10040000 <caller_notoc>:
66 # SWAP-NEXT: bl 0x10040010
67 # SWAP-NEXT: bl 0x10040030
68 # SWAP-NEXT: blr
69 # SWAP-LABEL: 10040010 <__gep_setup_callee_toc>:
70 # SWAP: bctr
71 # SWAP-LABEL: 10040030 <__gep_setup_callee_notoc>:
72 # SWAP: bctr
74 #--- lds
75 SECTIONS {
76 .text_func 0x1001000 : { *(.text_func) }
77 .text_callee 0x1002000 : { *(.text_callee) }
78 .text_caller_notoc 0x10030000 : { *(.text_caller_notoc) }
79 .text_caller_toc 0x10040000 : { *(.text_caller_toc) }
82 #--- ldsswap
83 SECTIONS {
84 .text_func 0x1001000 : { *(.text_func) }
85 .text_callee 0x1002000 : { *(.text_callee) }
86 .text_caller_toc 0x10030000 : { *(.text_caller_toc) }
87 .text_caller_notoc 0x10040000 : { *(.text_caller_notoc) }
90 #--- callees.s
91 .section .text_func, "ax", %progbits
92 func:
93 blr
95 .globl callee_toc
96 .section .text_callee, "ax", %progbits
97 callee_toc:
98 .Lfunc_gep1:
99 addis 2, 12, .TOC.-.Lfunc_gep1@ha
100 addi 2, 2, .TOC.-.Lfunc_gep1@l
101 .Lfunc_lep1:
102 .localentry callee_toc, .Lfunc_lep1-.Lfunc_gep1
103 bl func
104 addis 4, 2, global@toc@ha
105 lwz 4, global@toc@l(4)
108 .globl callee_notoc
109 callee_notoc:
110 .localentry callee_notoc, 1
111 bl func
112 plwz 4, global@pcrel(0), 1
115 ## .globl global
116 global:
117 .long 0
118 .size global, 4
120 #--- callernotoc.s
121 .section .text_caller_notoc, "ax", %progbits
122 caller_notoc:
123 .localentry caller, 1
124 bl callee_toc@notoc
125 bl callee_notoc@notoc
128 #--- callertoc.s
129 .section .text_caller_toc, "ax", %progbits
130 caller_toc:
131 .Lfunc_gep2:
132 addis 2, 12, .TOC.-.Lfunc_gep2@ha
133 addi 2, 2, .TOC.-.Lfunc_gep2@l
134 .Lfunc_lep2:
135 .localentry caller_toc, .Lfunc_lep2-.Lfunc_gep2
136 bl callee_toc
138 bl callee_notoc