|
| 1 | +# REQUIRES: aarch64 |
| 2 | +# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o |
| 3 | +# RUN: ld.lld -pie %t.o -o %tout |
| 4 | +# RUN: llvm-objdump -D %tout | FileCheck %s |
| 5 | +# RUN: llvm-readobj -r %tout | FileCheck %s -check-prefix=CHECK-RELOCS |
| 6 | + |
| 7 | +# Test that when we take the address of a preemptible ifunc using -fpie, we can |
| 8 | +# handle the case when the ifunc is in the same translation unit as the address |
| 9 | +# taker. In this case the compiler knows that ifunc is not defined in a shared |
| 10 | +# library so it can use a non got generating relative reference. |
| 11 | +.text |
| 12 | +.globl myfunc |
| 13 | +.type myfunc,@gnu_indirect_function |
| 14 | +myfunc: |
| 15 | + ret |
| 16 | + |
| 17 | +.text |
| 18 | +.globl main |
| 19 | +.type main,@function |
| 20 | +main: |
| 21 | + adrp x8, myfunc |
| 22 | + add x8, x8, :lo12: myfunc |
| 23 | + ret |
| 24 | + |
| 25 | +# CHECK: 0000000000010000 myfunc: |
| 26 | +# CHECK-NEXT: 10000: c0 03 5f d6 ret |
| 27 | +# CHECK: 0000000000010004 main: |
| 28 | +# CHECK-NEXT: 10004: 08 00 00 90 adrp x8, #0 |
| 29 | +# x8 = 0x10000 |
| 30 | +# CHECK-NEXT: 10008: 08 41 00 91 add x8, x8, #16 |
| 31 | +# x8 = 0x10010 = .plt for myfunc |
| 32 | +# CHECK-NEXT: 1000c: c0 03 5f d6 ret |
| 33 | +# CHECK-NEXT: Disassembly of section .plt: |
| 34 | +# CHECK-NEXT: 0000000000010010 .plt: |
| 35 | +# CHECK-NEXT: 10010: 90 00 00 90 adrp x16, #65536 |
| 36 | +# CHECK-NEXT: 10014: 11 02 40 f9 ldr x17, [x16] |
| 37 | +# CHECK-NEXT: 10018: 10 02 00 91 add x16, x16, #0 |
| 38 | +# CHECK-NEXT: 1001c: 20 02 1f d6 br x17 |
| 39 | + |
| 40 | +# CHECK-RELOCS: Relocations [ |
| 41 | +# CHECK-RELOCS-NEXT: Section {{.*}} .rela.plt { |
| 42 | +# CHECK-RELOCS-NEXT: 0x20000 R_AARCH64_IRELATIVE - 0x10000 |
| 43 | +# CHECK-RELOCS-NEXT: } |
| 44 | +# CHECK-RELOCS-NEXT: ] |
0 commit comments