[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / aarch64-ifunc-bti.s
blobd1794518cf5885cf9c8a49da767708f6a0008f6a
1 # REQUIRES: aarch64
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
14 # we must use bti c.
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
23 # CHECK-NEXT: br x17
24 # CHECK-NEXT: nop
25 # CHECK-NEXT: nop
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
30 # CHECK-NEXT: br x17
31 # CHECK-NEXT: nop
32 # CHECK-NEXT: nop
33 # CHECK-EMPTY:
34 # CHECK: Disassembly of section .iplt:
35 # CHECK-EMPTY:
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
43 # CHECK-NEXT: br x17
44 # CHECK-NEXT: nop
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
49 # CHECK-NEXT: br x17
50 # CHECK-NEXT: nop
52 ## The address of ifunc2 (STT_FUNC) escapes, so it must have `bti c`.
53 # SHARED: <ifunc2>:
54 # SHARED-NEXT: bti c
56 # SHARED: nop
57 # SHARED-NEXT: bti c
59 .section ".note.gnu.property", "a"
60 .long 4
61 .long 0x10
62 .long 0x5
63 .asciz "GNU"
65 .long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
66 .long 4
67 .long 1 // GNU_PROPERTY_AARCH64_FEATURE_1_BTI
68 .long 0
70 .text
71 .globl ifunc1
72 .type ifunc1,@gnu_indirect_function
73 ifunc1:
74 ret
76 .globl ifunc2
77 .type ifunc2,@gnu_indirect_function
78 ifunc2:
79 ret
81 .globl func1
83 .text
84 .globl _start
85 .type _start, %function
86 _start:
87 bl func1
88 bl ifunc1
89 adrp x8, ifunc2
90 add x8, x8, :lo12:ifunc2
91 ret