140 lines · plain
1# REQUIRES: aarch642# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t.o3# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-pac1.s -o %t1.o4# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3.s -o %t2.o5# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3-pac.s -o %t3.o6# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func2.s -o %tno.o7 8## We do not add PAC support when the inputs don't have the .note.gnu.property9## field.10 11# RUN: ld.lld %tno.o %t3.o --shared -o %tno1.so12# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tno1.so | FileCheck --check-prefix=NOPAC %s13# RUN: llvm-readelf -x .got.plt %tno1.so | FileCheck --check-prefix SOGOTPLT %s14# RUN: llvm-readelf --dynamic-table %tno1.so | FileCheck --check-prefix NOPACDYN %s15 16# RUN: ld.lld %tno.o %t3.o --shared -o %tno2.so -z pac-plt -znopac-plt17# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tno2.so | FileCheck --check-prefix=NOPAC %s18# RUN: llvm-readelf -x .got.plt %tno2.so | FileCheck --check-prefix SOGOTPLT %s19# RUN: llvm-readelf --dynamic-table %tno2.so | FileCheck --check-prefix NOPACDYN %s20 21# NOPAC: 00000000000102b8 <func2>:22# NOPAC-NEXT: 102b8: bl 0x102f0 <func3@plt>23# NOPAC-NEXT: ret24# NOPAC: Disassembly of section .plt:25# NOPAC: 00000000000102d0 <.plt>:26# NOPAC-NEXT: 102d0: stp x16, x30, [sp, #-16]!27# NOPAC-NEXT: adrp x16, 0x3000028# NOPAC-NEXT: ldr x17, [x16, #960]29# NOPAC-NEXT: add x16, x16, #96030# NOPAC-NEXT: br x1731# NOPAC-NEXT: nop32# NOPAC-NEXT: nop33# NOPAC-NEXT: nop34# NOPAC: 00000000000102f0 <func3@plt>:35# NOPAC-NEXT: 102f0: adrp x16, 0x3000036# NOPAC-NEXT: ldr x17, [x16, #968]37# NOPAC-NEXT: add x16, x16, #96838# NOPAC-NEXT: br x1739 40# SOGOTPLT: Hex dump of section '.got.plt':41# SOGOTPLT-NEXT: 0x000303b0 00000000 00000000 00000000 0000000042# SOGOTPLT-NEXT: 0x000303c0 00000000 00000000 d0020100 0000000043 44# NOPACDYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT)45# NOPACDYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT)46 47# RUN: ld.lld %t1.o %t3.o --shared --soname=t.so -o %t.so48# RUN: llvm-readelf -n %t.so | FileCheck --check-prefix PACPROP %s49# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %t.so | FileCheck --check-prefix PACSO %s50# RUN: llvm-readelf -x .got.plt %t.so | FileCheck --check-prefix SOGOTPLT2 %s51# RUN: llvm-readelf --dynamic-table %t.so | FileCheck --check-prefix PACDYN %s52 53## PAC has no effect on PLT[0], for PLT[N].54# PACSO: 0000000000010348 <func2>:55# PACSO-NEXT: 10348: bl 0x10380 <func3@plt>56# PACSO-NEXT: ret57# PACSO: 0000000000010350 <func3>:58# PACSO-NEXT: 10350: ret59# PACSO: Disassembly of section .plt:60# PACSO: 0000000000010360 <.plt>:61# PACSO-NEXT: 10360: stp x16, x30, [sp, #-16]!62# PACSO-NEXT: adrp x16, 0x3000063# PACSO-NEXT: ldr x17, [x16, #1120]64# PACSO-NEXT: add x16, x16, #112065# PACSO-NEXT: br x1766# PACSO-NEXT: nop67# PACSO-NEXT: nop68# PACSO-NEXT: nop69# PACSO: 0000000000010380 <func3@plt>:70# PACSO-NEXT: 10380: adrp x16, 0x3000071# PACSO-NEXT: ldr x17, [x16, #1128]72# PACSO-NEXT: add x16, x16, #112873# PACSO-NEXT: br x1774 75# SOGOTPLT2: Hex dump of section '.got.plt':76# SOGOTPLT2-NEXT: 0x00030450 00000000 00000000 00000000 0000000077# SOGOTPLT2-NEXT: 0x00030460 00000000 00000000 60030100 0000000078 79# PACPROP: Properties: aarch64 feature: PAC80 81# PACDYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT)82# PACDYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT)83 84## Turn on PAC entries with the -z pac-plt command line option. For files w/o85## GNU_PROPERTY_AARCH64_FEATURE_1_PAC set in GNU_PROPERTY_AARCH64_FEATURE_1_AND86## property, emit a warning.87 88# RUN: ld.lld %t.o %t2.o -z pac-plt %t.so -o %tpacplt.exe 2>&1 | FileCheck -DFILE=%t2.o --check-prefix WARN %s89 90# 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 job91 92# RUN: llvm-readelf -n %tpacplt.exe | FileCheck --check-prefix=PACPROP %s93# RUN: llvm-readelf --dynamic-table %tpacplt.exe | FileCheck --check-prefix PACDYN2 %s94# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tpacplt.exe | FileCheck --check-prefix PACPLT %s95 96# PACPLT: Disassembly of section .text:97# PACPLT: 0000000000210370 <func1>:98# PACPLT-NEXT: 210370: bl 0x2103a0 <func2@plt>99# PACPLT-NEXT: ret100# PACPLT: 0000000000210378 <func3>:101# PACPLT-NEXT: 210378: ret102# PACPLT: Disassembly of section .plt:103# PACPLT: 0000000000210380 <.plt>:104# PACPLT-NEXT: 210380: stp x16, x30, [sp, #-16]!105# PACPLT-NEXT: adrp x16, 0x230000106# PACPLT-NEXT: ldr x17, [x16, #1192]107# PACPLT-NEXT: add x16, x16, #1192108# PACPLT-NEXT: br x17109# PACPLT-NEXT: nop110# PACPLT-NEXT: nop111# PACPLT-NEXT: nop112# PACPLT: 00000000002103a0 <func2@plt>:113# PACPLT-NEXT: 2103a0: adrp x16, 0x230000114# PACPLT-NEXT: ldr x17, [x16, #1200]115# PACPLT-NEXT: add x16, x16, #1200116# PACPLT-NEXT: autia1716117# PACPLT-NEXT: br x17118# PACPLT-NEXT: nop119 120# PACDYN2-NOT: 0x0000000070000001 (AARCH64_BTI_PLT)121# PACDYN2: 0x0000000070000003 (AARCH64_PAC_PLT)122 123.section ".note.gnu.property", "a"124.long 4125.long 0x10126.long 0x5127.asciz "GNU"128 129.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND130.long 4131.long 2 // GNU_PROPERTY_AARCH64_FEATURE_1_PAC132.long 0133 134.text135.globl _start136.type func1,%function137func1:138 bl func2139 ret140