2019-06-07 21:00:17 +08:00
|
|
|
# REQUIRES: aarch64
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o
|
2019-06-11 05:39:11 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %p/Inputs/aarch64-addrifunc.s -o %t1.o
|
2019-06-07 21:00:17 +08:00
|
|
|
|
2019-08-20 16:34:56 +08:00
|
|
|
# RUN: ld.lld --shared --soname=t1.so %t1.o -o %t1.so
|
2019-06-11 05:39:11 +08:00
|
|
|
# RUN: ld.lld --pie %t1.so %t.o -o %t
|
2020-03-16 08:47:44 +08:00
|
|
|
# RUN: llvm-objdump -d --no-show-raw-insn --mattr=+bti --triple=aarch64-linux-gnu %t | FileCheck %s
|
2019-06-07 21:00:17 +08:00
|
|
|
|
|
|
|
# When the address of an ifunc is taken using a non-got reference which clang
|
|
|
|
# can do, LLD exports a canonical PLT entry that may have its address taken so
|
|
|
|
# we must use bti c.
|
|
|
|
|
|
|
|
# CHECK: Disassembly of section .plt:
|
2020-03-06 06:18:38 +08:00
|
|
|
# CHECK: 0000000000010380 <.plt>:
|
2019-12-03 02:34:56 +08:00
|
|
|
# CHECK-NEXT: 10380: bti c
|
|
|
|
# CHECK-NEXT: stp x16, x30, [sp, #-16]!
|
|
|
|
# CHECK-NEXT: adrp x16, #131072
|
2020-06-02 01:17:48 +08:00
|
|
|
# CHECK-NEXT: ldr x17, [x16, #1288]
|
|
|
|
# CHECK-NEXT: add x16, x16, #1288
|
2019-12-03 02:34:56 +08:00
|
|
|
# CHECK-NEXT: br x17
|
|
|
|
# CHECK-NEXT: nop
|
|
|
|
# CHECK-NEXT: nop
|
2020-03-06 06:18:38 +08:00
|
|
|
# CHECK: 00000000000103a0 <func1@plt>:
|
2019-12-03 02:34:56 +08:00
|
|
|
# CHECK-NEXT: 103a0: bti c
|
|
|
|
# CHECK-NEXT: adrp x16, #131072
|
2020-06-02 01:17:48 +08:00
|
|
|
# CHECK-NEXT: ldr x17, [x16, #1296]
|
|
|
|
# CHECK-NEXT: add x16, x16, #1296
|
2019-12-03 02:34:56 +08:00
|
|
|
# CHECK-NEXT: br x17
|
|
|
|
# CHECK-NEXT: nop
|
2019-12-15 08:19:03 +08:00
|
|
|
# CHECK-EMPTY:
|
|
|
|
# CHECK: Disassembly of section .iplt:
|
|
|
|
# CHECK-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
# CHECK-NEXT: 00000000000103c0 <myfunc>:
|
2019-12-03 02:34:56 +08:00
|
|
|
# CHECK-NEXT: 103c0: bti c
|
|
|
|
# CHECK-NEXT: adrp x16, #131072
|
2020-06-02 01:17:48 +08:00
|
|
|
# CHECK-NEXT: ldr x17, [x16, #1304]
|
|
|
|
# CHECK-NEXT: add x16, x16, #1304
|
2019-12-03 02:34:56 +08:00
|
|
|
# CHECK-NEXT: br x17
|
|
|
|
# CHECK-NEXT: nop
|
2019-06-07 21:00:17 +08:00
|
|
|
|
|
|
|
.section ".note.gnu.property", "a"
|
|
|
|
.long 4
|
|
|
|
.long 0x10
|
|
|
|
.long 0x5
|
|
|
|
.asciz "GNU"
|
|
|
|
|
|
|
|
.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
|
|
|
|
.long 4
|
|
|
|
.long 1 // GNU_PROPERTY_AARCH64_FEATURE_1_BTI
|
|
|
|
.long 0
|
|
|
|
|
|
|
|
.text
|
|
|
|
.globl myfunc
|
|
|
|
.type myfunc,@gnu_indirect_function
|
|
|
|
myfunc:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.globl func1
|
|
|
|
|
|
|
|
.text
|
|
|
|
.globl _start
|
|
|
|
.type _start, %function
|
|
|
|
_start:
|
|
|
|
bl func1
|
|
|
|
adrp x8, myfunc
|
|
|
|
add x8, x8, :lo12:myfunc
|
|
|
|
ret
|