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 7 8## We do not add PAC support when the inputs don't have the .note.gnu.property 9## field. 10 11# RUN: ld.lld %tno.o %t3.o --shared -o %tno.so 12# RUN: llvm-objdump -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 15 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, #131072 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, #131072 31# NOPAC-NEXT: ldr x17, [x16, #968] 32# NOPAC-NEXT: add x16, x16, #968 33# NOPAC-NEXT: br x17 34 35# SOGOTPLT: Hex dump of section '.got.plt': 36# SOGOTPLT-NEXT: 0x000303b0 00000000 00000000 00000000 00000000 37# SOGOTPLT-NEXT: 0x000303c0 00000000 00000000 d0020100 00000000 38 39# NOPACDYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT) 40# NOPACDYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT) 41 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 -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 47 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, #131072 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, #131072 66# PACSO-NEXT: ldr x17, [x16, #1128] 67# PACSO-NEXT: add x16, x16, #1128 68# PACSO-NEXT: br x17 69 70# SOGOTPLT2: Hex dump of section '.got.plt': 71# SOGOTPLT2-NEXT: 0x00030450 00000000 00000000 00000000 00000000 72# SOGOTPLT2-NEXT: 0x00030460 00000000 00000000 60030100 00000000 73 74# PACPROP: Properties: aarch64 feature: PAC 75 76# PACDYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT) 77# PACDYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT) 78 79## Turn on PAC entries with the -z pac-plt command line option. There are no 80## warnings in this case as the choice to use PAC in PLT entries is orthogonal 81## to the choice of using PAC in relocatable objects. The presence of the PAC 82## .note.gnu.property is an indication of preference by the relocatable object. 83 84# RUN: ld.lld %t.o %t2.o -z pac-plt %t.so -o %tpacplt.exe 85# RUN: llvm-readelf -n %tpacplt.exe | FileCheck --check-prefix=PACPROP %s 86# RUN: llvm-readelf --dynamic-table %tpacplt.exe | FileCheck --check-prefix PACDYN2 %s 87# RUN: llvm-objdump -d --mattr=+v8.3a --no-show-raw-insn %tpacplt.exe | FileCheck --check-prefix PACPLT %s 88 89# PACPLT: Disassembly of section .text: 90# PACPLT: 0000000000210370 <func1>: 91# PACPLT-NEXT: 210370: bl 0x2103a0 <func2@plt> 92# PACPLT-NEXT: ret 93# PACPLT: 0000000000210378 <func3>: 94# PACPLT-NEXT: 210378: ret 95# PACPLT: Disassembly of section .plt: 96# PACPLT: 0000000000210380 <.plt>: 97# PACPLT-NEXT: 210380: stp x16, x30, [sp, #-16]! 98# PACPLT-NEXT: adrp x16, #131072 99# PACPLT-NEXT: ldr x17, [x16, #1192] 100# PACPLT-NEXT: add x16, x16, #1192 101# PACPLT-NEXT: br x17 102# PACPLT-NEXT: nop 103# PACPLT-NEXT: nop 104# PACPLT-NEXT: nop 105# PACPLT: 00000000002103a0 <func2@plt>: 106# PACPLT-NEXT: 2103a0: adrp x16, #131072 107# PACPLT-NEXT: ldr x17, [x16, #1200] 108# PACPLT-NEXT: add x16, x16, #1200 109# PACPLT-NEXT: autia1716 110# PACPLT-NEXT: br x17 111# PACPLT-NEXT: nop 112 113# PACDYN2-NOT: 0x0000000070000001 (AARCH64_BTI_PLT) 114# PACDYN2: 0x0000000070000003 (AARCH64_PAC_PLT) 115 116.section ".note.gnu.property", "a" 117.long 4 118.long 0x10 119.long 0x5 120.asciz "GNU" 121 122.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND 123.long 4 124.long 2 // GNU_PROPERTY_AARCH64_FEATURE_1_PAC 125.long 0 126 127.text 128.globl _start 129.type func1,%function 130func1: 131 bl func2 132 ret 133