2 // RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
3 // RUN: ld.lld %t -o %t2 2>&1
4 // The output file is large, most of it zeroes. We dissassemble only the
5 // parts we need to speed up the test and avoid a large output file
6 // RUN: llvm-objdump -d %t2 -start-address=524288 -stop-address=524316 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK1 %s
7 // RUN: llvm-objdump -d %t2 -start-address=1048576 -stop-address=1048584 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK2 %s
8 // RUN: llvm-objdump -d %t2 -start-address=1572864 -stop-address=1572872 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK3 %s
9 // RUN: llvm-objdump -d %t2 -start-address=5242884 -stop-address=5242894 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK4 %s
10 // RUN: llvm-objdump -d %t2 -start-address=5767168 -stop-address=5767174 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK5 %s
11 // RUN: llvm-objdump -d %t2 -start-address=16777220 -stop-address=16777240 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK6 %s
12 // RUN: llvm-objdump -d %t2 -start-address=17825792 -stop-address=17825798 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK7 %s
13 // Test Range extension Thunks for the Thumb conditional branch instruction.
14 // This instruction only has a range of 1Mb whereas all the other Thumb wide
15 // Branch instructions have 16Mb range. We still place our pre-created Thunk
16 // Sections at 16Mb intervals as conditional branches to a target defined
17 // in a different section are rare.
19 // Define a function aligned on a half megabyte boundary
21 .section .text.\suff\(), "ax", %progbits
25 .type tfunc\suff\(), %function
33 // Long Range Thunk needed for 16Mb range branch, can reach pre-created Thunk
36 // CHECK1: Disassembly of section .text:
37 // CHECK1-NEXT: tfunc00:
38 // CHECK1-NEXT: 80000: 70 47 bx lr
39 // CHECK1-NEXT: 80002: 7f f3 ff d7 bl #16252926
40 // CHECK1: __Thumbv7ABSLongThunk_tfunc05:
41 // CHECK1-NEXT: 80008: 7f f2 fa bf b.w #2621428 <tfunc05>
42 // CHECK1: __Thumbv7ABSLongThunk_tfunc00:
43 // CHECK1-NEXT: 8000c: ff f7 f8 bf b.w #-16 <tfunc00>
45 // tfunc02 is within range of tfunc02
47 // tfunc05 is out of range, and we can't reach the pre-created Thunk Section
51 // CHECK2-NEXT: 100000: 70 47 bx lr
52 // CHECK2-NEXT: 100002: 3f f0 fd a7 beq.w #524282 <tfunc02>
53 // CHECK2-NEXT: 100006: 7f f4 ff a7 bne.w #-524290 <__Thumbv7ABSLongThunk_tfunc05>
55 // We can reach the Thunk Section created for bne.w tfunc05
58 // CHECK3: 180000: 70 47 bx lr
59 // CHECK3-NEXT: 180002: 40 f4 01 80 bne.w #-1048574 <__Thumbv7ABSLongThunk_tfunc05>
60 // CHECK3-NEXT: 180006: 00 f4 01 80 beq.w #-1048574 <__Thumbv7ABSLongThunk_tfunc00>
68 // CHECK4: __Thumbv7ABSLongThunk_tfunc03:
69 // CHECK4-NEXT: 500004: ff f4 fc bf b.w #-3145736 <tfunc03>
71 // We can't reach any Thunk Section, create a new one
74 // CHECK5-NEXT: 580000: 70 47 bx lr
75 // CHECK5-NEXT: 580002: 3f f4 ff a7 beq.w #-524290 <__Thumbv7ABSLongThunk_tfunc03>
97 // CHECK6: __Thumbv7ABSLongThunk_tfunc33:
98 // CHECK6-NEXT: 1000004: ff f0 fc bf b.w #1048568 <tfunc33>
99 // CHECK6: __Thumbv7ABSLongThunk_tfunc00:
100 // CHECK6-NEXT: 1000008: 7f f4 fa 97 b.w #-16252940 <tfunc00>
103 // We should be able to reach an existing ThunkSection.
106 // CHECK7-NEXT: 1100000: 70 47 bx lr
107 // CHECK7-NEXT: 1100002: 00 f7 01 b8 b.w #-1048574 <__Thumbv7ABSLongThunk_tfunc00>