1// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
2// RUN: echo "SECTIONS { \
3// RUN:       . = SIZEOF_HEADERS; \
4// RUN:       .text_low : { *(.text_low) *(.text_low2) . = . + 0x2000000 ; *(.text_high) *(.text_high2) } \
5// RUN:       } " > %t.script
6// RUN: ld.lld --script %t.script %t -o %t2 2>&1
7// RUN: llvm-objdump -d %t2 -start-address=148 -stop-address=188 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK1 %s
8// RUN: llvm-objdump -d %t2 -start-address=33554620 -stop-address=33554654 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK2 %s
9// REQUIRES: arm
10// Test that range extension thunks can handle location expressions within
11// a Section Description
12 .syntax unified
13 .section .text_low, "ax", %progbits
14 .thumb
15 .globl _start
16_start: bx lr
17 .globl low_target
18 .type low_target, %function
19low_target:
20 bl high_target
21 bl high_target2
22
23 .section .text_low2, "ax", %progbits
24 .thumb
25 .globl low_target2
26 .type low_target2, %function
27low_target2:
28 bl high_target
29 bl high_target2
30// CHECK1: Disassembly of section .text_low:
31// CHECK1-NEXT: _start:
32// CHECK1-NEXT:       94:       70 47   bx      lr
33// CHECK1: low_target:
34// CHECK1-NEXT:       96:       00 f0 03 f8     bl      #6
35// CHECK1-NEXT:       9a:       00 f0 06 f8     bl      #12
36// CHECK1: __Thumbv7ABSLongThunk_high_target:
37// CHECK1-NEXT:       a0:       40 f2 bd 0c     movw    r12, #189
38// CHECK1-NEXT:       a4:       c0 f2 00 2c     movt    r12, #512
39// CHECK1-NEXT:       a8:       60 47   bx      r12
40// CHECK1: __Thumbv7ABSLongThunk_high_target2:
41// CHECK1-NEXT:       aa:       40 f2 d9 0c     movw    r12, #217
42// CHECK1-NEXT:       ae:       c0 f2 00 2c     movt    r12, #512
43// CHECK1-NEXT:       b2:       60 47   bx      r12
44// CHECK1: low_target2:
45// CHECK1-NEXT:       b4:       ff f7 f4 ff     bl      #-24
46// CHECK1-NEXT:       b8:       ff f7 f7 ff     bl      #-18
47
48 .section .text_high, "ax", %progbits
49 .thumb
50 .globl high_target
51 .type high_target, %function
52high_target:
53 bl low_target
54 bl low_target2
55
56 .section .text_high2, "ax", %progbits
57 .thumb
58 .globl high_target2
59 .type high_target2, %function
60high_target2:
61 bl low_target
62 bl low_target2
63
64// CHECK2: high_target:
65// CHECK2-NEXT:  20000bc:       00 f0 02 f8     bl      #4
66// CHECK2-NEXT:  20000c0:       00 f0 05 f8     bl      #10
67// CHECK2: __Thumbv7ABSLongThunk_low_target:
68// CHECK2-NEXT:  20000c4:       40 f2 97 0c     movw    r12, #151
69// CHECK2-NEXT:  20000c8:       c0 f2 00 0c     movt    r12, #0
70// CHECK2-NEXT:  20000cc:       60 47   bx      r12
71// CHECK2: __Thumbv7ABSLongThunk_low_target2:
72// CHECK2-NEXT:  20000ce:       40 f2 b5 0c     movw    r12, #181
73// CHECK2-NEXT:  20000d2:       c0 f2 00 0c     movt    r12, #0
74// CHECK2-NEXT:  20000d6:       60 47   bx      r12
75// CHECK2: high_target2:
76// CHECK2-NEXT:  20000d8:       ff f7 f4 ff     bl      #-24
77// CHECK2-NEXT:  20000dc:       ff f7 f7 ff     bl      #-18
78