|
1 | 1 | # REQUIRES: aarch64
|
2 | 2 | # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t.o
|
3 | 3 | # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu --defsym CANONICAL_PLT=1 %s -o %tcanon.o
|
| 4 | +# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu --defsym RELVTABLE_PLT=1 %s -o %trelvtable.o |
4 | 5 | # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-bti1.s -o %t1.o
|
5 | 6 | # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3.s -o %t2.o
|
6 | 7 | # RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3-bti.s -o %t3.o
|
|
154 | 155 | # PIE-NEXT: nop
|
155 | 156 | # PIE-NEXT: nop
|
156 | 157 |
|
| 158 | +## We expect the same for R_AARCH64_PLT32, as the address of an plt entry escapes |
| 159 | +# RUN: ld.lld --shared %trelvtable.o -o %trelv.exe |
| 160 | +# RUN: llvm-readelf -n %trelv.exe | FileCheck --check-prefix=BTIPROP %s |
| 161 | +# RUN: llvm-readelf --dynamic-table -n %trelv.exe | FileCheck --check-prefix=BTIPROP %s |
| 162 | +# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+bti --no-show-raw-insn %trelv.exe | FileCheck --check-prefix=RELV %s |
| 163 | + |
| 164 | +# RELV: Disassembly of section .text: |
| 165 | +# RELV-LABEL: <func1>: |
| 166 | +# RELV-NEXT: 10380: bl 0x103b0 <func2@plt> |
| 167 | +# RELV-NEXT: bl 0x103c8 <funcRelVtable@plt> |
| 168 | +# RELV-NEXT: ret |
| 169 | +# RELV: Disassembly of section .plt: |
| 170 | +# RELV-LABEL: <.plt>: |
| 171 | +# RELV-NEXT: 10390: bti c |
| 172 | +# RELV-NEXT: stp x16, x30, [sp, #-16]! |
| 173 | +# RELV-NEXT: adrp x16, 0x30000 |
| 174 | +# RELV-NEXT: ldr x17, [x16, #1200] |
| 175 | +# RELV-NEXT: add x16, x16, #1200 |
| 176 | +# RELV-NEXT: br x17 |
| 177 | +# RELV-NEXT: nop |
| 178 | +# RELV-NEXT: nop |
| 179 | +# RELV-LABEL: <func2@plt>: |
| 180 | +# RELV-NEXT: 103b0: adrp x16, 0x30000 |
| 181 | +# RELV-NEXT: ldr x17, [x16, #1208] |
| 182 | +# RELV-NEXT: add x16, x16, #1208 |
| 183 | +# RELV-NEXT: br x17 |
| 184 | +# RELV-NEXT: nop |
| 185 | +# RELV-NEXT: nop |
| 186 | +# RELV-LABEL: <funcRelVtable@plt>: |
| 187 | +# RELV-NEXT: 103c8: bti c |
| 188 | +# RELV-NEXT: adrp x16, 0x30000 <_DYNAMIC+0xfc20> |
| 189 | +# RELV-NEXT: ldr x17, [x16, #1216] |
| 190 | +# RELV-NEXT: add x16, x16, #1216 |
| 191 | +# RELV-NEXT: br x17 |
| 192 | +# RELV-NEXT: nop |
| 193 | + |
157 | 194 | ## Build and executable with not all relocatable inputs having the BTI
|
158 | 195 | ## .note.property, expect no bti c and no .note.gnu.property entry
|
159 | 196 |
|
@@ -241,5 +278,13 @@ func1:
|
241 | 278 | add x0, x0, :lo12:func2
|
242 | 279 | .else
|
243 | 280 | bl func2
|
| 281 | +.endif |
| 282 | +.ifdef RELVTABLE_PLT |
| 283 | + bl funcRelVtable |
244 | 284 | .endif
|
245 | 285 | ret
|
| 286 | + |
| 287 | +.ifdef RELVTABLE_PLT |
| 288 | +// R_AARCH64_PLT32 |
| 289 | +.word funcRelVtable@PLT - . |
| 290 | +.endif |
0 commit comments