2 # Check LA25 stubs creation. This stub code is necessary when
3 # non-PIC code calls PIC function.
4 # RUN: echo "SECTIONS { .out 0x20000 : { *(.text.*) . = . + 0x100 ; *(.text) } }" > %t1.script
5 # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
6 # RUN: %p/Inputs/mips-fpic.s -o %t-fpic.o
7 # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
8 # RUN: %p/Inputs/mips-fnpic.s -o %t-fnpic.o
9 # RUN: ld.lld -r %t-fpic.o %t-fnpic.o -o %t-sto-pic.o
10 # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
11 # RUN: %p/Inputs/mips-pic.s -o %t-pic.o
12 # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-npic.o
13 # RUN: ld.lld --script %t1.script %t-npic.o %t-pic.o %t-sto-pic.o -o %t.exe
14 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t.exe | FileCheck %s
16 # CHECK: Disassembly of section .out:
18 # CHECK-NEXT: <__LA25Thunk_foo1a>:
19 # CHECK-NEXT: 20000: lui $25, 2
20 # CHECK-NEXT: 20004: j {{.*}} <foo1a>
21 # CHECK-NEXT: 20008: addiu $25, $25, 32
22 # CHECK-NEXT: 2000c: nop
24 # CHECK: <__LA25Thunk_foo1b>:
25 # CHECK-NEXT: 20010: lui $25, 2
26 # CHECK-NEXT: 20014: j {{.*}} <foo1b>
27 # CHECK-NEXT: 20018: addiu $25, $25, 36
28 # CHECK-NEXT: 2001c: nop
31 # CHECK-NEXT: 20020: nop
34 # CHECK-NEXT: 20024: nop
36 # CHECK: <__LA25Thunk_foo2>:
37 # CHECK-NEXT: 20028: lui $25, 2
38 # CHECK-NEXT: 2002c: j {{.*}} <foo2>
39 # CHECK-NEXT: 20030: addiu $25, $25, 64
40 # CHECK-NEXT: 20034: nop
43 # CHECK-NEXT: 20040: nop
46 # CHECK-NEXT: 20150: jal {{.*}} <__LA25Thunk_foo1a>
47 # CHECK-NEXT: 20154: nop
48 # CHECK-NEXT: 20158: jal {{.*}} <__LA25Thunk_foo2>
49 # CHECK-NEXT: 2015c: nop
50 # CHECK-NEXT: 20160: jal {{.*}} <__LA25Thunk_foo1b>
51 # CHECK-NEXT: 20164: nop
52 # CHECK-NEXT: 20168: jal {{.*}} <__LA25Thunk_foo2>
53 # CHECK-NEXT: 2016c: nop
54 # CHECK-NEXT: 20170: jal {{.*}} <__LA25Thunk_fpic>
55 # CHECK-NEXT: 20174: nop
56 # CHECK-NEXT: 20178: jal {{.*}} <fnpic>
57 # CHECK-NEXT: 2017c: nop
59 # CHECK: <__LA25Thunk_fpic>:
60 # CHECK-NEXT: 20180: lui $25, 2
61 # CHECK-NEXT: 20184: j {{.*}} <fpic>
62 # CHECK-NEXT: 20188: addiu $25, $25, 400
63 # CHECK-NEXT: 2018c: nop
66 # CHECK-NEXT: 20190: nop
69 # CHECK-NEXT: 201a0: nop
81 # Test script with orphans added to existing OutputSection, the .text.1 and
82 # .text.2 sections will be added to .text
83 # RUN: echo "SECTIONS { .text 0x20000 : { *(.text) } }" > %t2.script
84 # RUN: ld.lld --script %t2.script %t-npic.o %t-pic.o %t-sto-pic.o -o %t2.exe
85 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t2.exe | FileCheck --check-prefix=ORPH1 %s
87 # ORPH1: Disassembly of section .text:
89 # ORPH1-NEXT: <__start>:
90 # ORPH1-NEXT: 20000: jal {{.*}} <__LA25Thunk_foo1a>
91 # ORPH1-NEXT: 20004: nop
92 # ORPH1-NEXT: 20008: jal {{.*}} <__LA25Thunk_foo2>
93 # ORPH1-NEXT: 2000c: nop
94 # ORPH1-NEXT: 20010: jal {{.*}} <__LA25Thunk_foo1b>
95 # ORPH1-NEXT: 20014: nop
96 # ORPH1-NEXT: 20018: jal {{.*}} <__LA25Thunk_foo2>
97 # ORPH1-NEXT: 2001c: nop
98 # ORPH1-NEXT: 20020: jal {{.*}} <__LA25Thunk_fpic>
99 # ORPH1-NEXT: 20024: nop
100 # ORPH1-NEXT: 20028: jal {{.*}} <fnpic>
101 # ORPH1-NEXT: 2002c: nop
103 # ORPH1: <__LA25Thunk_fpic>:
104 # ORPH1-NEXT: 20030: lui $25, 2
105 # ORPH1-NEXT: 20034: j {{.*}} <fpic>
106 # ORPH1-NEXT: 20038: addiu $25, $25, 64
107 # ORPH1-NEXT: 2003c: nop
110 # ORPH1-NEXT: 20040: nop
113 # ORPH1-NEXT: 20050: nop
115 # ORPH1: <__LA25Thunk_foo1a>:
116 # ORPH1-NEXT: 20060: lui $25, 2
117 # ORPH1-NEXT: j {{.*}} <foo1a>
118 # ORPH1-NEXT: addiu $25, $25, 128
121 # ORPH1: <__LA25Thunk_foo1b>:
122 # ORPH1-NEXT: 20070: lui $25, 2
123 # ORPH1-NEXT: j {{.*}} <foo1b>
124 # ORPH1-NEXT: addiu $25, $25, 132
128 # ORPH1-NEXT: 20080: nop
131 # ORPH1-NEXT: 20084: nop
133 # ORPH1: <__LA25Thunk_foo2>:
134 # ORPH1-NEXT: 20090: lui $25, 2
135 # ORPH1-NEXT: j {{.*}} <foo2>
136 # ORPH1-NEXT: addiu $25, $25, 160
140 # ORPH1-NEXT: 200a0: nop
142 # Test script with orphans added to new OutputSection, the .text.1 and
143 # .text.2 sections will form a new OutputSection .text
144 # RUN: echo "SECTIONS { .out 0x20000 : { *(.text) } .text : {*(.text*)} }" > %t3.script
145 # RUN: ld.lld --script %t3.script %t-npic.o %t-pic.o %t-sto-pic.o -o %t3.exe
146 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t3.exe | FileCheck --check-prefix=ORPH2 %s
148 # ORPH2: Disassembly of section .out:
150 # ORPH2-NEXT: <__start>:
151 # ORPH2-NEXT: 20000: jal {{.*}} <__LA25Thunk_foo1a>
152 # ORPH2-NEXT: 20004: nop
153 # ORPH2-NEXT: 20008: jal {{.*}} <__LA25Thunk_foo2>
154 # ORPH2-NEXT: 2000c: nop
155 # ORPH2-NEXT: 20010: jal {{.*}} <__LA25Thunk_foo1b>
156 # ORPH2-NEXT: 20014: nop
157 # ORPH2-NEXT: 20018: jal {{.*}} <__LA25Thunk_foo2>
158 # ORPH2-NEXT: 2001c: nop
159 # ORPH2-NEXT: 20020: jal {{.*}} <__LA25Thunk_fpic>
160 # ORPH2-NEXT: 20024: nop
161 # ORPH2-NEXT: 20028: jal {{.*}} <fnpic>
162 # ORPH2-NEXT: 2002c: nop
164 # ORPH2: <__LA25Thunk_fpic>:
165 # ORPH2-NEXT: 20030: lui $25, 2
166 # ORPH2-NEXT: 20034: j {{.*}} <fpic>
167 # ORPH2-NEXT: 20038: addiu $25, $25, 64
168 # ORPH2-NEXT: 2003c: nop
171 # ORPH2-NEXT: 20040: nop
174 # ORPH2-NEXT: 20050: nop
176 # ORPH2-NEXT: Disassembly of section .text:
179 # ORPH2-NEXT: <__LA25Thunk_foo1a>:
180 # ORPH2-NEXT: 20060: lui $25, 2
181 # ORPH2-NEXT: 20064: j {{.*}} <foo1a>
182 # ORPH2-NEXT: 20068: addiu $25, $25, 128
183 # ORPH2-NEXT: 2006c: nop
185 # ORPH2: <__LA25Thunk_foo1b>:
186 # ORPH2-NEXT: 20070: lui $25, 2
187 # ORPH2-NEXT: 20074: j {{.*}} <foo1b>
188 # ORPH2-NEXT: 20078: addiu $25, $25, 132
189 # ORPH2-NEXT: 2007c: nop
192 # ORPH2-NEXT: 20080: nop
195 # ORPH2-NEXT: 20084: nop
197 # ORPH2: <__LA25Thunk_foo2>:
198 # ORPH2-NEXT: 20088: lui $25, 2
199 # ORPH2-NEXT: 2008c: j {{.*}} <foo2>
200 # ORPH2-NEXT: 20090: addiu $25, $25, 160
201 # ORPH2-NEXT: 20094: nop
204 # ORPH2-NEXT: 200a0: nop