|
| 1 | +### This file replace .note.gnu.property with aarch64 build attributes in order to confirm |
| 2 | +### interoperability. |
| 3 | + |
| 4 | +# REQUIRES: aarch64 |
| 5 | +# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t.o |
| 6 | +# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-pac1-replace.s -o %t1.o |
| 7 | +# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3.s -o %t2.o |
| 8 | +# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3-pac-replace.s -o %t3.o |
| 9 | +# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func2.s -o %tno.o |
| 10 | + |
| 11 | +## We do not add PAC support when the inputs don't have the .note.gnu.property |
| 12 | +## field. |
| 13 | + |
| 14 | +# RUN: ld.lld %tno.o %t3.o --shared -o %tno.so |
| 15 | +# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tno.so | FileCheck --check-prefix=NOPAC %s |
| 16 | +# RUN: llvm-readelf -x .got.plt %tno.so | FileCheck --check-prefix SOGOTPLT %s |
| 17 | +# RUN: llvm-readelf --dynamic-table %tno.so | FileCheck --check-prefix NOPACDYN %s |
| 18 | + |
| 19 | +# NOPAC: 00000000000102b8 <func2>: |
| 20 | +# NOPAC-NEXT: 102b8: bl 0x102f0 <func3@plt> |
| 21 | +# NOPAC-NEXT: ret |
| 22 | +# NOPAC: Disassembly of section .plt: |
| 23 | +# NOPAC: 00000000000102d0 <.plt>: |
| 24 | +# NOPAC-NEXT: 102d0: stp x16, x30, [sp, #-16]! |
| 25 | +# NOPAC-NEXT: adrp x16, 0x30000 |
| 26 | +# NOPAC-NEXT: ldr x17, [x16, #960] |
| 27 | +# NOPAC-NEXT: add x16, x16, #960 |
| 28 | +# NOPAC-NEXT: br x17 |
| 29 | +# NOPAC-NEXT: nop |
| 30 | +# NOPAC-NEXT: nop |
| 31 | +# NOPAC-NEXT: nop |
| 32 | +# NOPAC: 00000000000102f0 <func3@plt>: |
| 33 | +# NOPAC-NEXT: 102f0: adrp x16, 0x30000 |
| 34 | +# NOPAC-NEXT: ldr x17, [x16, #968] |
| 35 | +# NOPAC-NEXT: add x16, x16, #968 |
| 36 | +# NOPAC-NEXT: br x17 |
| 37 | + |
| 38 | +# SOGOTPLT: Hex dump of section '.got.plt': |
| 39 | +# SOGOTPLT-NEXT: 0x000303b0 00000000 00000000 00000000 00000000 |
| 40 | +# SOGOTPLT-NEXT: 0x000303c0 00000000 00000000 d0020100 00000000 |
| 41 | + |
| 42 | +# NOPACDYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT) |
| 43 | +# NOPACDYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT) |
| 44 | + |
| 45 | + |
| 46 | +# RUN: ld.lld %t1.o %t3.o --shared --soname=t.so -o %t.so |
| 47 | +# RUN: llvm-readelf -n %t.so | FileCheck --check-prefix PACPROP %s |
| 48 | +# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %t.so | FileCheck --check-prefix PACSO %s |
| 49 | +# RUN: llvm-readelf -x .got.plt %t.so | FileCheck --check-prefix SOGOTPLT2 %s |
| 50 | +# RUN: llvm-readelf --dynamic-table %t.so | FileCheck --check-prefix PACDYN %s |
| 51 | + |
| 52 | +# PACPROP: Properties: aarch64 feature: PAC |
| 53 | + |
| 54 | +# PACSO: Disassembly of section .text: |
| 55 | +# PACSO: 0000000000010348 <func2>: |
| 56 | +# PACSO-NEXT: 10348: bl 0x10380 <func3@plt> |
| 57 | +# PACSO-NEXT: 1034c: ret |
| 58 | +# PACSO: 0000000000010350 <func3>: |
| 59 | +# PACSO-NEXT: 10350: ret |
| 60 | +# PACSO: Disassembly of section .plt: |
| 61 | +# PACSO: 0000000000010360 <.plt>: |
| 62 | +# PACSO-NEXT: 10360: stp x16, x30, [sp, #-16]! |
| 63 | +# PACSO-NEXT: 10364: adrp x16, 0x30000 |
| 64 | +# PACSO-NEXT: 10368: ldr x17, [x16, #1120] |
| 65 | +# PACSO-NEXT: 1036c: add x16, x16, #1120 |
| 66 | +# PACSO-NEXT: 10370: br x17 |
| 67 | +# PACSO-NEXT: 10374: nop |
| 68 | +# PACSO-NEXT: 10378: nop |
| 69 | +# PACSO-NEXT: 1037c: nop |
| 70 | +# PACSO: 0000000000010380 <func3@plt>: |
| 71 | +# PACSO-NEXT: 10380: adrp x16, 0x30000 |
| 72 | +# PACSO-NEXT: 10384: ldr x17, [x16, #1128] |
| 73 | +# PACSO-NEXT: 10388: add x16, x16, #1128 |
| 74 | +# PACSO-NEXT: 1038c: br x17 |
| 75 | + |
| 76 | +# SOGOTPLT2: Hex dump of section '.got.plt': |
| 77 | +# SOGOTPLT2-NEXT: 0x00030450 00000000 00000000 00000000 00000000 |
| 78 | +# SOGOTPLT2-NEXT: 0x00030460 00000000 00000000 60030100 00000000 |
| 79 | + |
| 80 | +# PACDYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT) |
| 81 | +# PACDYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT) |
| 82 | + |
| 83 | + |
| 84 | +# RUN: ld.lld %t.o %t2.o -z pac-plt %t.so -o %tpacplt.exe 2>&1 | FileCheck -DFILE=%t2.o --check-prefix WARN %s |
| 85 | + |
| 86 | +# 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 job |
| 87 | + |
| 88 | + |
| 89 | +# RUN: llvm-readelf -n %tpacplt.exe | FileCheck --check-prefix=PACPROP %s |
| 90 | +# RUN: llvm-readelf --dynamic-table %tpacplt.exe | FileCheck --check-prefix PACDYN2 %s |
| 91 | +# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tpacplt.exe | FileCheck --check-prefix PACPLT %s |
| 92 | + |
| 93 | +# PACDYN2-NOT: 0x0000000070000001 (AARCH64_BTI_PLT) |
| 94 | +# PACDYN2: 0x0000000070000003 (AARCH64_PAC_PLT) |
| 95 | + |
| 96 | +# PACPLT: Disassembly of section .text: |
| 97 | +# PACPLT: 0000000000210370 <func1>: |
| 98 | +# PACPLT-NEXT: 210370: bl 0x2103a0 <func2@plt> |
| 99 | +# PACPLT-NEXT: ret |
| 100 | +# PACPLT: 0000000000210378 <func3>: |
| 101 | +# PACPLT-NEXT: 210378: ret |
| 102 | +# PACPLT: Disassembly of section .plt: |
| 103 | +# PACPLT: 0000000000210380 <.plt>: |
| 104 | +# PACPLT-NEXT: 210380: stp x16, x30, [sp, #-16]! |
| 105 | +# PACPLT-NEXT: adrp x16, 0x230000 |
| 106 | +# PACPLT-NEXT: ldr x17, [x16, #1192] |
| 107 | +# PACPLT-NEXT: add x16, x16, #1192 |
| 108 | +# PACPLT-NEXT: br x17 |
| 109 | +# PACPLT-NEXT: nop |
| 110 | +# PACPLT-NEXT: nop |
| 111 | +# PACPLT-NEXT: nop |
| 112 | +# PACPLT: 00000000002103a0 <func2@plt>: |
| 113 | +# PACPLT-NEXT: 2103a0: adrp x16, 0x230000 |
| 114 | +# PACPLT-NEXT: ldr x17, [x16, #1200] |
| 115 | +# PACPLT-NEXT: add x16, x16, #1200 |
| 116 | +# PACPLT-NEXT: autia1716 |
| 117 | +# PACPLT-NEXT: br x17 |
| 118 | +# PACPLT-NEXT: nop |
| 119 | + |
| 120 | + |
| 121 | +.aeabi_subsection aeabi_feature_and_bits, optional, uleb128 |
| 122 | +.aeabi_attribute Tag_Feature_BTI, 0 |
| 123 | +.aeabi_attribute Tag_Feature_PAC, 1 |
| 124 | +.aeabi_attribute Tag_Feature_GCS, 0 |
| 125 | + |
| 126 | +.text |
| 127 | +.globl _start |
| 128 | +.type func1,%function |
| 129 | +func1: |
| 130 | + bl func2 |
| 131 | + ret |
0 commit comments