114 lines · plain
1// REQUIRES: aarch642// RUN: split-file %s %t3// RUN: llvm-mc -filetype=obj -triple=aarch64 %t/asm -o %t.o4// RUN: ld.lld --script %t/lds --shared %t.o -o %t.so 2>&15// RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t.so | FileCheck %s6 7// Check that Position Independent thunks are generated for shared libraries.8 9//--- asm10 .section .text_low, "ax", %progbits11 .globl low_target12 .type low_target, %function13low_target:14 // Need thunk to high_target@plt15 bl high_target16 ret17// CHECK: <low_target>:18// CHECK-NEXT: 0: bl 0x14 <__AArch64ADRPThunk_high_target>19// CHECK-NEXT: ret20 21 .hidden low_target222 .globl low_target223 .type low_target2, %function24low_target2:25 // Need thunk to high_target226 bl high_target227 // .text_high+8 = high_target228 bl .text_high+829 ret30// CHECK: <low_target2>:31// CHECK-NEXT: 8: bl 0x20 <__AArch64ADRPThunk_high_target2>32// CHECK-NEXT: c: bl 0x2c <__AArch64ADRPThunk_>33// CHECK-NEXT: ret34 35// Expect range extension thunks for .text_low36// adrp calculation is (PC + signed immediate) & (!0xfff)37// CHECK: <__AArch64ADRPThunk_high_target>:38// CHECK-NEXT: 14: adrp x16, 0x1000000039// CHECK-NEXT: add x16, x16, #0x5040// CHECK-NEXT: br x1641// CHECK: <__AArch64ADRPThunk_high_target2>:42// CHECK-NEXT: 20: adrp x16, 0x1000000043// CHECK-NEXT: add x16, x16, #0x844// CHECK-NEXT: br x1645/// Identical to the previous one, but for the target .text_high+8.46// CHECK: <__AArch64ADRPThunk_>:47// CHECK-NEXT: 2c: adrp x16, 0x1000000048// CHECK-NEXT: add x16, x16, #0x849// CHECK-NEXT: br x1650 51 52 .section .text_high, "ax", %progbits53 .globl high_target54 .type high_target, %function55high_target:56 // No thunk needed as we can reach low_target@plt57 bl low_target58 ret59// CHECK: <high_target>:60// CHECK-NEXT: 10000000: bl 0x10000040 <low_target@plt>61// CHECK-NEXT: ret62 63 .hidden high_target264 .globl high_target265 .type high_target2, %function66high_target2:67 // Need thunk to low_target68 bl low_target269 ret70// CHECK: <high_target2>:71// CHECK-NEXT: 10000008: bl 0x10000010 <__AArch64ADRPThunk_low_target2>72// CHECK-NEXT: ret73 74// Expect Thunk for .text.high75 76// CHECK: <__AArch64ADRPThunk_low_target2>:77// CHECK-NEXT: 10000010: adrp x16, 0x078// CHECK-NEXT: add x16, x16, #0x879// CHECK-NEXT: br x1680 81// CHECK: Disassembly of section .plt:82// CHECK-EMPTY:83// CHECK-NEXT: <.plt>:84// CHECK-NEXT: 10000020: stp x16, x30, [sp, #-0x10]!85// CHECK-NEXT: adrp x16, 0x1000000086// CHECK-NEXT: ldr x17, [x16, #0x1f8]87// CHECK-NEXT: add x16, x16, #0x1f888// CHECK-NEXT: br x1789// CHECK-NEXT: nop90// CHECK-NEXT: nop91// CHECK-NEXT: nop92// CHECK-EMPTY:93// CHECK-NEXT: <low_target@plt>:94// CHECK-NEXT: 10000040: adrp x16, 0x1000000095// CHECK-NEXT: ldr x17, [x16, #0x200]96// CHECK-NEXT: add x16, x16, #0x20097// CHECK-NEXT: br x1798// CHECK-EMPTY:99// CHECK-NEXT: <high_target@plt>:100// CHECK-NEXT: 10000050: adrp x16, 0x10000000101// CHECK-NEXT: ldr x17, [x16, #0x208]102// CHECK-NEXT: add x16, x16, #0x208103// CHECK-NEXT: br x17104 105//--- lds106PHDRS {107 low PT_LOAD FLAGS(0x1 | 0x4);108 high PT_LOAD FLAGS(0x1 | 0x4);109}110SECTIONS {111 .text_low : { *(.text_low) } :low112 .text_high 0x10000000 : { *(.text_high) } :high113}114