[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / aarch64-feature-pac.s
blob4fd1fd2acea7378695964d87ba2562265a9b360a
1 # REQUIRES: aarch64
2 # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t.o
3 # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-pac1.s -o %t1.o
4 # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3.s -o %t2.o
5 # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3-pac.s -o %t3.o
6 # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func2.s -o %tno.o
8 ## We do not add PAC support when the inputs don't have the .note.gnu.property
9 ## field.
11 # RUN: ld.lld %tno.o %t3.o --shared -o %tno.so
12 # RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tno.so | FileCheck --check-prefix=NOPAC %s
13 # RUN: llvm-readelf -x .got.plt %tno.so | FileCheck --check-prefix SOGOTPLT %s
14 # RUN: llvm-readelf --dynamic-table %tno.so | FileCheck --check-prefix NOPACDYN %s
16 # NOPAC: 00000000000102b8 <func2>:
17 # NOPAC-NEXT: 102b8: bl 0x102f0 <func3@plt>
18 # NOPAC-NEXT: ret
19 # NOPAC: Disassembly of section .plt:
20 # NOPAC: 00000000000102d0 <.plt>:
21 # NOPAC-NEXT: 102d0: stp x16, x30, [sp, #-16]!
22 # NOPAC-NEXT: adrp x16, 0x30000
23 # NOPAC-NEXT: ldr x17, [x16, #960]
24 # NOPAC-NEXT: add x16, x16, #960
25 # NOPAC-NEXT: br x17
26 # NOPAC-NEXT: nop
27 # NOPAC-NEXT: nop
28 # NOPAC-NEXT: nop
29 # NOPAC: 00000000000102f0 <func3@plt>:
30 # NOPAC-NEXT: 102f0: adrp x16, 0x30000
31 # NOPAC-NEXT: ldr x17, [x16, #968]
32 # NOPAC-NEXT: add x16, x16, #968
33 # NOPAC-NEXT: br x17
35 # SOGOTPLT: Hex dump of section '.got.plt':
36 # SOGOTPLT-NEXT: 0x000303b0 00000000 00000000 00000000 00000000
37 # SOGOTPLT-NEXT: 0x000303c0 00000000 00000000 d0020100 00000000
39 # NOPACDYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT)
40 # NOPACDYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT)
42 # RUN: ld.lld %t1.o %t3.o --shared --soname=t.so -o %t.so
43 # RUN: llvm-readelf -n %t.so | FileCheck --check-prefix PACPROP %s
44 # RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %t.so | FileCheck --check-prefix PACSO %s
45 # RUN: llvm-readelf -x .got.plt %t.so | FileCheck --check-prefix SOGOTPLT2 %s
46 # RUN: llvm-readelf --dynamic-table %t.so | FileCheck --check-prefix PACDYN %s
48 ## PAC has no effect on PLT[0], for PLT[N].
49 # PACSO: 0000000000010348 <func2>:
50 # PACSO-NEXT: 10348: bl 0x10380 <func3@plt>
51 # PACSO-NEXT: ret
52 # PACSO: 0000000000010350 <func3>:
53 # PACSO-NEXT: 10350: ret
54 # PACSO: Disassembly of section .plt:
55 # PACSO: 0000000000010360 <.plt>:
56 # PACSO-NEXT: 10360: stp x16, x30, [sp, #-16]!
57 # PACSO-NEXT: adrp x16, 0x30000
58 # PACSO-NEXT: ldr x17, [x16, #1120]
59 # PACSO-NEXT: add x16, x16, #1120
60 # PACSO-NEXT: br x17
61 # PACSO-NEXT: nop
62 # PACSO-NEXT: nop
63 # PACSO-NEXT: nop
64 # PACSO: 0000000000010380 <func3@plt>:
65 # PACSO-NEXT: 10380: adrp x16, 0x30000
66 # PACSO-NEXT: ldr x17, [x16, #1128]
67 # PACSO-NEXT: add x16, x16, #1128
68 # PACSO-NEXT: br x17
70 # SOGOTPLT2: Hex dump of section '.got.plt':
71 # SOGOTPLT2-NEXT: 0x00030450 00000000 00000000 00000000 00000000
72 # SOGOTPLT2-NEXT: 0x00030460 00000000 00000000 60030100 00000000
74 # PACPROP: Properties: aarch64 feature: PAC
76 # PACDYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT)
77 # PACDYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT)
79 ## Turn on PAC entries with the -z pac-plt command line option. For files w/o
80 ## GNU_PROPERTY_AARCH64_FEATURE_1_PAC set in GNU_PROPERTY_AARCH64_FEATURE_1_AND
81 ## property, emit a warning.
83 # RUN: ld.lld %t.o %t2.o -z pac-plt %t.so -o %tpacplt.exe 2>&1 | FileCheck -DFILE=%t2.o --check-prefix WARN %s
85 # WARN: warning: [[FILE]]: -z pac-plt: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_PAC property and no valid PAuth core info present for this link job
87 # RUN: llvm-readelf -n %tpacplt.exe | FileCheck --check-prefix=PACPROP %s
88 # RUN: llvm-readelf --dynamic-table %tpacplt.exe | FileCheck --check-prefix PACDYN2 %s
89 # RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tpacplt.exe | FileCheck --check-prefix PACPLT %s
91 # PACPLT: Disassembly of section .text:
92 # PACPLT: 0000000000210370 <func1>:
93 # PACPLT-NEXT: 210370: bl 0x2103a0 <func2@plt>
94 # PACPLT-NEXT: ret
95 # PACPLT: 0000000000210378 <func3>:
96 # PACPLT-NEXT: 210378: ret
97 # PACPLT: Disassembly of section .plt:
98 # PACPLT: 0000000000210380 <.plt>:
99 # PACPLT-NEXT: 210380: stp x16, x30, [sp, #-16]!
100 # PACPLT-NEXT: adrp x16, 0x230000
101 # PACPLT-NEXT: ldr x17, [x16, #1192]
102 # PACPLT-NEXT: add x16, x16, #1192
103 # PACPLT-NEXT: br x17
104 # PACPLT-NEXT: nop
105 # PACPLT-NEXT: nop
106 # PACPLT-NEXT: nop
107 # PACPLT: 00000000002103a0 <func2@plt>:
108 # PACPLT-NEXT: 2103a0: adrp x16, 0x230000
109 # PACPLT-NEXT: ldr x17, [x16, #1200]
110 # PACPLT-NEXT: add x16, x16, #1200
111 # PACPLT-NEXT: autia1716
112 # PACPLT-NEXT: br x17
113 # PACPLT-NEXT: nop
115 # PACDYN2-NOT: 0x0000000070000001 (AARCH64_BTI_PLT)
116 # PACDYN2: 0x0000000070000003 (AARCH64_PAC_PLT)
118 .section ".note.gnu.property", "a"
119 .long 4
120 .long 0x10
121 .long 0x5
122 .asciz "GNU"
124 .long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
125 .long 4
126 .long 2 // GNU_PROPERTY_AARCH64_FEATURE_1_PAC
127 .long 0
129 .text
130 .globl _start
131 .type func1,%function
132 func1:
133 bl func2