1# REQUIRES: aarch64 2# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o 3# RUN: ld.lld -shared %t.o -o %tout 4# RUN: llvm-objdump -D --no-show-raw-insn %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 in a shared object 8# we get R_AARCH64_GLOB_DAT to the symbol as it could be defined in another 9# link unit and preempt our definition. 10.text 11.globl myfunc 12.type myfunc,@gnu_indirect_function 13myfunc: 14 ret 15 16.text 17.globl main 18.type main,@function 19main: 20 adrp x8, :got:myfunc 21 ldr x8, [x8, :got_lo12:myfunc] 22 ret 23# CHECK: 0000000000010284 <main>: 24## myfunc's got entry = page(0x20330)-page(0x10284) + 0x330 = 65536 + 816 25# CHECK-NEXT: 10284: adrp x8, #65536 26# CHECK-NEXT: 10288: ldr x8, [x8, #816] 27# CHECK-NEXT: 1028c: ret 28 29# CHECK: Disassembly of section .got: 30# CHECK-EMPTY: 31# CHECK-NEXT: 0000000000020330 <.got>: 32 33# CHECK-RELOCS: Relocations [ 34# CHECK-RELOCS-NEXT: Section {{.*}} .rela.dyn { 35# CHECK-RELOCS-NEXT: 0x20330 R_AARCH64_GLOB_DAT myfunc 0x0 36# CHECK-RELOCS-NEXT: } 37# CHECK-RELOCS-NEXT: ] 38