2 # RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o
3 # RUN: llvm-mc -filetype=obj -triple=aarch64 %p/Inputs/aarch64-addrifunc.s -o %t1.o
5 # RUN: ld.lld --shared --soname=t1.so %t1.o -o %t1.so
6 # RUN: ld.lld --pie %t1.so %t.o -o %t
7 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --mattr=+bti --triple=aarch64-linux-gnu %t | FileCheck %s
9 # RUN: ld.lld -shared -Bsymbolic %t1.so %t.o -o %t.so
10 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --mattr=+bti %t.so | FileCheck %s --check-prefix=SHARED
12 # When the address of an ifunc is taken using a non-got reference which clang
13 # can do, LLD exports a canonical PLT entry that may have its address taken so
16 # CHECK: Disassembly of section .plt:
17 # CHECK: 00000000000103a0 <.plt>:
18 # CHECK-NEXT: 103a0: bti c
19 # CHECK-NEXT: stp x16, x30, [sp, #-16]!
20 # CHECK-NEXT: adrp x16, 0x30000
21 # CHECK-NEXT: ldr x17, [x16, #1344]
22 # CHECK-NEXT: add x16, x16, #1344
26 # CHECK: 00000000000103c0 <func1@plt>:
27 # CHECK-NEXT: 103c0: adrp x16, 0x30000
28 # CHECK-NEXT: ldr x17, [x16, #1352]
29 # CHECK-NEXT: add x16, x16, #1352
34 # CHECK: Disassembly of section .iplt:
36 ## The address of ifunc1@plt does not escape so it does not need `bti c`,
37 ## but having bti is not wrong.
38 # CHECK-NEXT: 00000000000103e0 <ifunc2>:
39 # CHECK-NEXT: 103e0: bti c
40 # CHECK-NEXT: adrp x16, 0x30000
41 # CHECK-NEXT: ldr x17, [x16, #1360]
42 # CHECK-NEXT: add x16, x16, #1360
45 # CHECK-NEXT: 103f8: bti c
46 # CHECK-NEXT: adrp x16, 0x30000
47 # CHECK-NEXT: ldr x17, [x16, #1368]
48 # CHECK-NEXT: add x16, x16, #1368
52 ## The address of ifunc2 (STT_FUNC) escapes, so it must have `bti c`.
59 .section ".note.gnu.property", "a"
65 .long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
67 .long 1 // GNU_PROPERTY_AARCH64_FEATURE_1_BTI
72 .type ifunc1,@gnu_indirect_function
77 .type ifunc2,@gnu_indirect_function
85 .type _start, %function
90 add x8
, x8
, :lo12
:ifunc2