150
|
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-btipac1.s -o %t1.o
|
|
4 # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3.s -o %t3.o
|
|
5 # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3-btipac.s -o %t3btipac.o
|
|
6
|
|
7 ## Build shared library with all inputs having BTI and PAC, expect PLT
|
|
8 ## entries supporting both PAC and BTI. For a shared library this means:
|
|
9 ## PLT[0] has bti c at start
|
|
10 ## PLT[n] has autia1716 before br x17
|
|
11
|
|
12 # RUN: ld.lld %t1.o %t3btipac.o --shared --soname=t.so -o %t.so
|
|
13 # RUN: llvm-readelf -n %t.so | FileCheck --check-prefix BTIPACPROP %s
|
173
|
14 # RUN: llvm-objdump -d --mattr=+v8.5a --no-show-raw-insn %t.so | FileCheck --check-prefix BTIPACSO %s
|
150
|
15 # RUN: llvm-readelf --dynamic-table %t.so | FileCheck --check-prefix BTIPACDYN %s
|
|
16
|
|
17 # BTIPACSO: Disassembly of section .text:
|
173
|
18 # BTIPACSO: 0000000000010348 <func2>:
|
|
19 # BTIPACSO-NEXT: 10348: bl 0x10380 <func3@plt>
|
150
|
20 # BTIPACSO-NEXT: ret
|
173
|
21 # BTIPACSO: 0000000000010350 <func3>:
|
150
|
22 # BTIPACSO-NEXT: 10350: ret
|
|
23 # BTIPACSO: Disassembly of section .plt:
|
173
|
24 # BTIPACSO: 0000000000010360 <.plt>:
|
150
|
25 # BTIPACSO-NEXT: 10360: bti c
|
|
26 # BTIPACSO-NEXT: stp x16, x30, [sp, #-16]!
|
|
27 # BTIPACSO-NEXT: adrp x16, #131072
|
173
|
28 # BTIPACSO-NEXT: ldr x17, [x16, #1136]
|
|
29 # BTIPACSO-NEXT: add x16, x16, #1136
|
150
|
30 # BTIPACSO-NEXT: br x17
|
|
31 # BTIPACSO-NEXT: nop
|
|
32 # BTIPACSO-NEXT: nop
|
173
|
33 # BTIPACSO: 0000000000010380 <func3@plt>:
|
150
|
34 # BTIPACSO-NEXT: 10380: adrp x16, #131072
|
173
|
35 # BTIPACSO-NEXT: ldr x17, [x16, #1144]
|
|
36 # BTIPACSO-NEXT: add x16, x16, #1144
|
150
|
37 # BTIPACSO-NEXT: br x17
|
|
38
|
|
39 # BTIPACPROP: Properties: aarch64 feature: BTI, PAC
|
|
40
|
|
41 # BTIPACDYN: 0x0000000070000001 (AARCH64_BTI_PLT)
|
173
|
42 # BTIPACDYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT)
|
150
|
43
|
|
44 ## Make an executable with both BTI and PAC properties. Expect:
|
|
45 ## PLT[0] bti c as first instruction
|
173
|
46 ## PLT[n] bti n as first instruction
|
150
|
47
|
|
48 # RUN: ld.lld %t.o %t3btipac.o %t.so -o %t.exe
|
|
49 # RUN: llvm-readelf -n %t.exe | FileCheck --check-prefix=BTIPACPROP %s
|
173
|
50 # RUN: llvm-objdump -d --mattr=+v8.5a --no-show-raw-insn %t.exe | FileCheck --check-prefix BTIPACEX %s
|
|
51 # RUN: llvm-readelf --dynamic-table %t.exe | FileCheck --check-prefix BTIPACDYNEX %s
|
150
|
52
|
|
53 # BTIPACEX: Disassembly of section .text:
|
173
|
54 # BTIPACEX: 0000000000210370 <func1>:
|
|
55 # BTIPACEX-NEXT: 210370: bl 0x2103a0 <func2@plt>
|
150
|
56 # BTIPACEX-NEXT: ret
|
|
57 # BTIPACEX-NEXT: ret
|
173
|
58 # BTIPACEX: 000000000021037c <func3>:
|
150
|
59 # BTIPACEX-NEXT: 21037c: ret
|
|
60 # BTIPACEX: Disassembly of section .plt:
|
173
|
61 # BTIPACEX: 0000000000210380 <.plt>:
|
150
|
62 # BTIPACEX-NEXT: 210380: bti c
|
|
63 # BTIPACEX-NEXT: stp x16, x30, [sp, #-16]!
|
|
64 # BTIPACEX-NEXT: adrp x16, #131072
|
173
|
65 # BTIPACEX-NEXT: ldr x17, [x16, #1192]
|
|
66 # BTIPACEX-NEXT: add x16, x16, #1192
|
150
|
67 # BTIPACEX-NEXT: br x17
|
|
68 # BTIPACEX-NEXT: nop
|
|
69 # BTIPACEX-NEXT: nop
|
173
|
70 # BTIPACEX: 00000000002103a0 <func2@plt>:
|
150
|
71 # BTIPACEX-NEXT: 2103a0: bti c
|
|
72 # BTIPACEX-NEXT: adrp x16, #131072
|
173
|
73 # BTIPACEX-NEXT: ldr x17, [x16, #1200]
|
|
74 # BTIPACEX-NEXT: add x16, x16, #1200
|
150
|
75 # BTIPACEX-NEXT: br x17
|
|
76
|
173
|
77 # BTIPACDYNEX: 0x0000000070000001 (AARCH64_BTI_PLT)
|
|
78 # BTIPACDYNEX-NOT: 0x0000000070000003 (AARCH64_PAC_PLT)
|
|
79
|
150
|
80 ## Check that combinations of BTI+PAC with 0 properties results in standard PLT
|
|
81
|
|
82 # RUN: ld.lld %t.o %t3.o %t.so -o %t.exe
|
173
|
83 # RUN: llvm-objdump -d --mattr=+v8.5a --no-show-raw-insn %t.exe | FileCheck --check-prefix EX %s
|
150
|
84 # RUN: llvm-readelf --dynamic-table %t.exe | FileCheck --check-prefix=NODYN %s
|
|
85
|
|
86 # EX: Disassembly of section .text:
|
173
|
87 # EX: 00000000002102e0 <func1>:
|
|
88 # EX-NEXT: 2102e0: bl 0x210310 <func2@plt>
|
150
|
89 # EX-NEXT: ret
|
|
90 # EX-NEXT: ret
|
173
|
91 # EX: 00000000002102ec <func3>:
|
150
|
92 # EX-NEXT: 2102ec: ret
|
|
93 # EX: Disassembly of section .plt:
|
173
|
94 # EX: 00000000002102f0 <.plt>:
|
150
|
95 # EX-NEXT: 2102f0: stp x16, x30, [sp, #-16]!
|
|
96 # EX-NEXT: adrp x16, #131072
|
|
97 # EX-NEXT: ldr x17, [x16, #1024]
|
|
98 # EX-NEXT: add x16, x16, #1024
|
|
99 # EX-NEXT: br x17
|
|
100 # EX-NEXT: nop
|
|
101 # EX-NEXT: nop
|
|
102 # EX-NEXT: nop
|
173
|
103 # EX: 0000000000210310 <func2@plt>:
|
150
|
104 # EX: 210310: adrp x16, #131072
|
|
105 # EX-NEXT: ldr x17, [x16, #1032]
|
|
106 # EX-NEXT: add x16, x16, #1032
|
|
107 # EX-NEXT: br x17
|
|
108
|
|
109 # NODYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT)
|
|
110 # NODYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT)
|
|
111
|
|
112 ## Check that combination of -z pac-plt and -z force-bti warns for the file that
|
|
113 ## doesn't contain the BTI property, but generates PAC and BTI PLT sequences.
|
|
114 ## The -z pac-plt doesn't warn as it is not required for correctness.
|
173
|
115 ## Expect:
|
|
116 ## PLT[0] bti c as first instruction
|
|
117 ## PLT[n] bti n as first instruction, autia1716 before br x17
|
150
|
118
|
|
119 # RUN: ld.lld %t.o %t3.o %t.so -z pac-plt -z force-bti -o %t.exe 2>&1 | FileCheck --check-prefix=FORCE-WARN %s
|
|
120
|
173
|
121 # FORCE-WARN: aarch64-feature-btipac.s.tmp3.o: -z force-bti: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_BTI property
|
150
|
122
|
|
123 # RUN: llvm-readelf -n %t.exe | FileCheck --check-prefix=BTIPACPROP %s
|
173
|
124 # RUN: llvm-objdump -d --mattr=+v8.5a --no-show-raw-insn %t.exe | FileCheck --check-prefix BTIPACEX2 %s
|
|
125 # RUN: llvm-readelf --dynamic-table %t.exe | FileCheck --check-prefix BTIPACDYN2 %s
|
150
|
126 .section ".note.gnu.property", "a"
|
|
127 .long 4
|
|
128 .long 0x10
|
|
129 .long 0x5
|
|
130 .asciz "GNU"
|
|
131
|
|
132 .long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
|
|
133 .long 4
|
|
134 .long 3 // GNU_PROPERTY_AARCH64_FEATURE_1_BTI and PAC
|
|
135 .long 0
|
|
136
|
|
137 .text
|
|
138 .globl _start
|
|
139 .type func1,%function
|
|
140 func1:
|
|
141 bl func2
|
|
142 ret
|
|
143 .globl func3
|
|
144 .type func3,%function
|
|
145 ret
|
173
|
146
|
|
147 # BTIPACEX2: Disassembly of section .text:
|
|
148 # BTIPACEX2: 0000000000210370 <func1>:
|
|
149 # BTIPACEX2-NEXT: 210370: bl 0x2103a0 <func2@plt>
|
|
150 # BTIPACEX2-NEXT: ret
|
|
151 # BTIPACEX2-NEXT: ret
|
|
152 # BTIPACEX2: 000000000021037c <func3>:
|
|
153 # BTIPACEX2-NEXT: 21037c: ret
|
|
154 # BTIPACEX2: Disassembly of section .plt:
|
|
155 # BTIPACEX2: 0000000000210380 <.plt>:
|
|
156 # BTIPACEX2-NEXT: 210380: bti c
|
|
157 # BTIPACEX2-NEXT: stp x16, x30, [sp, #-16]!
|
|
158 # BTIPACEX2-NEXT: adrp x16, #131072
|
|
159 # BTIPACEX2-NEXT: ldr x17, [x16, #1208]
|
|
160 # BTIPACEX2-NEXT: add x16, x16, #1208
|
|
161 # BTIPACEX2-NEXT: br x17
|
|
162 # BTIPACEX2-NEXT: nop
|
|
163 # BTIPACEX2-NEXT: nop
|
|
164 # BTIPACEX2: 00000000002103a0 <func2@plt>:
|
|
165 # BTIPACEX2-NEXT: 2103a0: bti c
|
|
166 # BTIPACEX2-NEXT: adrp x16, #131072
|
|
167 # BTIPACEX2-NEXT: ldr x17, [x16, #1216]
|
|
168 # BTIPACEX2-NEXT: add x16, x16, #1216
|
|
169 # BTIPACEX2-NEXT: autia1716
|
|
170 # BTIPACEX2-NEXT: br x17
|
|
171
|
|
172 # BTIPACDYN2: 0x0000000070000001 (AARCH64_BTI_PLT)
|
|
173 # BTIPACDYN2-NEXT: 0x0000000070000003 (AARCH64_PAC_PLT) |