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 --pic-veneer --no-rosegment --script %t.script %t -o %t2
9// RUN: llvm-objdump -d --triple=thumbv7a-none-linux-gnueabi %t2 | FileCheck %s
10
11// Test that we can force generation of position independent thunks even when
12// inputs are not pic.
13
14 .syntax unified
15 .section .text_low, "ax", %progbits
16 .thumb
17 .globl _start
18_start: bx lr
19 .globl low_target
20 .type low_target, %function
21low_target:
22 bl high_target
23 bl high_target2
24
25 .section .text_low2, "ax", %progbits
26 .thumb
27 .globl low_target2
28 .type low_target2, %function
29low_target2:
30 bl high_target
31 bl high_target2
32
33// CHECK: Disassembly of section .text_low:
34// CHECK-EMPTY:
35// CHECK-NEXT: <_start>:
36// CHECK-NEXT:       94:        70 47   bx      lr
37// CHECK: <low_target>:
38// CHECK-NEXT:       96:        00 f0 03 f8     bl      #6
39// CHECK-NEXT:       9a:        00 f0 07 f8     bl      #14
40// CHECK-NEXT:       9e:        d4 d4   bmi     #-88
41// CHECK: <__ThumbV7PILongThunk_high_target>:
42// CHECK-NEXT:       a0:        4f f6 55 7c     movw    r12, #65365
43// CHECK-NEXT:       a4:        c0 f2 ff 1c     movt    r12, #511
44// CHECK-NEXT:       a8:        fc 44   add     r12, pc
45// CHECK-NEXT:       aa:        60 47   bx      r12
46// CHECK: <__ThumbV7PILongThunk_high_target2>:
47// CHECK-NEXT:       ac:        4f f6 69 7c     movw    r12, #65385
48// CHECK-NEXT:       b0:        c0 f2 ff 1c     movt    r12, #511
49// CHECK-NEXT:       b4:        fc 44   add     r12, pc
50// CHECK-NEXT:       b6:        60 47   bx      r12
51// CHECK: <low_target2>:
52// CHECK-NEXT:       b8:        ff f7 f2 ff     bl      #-28
53// CHECK-NEXT:       bc:        ff f7 f6 ff     bl      #-20
54
55
56 .section .text_high, "ax", %progbits
57 .thumb
58 .globl high_target
59 .type high_target, %function
60high_target:
61 bl low_target
62 bl low_target2
63
64 .section .text_high2, "ax", %progbits
65 .thumb
66 .globl high_target2
67 .type high_target2, %function
68high_target2:
69 bl low_target
70 bl low_target2
71
72// CHECK: Disassembly of section .text_high:
73// CHECK-EMPTY:
74// CHECK-NEXT: <high_target>:
75// CHECK-NEXT:  2000000:        00 f0 02 f8     bl      #4
76// CHECK-NEXT:  2000004:        00 f0 06 f8     bl      #12
77// CHECK: <__ThumbV7PILongThunk_low_target>:
78// CHECK-NEXT:  2000008:        40 f2 83 0c     movw    r12, #131
79// CHECK-NEXT:  200000c:        cf f6 00 6c     movt    r12, #65024
80// CHECK-NEXT:  2000010:        fc 44   add     r12, pc
81// CHECK-NEXT:  2000012:        60 47   bx      r12
82// CHECK: <__ThumbV7PILongThunk_low_target2>:
83// CHECK-NEXT:  2000014:        40 f2 99 0c     movw    r12, #153
84// CHECK-NEXT:  2000018:        cf f6 00 6c     movt    r12, #65024
85// CHECK-NEXT:  200001c:        fc 44   add     r12, pc
86// CHECK-NEXT:  200001e:        60 47   bx      r12
87// CHECK: <high_target2>:
88// CHECK-NEXT:  2000020:        ff f7 f2 ff     bl      #-28
89// CHECK-NEXT:  2000024:        ff f7 f6 ff     bl      #-20
90