2 // RUN
: split-file
%s
%t
3 // RUN
: llvm-mc
-filetype
=obj
-triple
=aarch64
%t/asm
-o
%t.o
4 // RUN
: ld.lld
--script
%t/lds
--shared
%t.o
-o
%t.so
2>&1
5 // RUN
: llvm-objdump
-d
--no-show-raw-insn
--print-imm-hex
%t.so | FileCheck
%s
7 // Check that Position Independent thunks are generated for shared libraries.
10 .section .text_low, "ax", %progbits
12 .type low_target, %function
14 // Need thunk to high_target@plt
17 // CHECK
: <low_target
>:
18 // CHECK-NEXT
: 0: bl 0x14 <__AArch64ADRPThunk_high_target
>
23 .type low_target2, %function
25 // Need thunk to high_target2
27 // .text_high+8 = high_target2
30 // CHECK
: <low_target2
>:
31 // CHECK-NEXT
: 8: bl 0x20 <__AArch64ADRPThunk_high_target2
>
32 // CHECK-NEXT
: c
: bl 0x2c <__AArch64ADRPThunk_
>
35 // Expect range extension thunks for
.text_low
36 // adrp calculation is
(PC
+ signed immediate
) & (!0xfff)
37 // CHECK
: <__AArch64ADRPThunk_high_target
>:
38 // CHECK-NEXT
: 14: adrp x16
, 0x10000000
39 // CHECK-NEXT
: add x16
, x16
, #0x50
41 // CHECK
: <__AArch64ADRPThunk_high_target2
>:
42 // CHECK-NEXT
: 20: adrp x16
, 0x10000000
43 // CHECK-NEXT
: add x16
, x16
, #0x8
45 /// Identical to the previous one
, but for the target
.text_high+8.
46 // CHECK
: <__AArch64ADRPThunk_
>:
47 // CHECK-NEXT
: 2c
: adrp x16
, 0x10000000
48 // CHECK-NEXT
: add x16
, x16
, #0x8
52 .section .text_high, "ax", %progbits
54 .type high_target, %function
56 // No thunk needed as we can reach low_target@plt
59 // CHECK
: <high_target
>:
60 // CHECK-NEXT
: 10000000: bl 0x10000040 <low_target@plt
>
65 .type high_target2, %function
67 // Need thunk to low_target
70 // CHECK
: <high_target2
>:
71 // CHECK-NEXT
: 10000008: bl 0x10000010 <__AArch64ADRPThunk_low_target2
>
74 // Expect Thunk for
.text.high
76 // CHECK
: <__AArch64ADRPThunk_low_target2
>:
77 // CHECK-NEXT
: 10000010: adrp x16
, 0x0
78 // CHECK-NEXT
: add x16
, x16
, #0x8
81 // CHECK
: Disassembly of section
.plt:
83 // CHECK-NEXT
: <.plt>:
84 // CHECK-NEXT
: 10000020: stp x16
, x30
, [sp
, #-0x10]!
85 // CHECK-NEXT
: adrp x16
, 0x10000000
86 // CHECK-NEXT
: ldr x17
, [x16
, #0x1f8]
87 // CHECK-NEXT
: add x16
, x16
, #0x1f8
93 // CHECK-NEXT
: <low_target@plt
>:
94 // CHECK-NEXT
: 10000040: adrp x16
, 0x10000000
95 // CHECK-NEXT
: ldr x17
, [x16
, #0x200]
96 // CHECK-NEXT
: add x16
, x16
, #0x200
99 // CHECK-NEXT
: <high_target@plt
>:
100 // CHECK-NEXT
: 10000050: adrp x16
, 0x10000000
101 // CHECK-NEXT
: ldr x17
, [x16
, #0x208]
102 // CHECK-NEXT
: add x16
, x16
, #0x208
103 // CHECK-NEXT
: br x17
107 low PT_LOAD FLAGS
(0x1 |
0x4);
108 high PT_LOAD FLAGS
(0x1 |
0x4);
111 .text_low : { *(.text_low) } :low
112 .text_high 0x10000000 : { *(.text_high) } :high