1// REQUIRES: arm
2// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
3// RUN: echo "SECTIONS { \
4// RUN:       . = SIZEOF_HEADERS; \
5// RUN:       .text_low : { *(.text_low) *(.text_low2) } \
6// RUN:       .text_high 0x2000000 : { *(.text_high) *(.text_high2) } \
7// RUN:       } " > %t.script
8// RUN: ld.lld --no-rosegment --script %t.script %t -o %t2
9// RUN: llvm-objdump -d %t2 | FileCheck %s
10// Simple test that we can support range extension thunks with linker scripts
11 .syntax unified
12 .section .text_low, "ax", %progbits
13 .thumb
14 .globl _start
15_start: bx lr
16 .globl low_target
17 .type low_target, %function
18low_target:
19 bl high_target
20 bl high_target2
21
22 .section .text_low2, "ax", %progbits
23 .thumb
24 .globl low_target2
25 .type low_target2, %function
26low_target2:
27 bl high_target
28 bl high_target2
29
30// CHECK: Disassembly of section .text_low:
31// CHECK-EMPTY:
32// CHECK-NEXT: <_start>:
33// CHECK-NEXT:       94:        4770    bx      lr
34// CHECK: <low_target>:
35// CHECK-NEXT:       96:        f000 f803       bl      0xa0 <__Thumbv7ABSLongThunk_high_target>
36// CHECK-NEXT:       9a:        f000 f806       bl      0xaa <__Thumbv7ABSLongThunk_high_target2>
37// CHECK: <__Thumbv7ABSLongThunk_high_target>:
38// CHECK-NEXT:       a0:        f240 0c01       movw    r12, #1
39// CHECK-NEXT:       a4:        f2c0 2c00       movt    r12, #512
40// CHECK-NEXT:       a8:        4760    bx      r12
41// CHECK: <__Thumbv7ABSLongThunk_high_target2>:
42// CHECK-NEXT:       aa:        f240 0c1d       movw    r12, #29
43// CHECK-NEXT:       ae:        f2c0 2c00       movt    r12, #512
44// CHECK-NEXT:       b2:        4760    bx      r12
45// CHECK: <low_target2>:
46// CHECK-NEXT:       b4:        f7ff fff4       bl      0xa0 <__Thumbv7ABSLongThunk_high_target>
47// CHECK-NEXT:       b8:        f7ff fff7       bl      0xaa <__Thumbv7ABSLongThunk_high_target2>
48
49 .section .text_high, "ax", %progbits
50 .thumb
51 .globl high_target
52 .type high_target, %function
53high_target:
54 bl low_target
55 bl low_target2
56
57 .section .text_high2, "ax", %progbits
58 .thumb
59 .globl high_target2
60 .type high_target2, %function
61high_target2:
62 bl low_target
63 bl low_target2
64
65// CHECK: Disassembly of section .text_high:
66// CHECK-EMPTY:
67// CHECK-NEXT: <high_target>:
68// CHECK-NEXT:  2000000:        f000 f802       bl      0x2000008 <__Thumbv7ABSLongThunk_low_target>
69// CHECK-NEXT:  2000004:        f000 f805       bl      0x2000012 <__Thumbv7ABSLongThunk_low_target2>
70// CHECK: <__Thumbv7ABSLongThunk_low_target>:
71// CHECK-NEXT:  2000008:        f240 0c97       movw    r12, #151
72// CHECK-NEXT:  200000c:        f2c0 0c00       movt    r12, #0
73// CHECK-NEXT:  2000010:        4760    bx      r12
74// CHECK: <__Thumbv7ABSLongThunk_low_target2>:
75// CHECK-NEXT:  2000012:        f240 0cb5       movw    r12, #181
76// CHECK-NEXT:  2000016:        f2c0 0c00       movt    r12, #0
77// CHECK-NEXT:  200001a:        4760    bx      r12
78// CHECK: <high_target2>:
79// CHECK-NEXT:  200001c:        f7ff fff4       bl      0x2000008 <__Thumbv7ABSLongThunk_low_target>
80// CHECK-NEXT:  2000020:        f7ff fff7       bl      0x2000012 <__Thumbv7ABSLongThunk_low_target2>
81