1 | // Check the -msign-return-address= option, which has a required argument to |
2 | // select scope. |
3 | // RUN: %clang -target aarch64--none-eabi -c %s -### -msign-return-address=none 2>&1 | \ |
4 | // RUN: FileCheck %s --check-prefix=RA-OFF --check-prefix=KEY-A --check-prefix=BTE-OFF |
5 | |
6 | // RUN: %clang -target aarch64--none-eabi -c %s -### -msign-return-address=non-leaf 2>&1 | \ |
7 | // RUN: FileCheck %s --check-prefix=RA-NON-LEAF --check-prefix=KEY-A --check-prefix=BTE-OFF |
8 | |
9 | // RUN: %clang -target aarch64--none-eabi -c %s -### -msign-return-address=all 2>&1 | \ |
10 | // RUN: FileCheck %s --check-prefix=RA-ALL --check-prefix=KEY-A --check-prefix=BTE-OFF |
11 | |
12 | // Check that the -msign-return-address= option can also accept the signing key |
13 | // to use. |
14 | |
15 | // RUN: %clang -target aarch64--none-eabi -c %s -### -msign-return-address=non-leaf 2>&1 | \ |
16 | // RUN: FileCheck %s --check-prefix=RA-NON-LEAF --check-prefix=KEY-B --check-prefix=BTE-OFF |
17 | |
18 | // RUN: %clang -target aarch64--none-eabi -c %s -### -msign-return-address=all 2>&1 | \ |
19 | // RUN: FileCheck %s --check-prefix=RA-ALL --check-prefix=KEY-B --check-prefix=BTE-OFF |
20 | |
21 | // -mbranch-protection with standard |
22 | // RUN: %clang -target aarch64--none-eabi -c %s -### -mbranch-protection=standard 2>&1 | \ |
23 | // RUN: FileCheck %s --check-prefix=RA-NON-LEAF --check-prefix=KEY-A --check-prefix=BTE-ON |
24 | |
25 | // If the -msign-return-address and -mbranch-protection are both used, the |
26 | // right-most one controls return address signing. |
27 | // RUN: %clang -target aarch64--none-eabi -c %s -### -msign-return-address=non-leaf -mbranch-protection=none 2>&1 | \ |
28 | // RUN: FileCheck %s --check-prefix=CONFLICT |
29 | |
30 | // RUN: %clang -target aarch64--none-eabi -c %s -### -mbranch-protection=pac-ret -msign-return-address=none 2>&1 | \ |
31 | // RUN: FileCheck %s --check-prefix=CONFLICT |
32 | |
33 | // RUN: %clang -target aarch64--none-eabi -c %s -### -msign-return-address=foo 2>&1 | \ |
34 | // RUN: FileCheck %s --check-prefix=BAD-RA-PROTECTION |
35 | |
36 | // RUN: %clang -target aarch64--none-eabi -c %s -### -mbranch-protection=bar 2>&1 | \ |
37 | // RUN: FileCheck %s --check-prefix=BAD-BP-PROTECTION |
38 | |
39 | // RA-OFF: "-msign-return-address=none" |
40 | // RA-NON-LEAF: "-msign-return-address=non-leaf" |
41 | // RA-ALL: "-msign-return-address=all" |
42 | |
43 | // KEY-A: "-msign-return-address-key=a_key" |
44 | |
45 | // BTE-OFF-NOT: "-mbranch-target-enforce" |
46 | // BTE-ON: "-mbranch-target-enforce" |
47 | |
48 | // CONFLICT: "-msign-return-address=none" |
49 | |
50 | // BAD-RA-PROTECTION: invalid branch protection option 'foo' in '-msign-return-address={{.*}}' |
51 | // BAD-BP-PROTECTION: invalid branch protection option 'bar' in '-mbranch-protection={{.*}}' |
52 | |
53 | // BAD-B-KEY-COMBINATION: invalid branch protection option 'b-key' in '-mbranch-protection={{.*}}' |
54 | // BAD-LEAF-COMBINATION: invalid branch protection option 'leaf' in '-mbranch-protection={{.*}}' |
55 | |