2 // RUN
: llvm-mc
-arm-add-build-attributes
-filetype
=obj
-triple
=thumbv7a-none-linux-gnueabi
%s
-o
%t
3 // RUN
: echo
"SECTIONS { \
4 // RUN: .text 0x100000 : { *(.text) } \
5 // RUN: .textl : { *(.text_l0*) *(.text_l1*) *(.text_l2*) *(.text_l3*) } \
6 // RUN: .texth : { *(.text_h0*) *(.text_h1*) *(.text_h2*) *(.text_h3*) } \
8 // RUN
: ld.lld
--script
%t.script
%t -o
%t2
9 // The output file is large
, most of it zeroes. We dissassemble only the
10 // parts we need to speed up the test
and avoid
a large output file
11 // RUN
: llvm-objdump
--no-print-imm-hex
-d
%t2
--start-address
=0x100000 --stop-address
=0x100012 | FileCheck
--check-prefix
=CHECK1
%s
12 // RUN
: llvm-objdump
--no-print-imm-hex
-d
%t2
--start-address
=0x200000 --stop-address
=0x200008 | FileCheck
--check-prefix
=CHECK2
%s
13 // RUN
: llvm-objdump
--no-print-imm-hex
-d
%t2
--start-address
=0xb00004 --stop-address
=0xb0000e | FileCheck
--check-prefix
=CHECK3
%s
14 // RUN
: llvm-objdump
--no-print-imm-hex
-d
%t2
--start-address
=0x2100000 --stop-address
=0x210001a | FileCheck
--check-prefix
=CHECK4
%s
15 // RUN
: llvm-objdump
--no-print-imm-hex
-d
%t2
--start-address
=0x2200000 --stop-address
=0x220000e | FileCheck
--check-prefix
=CHECK5
%s
16 // RUN
: llvm-objdump
--no-print-imm-hex
-d
%t2
--start-address
=0x4100000 --stop-address
=0x4100020 | FileCheck
--check-prefix
=CHECK6
%s
18 // Test the range extensions in
a linker script where there are several
19 // OutputSections requiring range extension Thunks. We should
be able to reuse
20 // Thunks between OutputSections but our placement of new Thunks is done on
a
21 // per OutputSection basis
24 // Define
a function that we can match with
.text_l* aligned on a megabyte
27 .section .text_l\suff\(), "ax", %progbits
31 .type tfuncl\suff\(), %function
36 // Define
a function that we can match with
.text_h* aligned on a megabyte
39 .section .text_h\suff\(), "ax", %progbits
43 .type tfunch\suff\(), %function
48 .section .text, "ax", %progbits
53 // Expect
a range extension thunk in
.text OutputSection
55 // CHECK1
: Disassembly of section
.text:
57 // CHECK1-NEXT
: <_start
>:
58 // CHECK1-NEXT
: 100000: f0ff fffe
bl 0x200000 <tfuncl00
>
59 // CHECK1-NEXT
: 100004: f000 f800
bl 0x100008 <__Thumbv7ABSLongThunk_tfunch31
>
60 // CHECK1
: <__Thumbv7ABSLongThunk_tfunch31
>:
61 // CHECK1-NEXT
: 100008: f240
0c01 movw
r12, #1
62 // CHECK1-NEXT
: 10000c
: f2c0
4c10 movt
r12, #1040
63 // CHECK1-NEXT
: 100010: 4760 bx
r12
65 // Create
a range extension thunk in
.textl
67 // We can reuse existing thunk in
.text
69 // CHECK2
: Disassembly of section
.textl:
71 // CHECK2-NEXT
: <tfuncl00
>:
72 // CHECK2-NEXT
: 200000: 4770 bx
lr
73 // CHECK2-NEXT
: 200002: f0ff dfff
bl 0xb00004 <__Thumbv7ABSLongThunk_tfuncl24
>
74 // CHECK2-NEXT
: 200006: f6ff ffff
bl 0x100008 <__Thumbv7ABSLongThunk_tfunch31
>
84 // CHECK3
: <__Thumbv7ABSLongThunk_tfuncl24
>:
85 // CHECK3-NEXT
: b00004
: f2ff
97fc b.w
0x1a00000 <tfuncl24
>
108 // Create range extension thunks in
.textl
111 // Shouldn
't need a thunk
113 // CHECK4: 2100002: f000 f805 bl 0x2100010 <__Thumbv7ABSLongThunk_tfuncl00>
114 // CHECK4-NEXT: 2100006: f4ff f7fb bl 0x1a00000 <tfuncl24>
115 // CHECK4-NEXT: 210000a: f0ff fff9 bl 0x2200000 <tfunch00>
116 // CHECK4: <__Thumbv7ABSLongThunk_tfuncl00>:
117 // CHECK4-NEXT: 2100010: f240 0c01 movw r12, #1
118 // CHECK4-NEXT: 2100014: f2c0 0c20 movt r12, #32
119 // CHECK4-NEXT: 2100018: 4760 bx r12
121 // Can reuse existing thunks in .textl
124 // Shouldn't need
a thunk
126 // CHECK5
: Disassembly of section
.texth:
128 // CHECK5-NEXT
: <tfunch00
>:
129 // CHECK5-NEXT
: 2200000: 4770 bx
lr
130 // CHECK5-NEXT
: 2200002: f700 f805
bl 0x2100010 <__Thumbv7ABSLongThunk_tfuncl00
>
131 // CHECK5-NEXT
: 2200006: f7ff dffb
bl 0x1a00000 <tfuncl24
>
132 // CHECK5-NEXT
: 220000a: f6ff fff9
bl 0x2100000 <tfuncl31
>
164 // expect Thunks in
.texth
167 // CHECK6
: <tfunch31
>:
168 // CHECK6-NEXT
: 4100000: 4770 bx
lr
169 // CHECK6-NEXT
: 4100002: f000 f803
bl 0x410000c <__Thumbv7ABSLongThunk_tfuncl00
>
170 // CHECK6-NEXT
: 4100006: f000 f806
bl 0x4100016 <__Thumbv7ABSLongThunk_tfunch00
>
171 // CHECK6
: <__Thumbv7ABSLongThunk_tfuncl00
>:
172 // CHECK6-NEXT
: 410000c
: f240
0c01 movw
r12, #1
173 // CHECK6-NEXT
: 4100010: f2c0
0c20 movt
r12, #32
174 // CHECK6-NEXT
: 4100014: 4760 bx
r12
175 // CHECK6
: <__Thumbv7ABSLongThunk_tfunch00
>:
176 // CHECK6-NEXT
: 4100016: f240
0c01 movw
r12, #1
177 // CHECK6-NEXT
: 410001a: f2c0
2c20 movt
r12, #544
178 // CHECK6-NEXT
: 410001e
: 4760 bx
r12