| 1 |
// Check the -mbranch-protection=option |
| 2 |
|
| 3 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=pac-ret 2>&1 | \ |
| 4 |
// RUN: FileCheck %s --check-prefix=RA-NON-LEAF --check-prefix=KEY-A --check-prefix=BTE-OFF |
| 5 |
|
| 6 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=pac-ret+leaf 2>&1 | \ |
| 7 |
// RUN: FileCheck %s --check-prefix=RA-ALL --check-prefix=KEY-A --check-prefix=BTE-OFF |
| 8 |
|
| 9 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=pac-ret+leaf+b-key 2>&1 | \ |
| 10 |
// RUN: FileCheck %s --check-prefix=RA-ALL --check-prefix=KEY-B --check-prefix=BTE-OFF |
| 11 |
|
| 12 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=pac-ret+b-key 2>&1 | \ |
| 13 |
// RUN: FileCheck %s --check-prefix=RA-NON-LEAF --check-prefix=KEY-B --check-prefix=BTE-OFF |
| 14 |
|
| 15 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=bti 2>&1 | \ |
| 16 |
// RUN: FileCheck %s --check-prefix=RA-OFF --check-prefix=BTE-ON |
| 17 |
|
| 18 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=bti+pac-ret 2>&1 | \ |
| 19 |
// RUN: FileCheck %s --check-prefix=RA-NON-LEAF --check-prefix=KEY-A --check-prefix=BTE-ON |
| 20 |
|
| 21 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=bti+pac-ret+leaf 2>&1 | \ |
| 22 |
// RUN: FileCheck %s --check-prefix=RA-ALL --check-prefix=KEY-A --check-prefix=BTE-ON |
| 23 |
|
| 24 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=bti 2>&1 | \ |
| 25 |
// RUN: FileCheck %s --check-prefix=RA-OFF --check-prefix=BTE-ON |
| 26 |
|
| 27 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=bti+pac-ret+b-key 2>&1 | \ |
| 28 |
// RUN: FileCheck %s --check-prefix=RA-NON-LEAF --check-prefix=KEY-B --check-prefix=BTE-ON |
| 29 |
|
| 30 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=bti+pac-ret+leaf+b-key 2>&1 | \ |
| 31 |
// RUN: FileCheck %s --check-prefix=RA-ALL --check-prefix=KEY-B --check-prefix=BTE-ON |
| 32 |
|
| 33 |
// -mbranch-protection with standard |
| 34 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=standard 2>&1 | \ |
| 35 |
// RUN: FileCheck %s --check-prefix=RA-NON-LEAF --check-prefix=KEY-A --check-prefix=BTE-ON |
| 36 |
|
| 37 |
// RUN: not %clang --target=arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=bar 2>&1 | \ |
| 38 |
// RUN: FileCheck %s --check-prefix=BAD-BP-PROTECTION |
| 39 |
|
| 40 |
// RUN: not %clang --target=arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=pac-ret+bti+b-key 2>&1 | \ |
| 41 |
// RUN: FileCheck %s --check-prefix=BAD-B-KEY-COMBINATION |
| 42 |
|
| 43 |
// RUN: not %clang --target=arm-arm-none-eabi -march=armv8.1-m.main -c %s -### -mbranch-protection=pac-ret+bti+leaf 2>&1 | \ |
| 44 |
// RUN: FileCheck %s --check-prefix=BAD-LEAF-COMBINATION |
| 45 |
|
| 46 |
// -mbranch-protection with supported architectures other than v8.1-m.main |
| 47 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8-m.main -c %s -### -mbranch-protection=pac-ret 2>&1 | \ |
| 48 |
// RUN: FileCheck %s --check-prefix=RA-NON-LEAF --check-prefix=KEY-A --check-prefix=BTE-OFF |
| 49 |
|
| 50 |
// RUN: %clang -target arm-arm-none-eabi -march=armv7-m -c %s -### -mbranch-protection=pac-ret 2>&1 | \ |
| 51 |
// RUN: FileCheck %s --check-prefix=RA-NON-LEAF --check-prefix=KEY-A --check-prefix=BTE-OFF |
| 52 |
|
| 53 |
// RUN: %clang -target arm-arm-none-eabi -march=armv7e-m -c %s -### -mbranch-protection=pac-ret 2>&1 | \ |
| 54 |
// RUN: FileCheck %s --check-prefix=RA-NON-LEAF --check-prefix=KEY-A --check-prefix=BTE-OFF |
| 55 |
|
| 56 |
// -mbranch-protection with unsupported architectures |
| 57 |
// RUN: %clang -target arm-arm-none-eabi -march=armv6-m -c %s -### -mbranch-protection=bti 2>&1 | \ |
| 58 |
// RUN: FileCheck %s --check-prefix=INCOMPATIBLE-ARCH |
| 59 |
|
| 60 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8-m.base -c %s -### -mbranch-protection=bti 2>&1 | \ |
| 61 |
// RUN: FileCheck %s --check-prefix=INCOMPATIBLE-ARCH |
| 62 |
|
| 63 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8-a -c %s -### -mbranch-protection=bti 2>&1 | \ |
| 64 |
// RUN: FileCheck %s --check-prefix=INCOMPATIBLE-ARCH |
| 65 |
|
| 66 |
// RUN: %clang -target arm-arm-none-eabi -march=armv8-r -c %s -### -mbranch-protection=bti 2>&1 | \ |
| 67 |
// RUN: FileCheck %s --check-prefix=INCOMPATIBLE-ARCH |
| 68 |
|
| 69 |
// RUN: %clang -target arm-arm-none-eabi -march=armv7-a -c %s -### -mbranch-protection=bti 2>&1 | \ |
| 70 |
// RUN: FileCheck %s --check-prefix=INCOMPATIBLE-ARCH |
| 71 |
|
| 72 |
/// RUN: %clang -target arm-arm-none-eabi -march=armv7-a -mthumb -c %s -### -mbranch-protection=bti 2>&1 | \ |
| 73 |
/// RUN: FileCheck %s --check-prefix=INCOMPATIBLE-ARCH |
| 74 |
|
| 75 |
// RUN: %clang -target arm-arm-none-eabi -march=armv7-r -c %s -### -mbranch-protection=bti 2>&1 | \ |
| 76 |
// RUN: FileCheck %s --check-prefix=INCOMPATIBLE-ARCH |
| 77 |
|
| 78 |
// RA-OFF: "-msign-return-address=none" |
| 79 |
// RA-NON-LEAF: "-msign-return-address=non-leaf" |
| 80 |
// RA-ALL: "-msign-return-address=all" |
| 81 |
|
| 82 |
// KEY-A: "-msign-return-address-key=a_key" |
| 83 |
// KEY-B: "-msign-return-address-key=b_key" |
| 84 |
|
| 85 |
// BTE-OFF-NOT: "-mbranch-target-enforce" |
| 86 |
// BTE-ON: "-mbranch-target-enforce" |
| 87 |
|
| 88 |
// BAD-BP-PROTECTION: unsupported argument 'bar' to option '-mbranch-protection=' |
| 89 |
|
| 90 |
// BAD-B-KEY-COMBINATION: unsupported argument 'b-key' to option '-mbranch-protection=' |
| 91 |
// BAD-LEAF-COMBINATION: unsupported argument 'leaf' to option '-mbranch-protection=' |
| 92 |
|
| 93 |
// INCOMPATIBLE-ARCH: '-mbranch-protection=' option is incompatible with the '{{.*}}' architecture |