|
| 1 | +# This test checks that MarkRAStates pass ignores functions with |
| 2 | +# malformed .cfi_negate_ra_state sequences in the input binary. |
| 3 | + |
| 4 | +# The cases checked are: |
| 5 | +# - extra .cfi_negate_ra_state in Signed state: checked in foo, |
| 6 | +# - extra .cfi_negate_ra_state in Unsigned state: checked in bar, |
| 7 | +# - missing .cfi_negate_ra_state from PSign or PAuth instructions: checked in baz. |
| 8 | + |
1 | 9 | # RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o |
2 | 10 | # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q |
3 | | -# RUN: llvm-bolt %t.exe -o %t.exe.bolt | FileCheck %s |
| 11 | +# RUN: llvm-bolt %t.exe -o %t.exe.bolt --no-threads | FileCheck %s --check-prefix=CHECK-BOLT |
| 12 | + |
| 13 | +# CHECK-BOLT: BOLT-INFO: inconsistent RAStates in function foo |
| 14 | +# CHECK-BOLT-NEXT: BOLT-INFO: ptr authenticating inst encountered in Unsigned RA state. |
4 | 15 |
|
5 | | -# check that the output is listing foo as incorrect |
6 | | -# CHECK: BOLT-INFO: inconsistent RAStates in function foo |
| 16 | +# CHECK-BOLT: BOLT-INFO: inconsistent RAStates in function bar |
| 17 | +# CHECK-BOLT-NEXT: BOLT-INFO: ptr signing inst encountered in Signed RA state |
7 | 18 |
|
8 | | -# check that foo got Ignored, so it's not in the new .text section |
9 | | -# RUN: llvm-objdump %t.exe.bolt -d -j .text > %t.exe.dump |
10 | | -# RUN: not grep "<foo>:" %t.exe.dump |
| 19 | +# CHECK-BOLT: BOLT-INFO: inconsistent RAStates in function baz |
| 20 | +# CHECK-BOLT-NEXT: BOLT-INFO: ptr sign/auth inst without .cfi_negate_ra_state |
| 21 | + |
| 22 | +# Check that the incorrect functions got ignored, so they are not in the new .text section |
| 23 | +# RUN: llvm-objdump %t.exe.bolt -d -j .text | FileCheck %s --check-prefix=CHECK-OBJDUMP |
| 24 | +# CHECK-OBJDUMP-NOT: <foo>: |
| 25 | +# CHECK-OBJDUMP-NOT: <bar>: |
| 26 | +# CHECK-OBJDUMP-NOT: <baz>: |
11 | 27 |
|
12 | 28 |
|
13 | | -# How is this test incorrect? |
14 | | -# There is an extra .cfi_negate_ra_state in foo. |
15 | | -# Because of this, we will get to the autiasp (hint #29) |
16 | | -# in a (seemingly) unsigned state. That is incorrect. |
17 | 29 | .text |
18 | 30 | .globl foo |
19 | 31 | .p2align 2 |
|
22 | 34 | .cfi_startproc |
23 | 35 | hint #25 |
24 | 36 | .cfi_negate_ra_state |
25 | | - sub sp, sp, #16 |
26 | | - stp x29, x30, [sp, #16] // 16-byte Folded Spill |
27 | | - .cfi_def_cfa_offset 16 |
28 | | - str w0, [sp, #12] |
29 | | - ldr w8, [sp, #12] |
| 37 | + mov x1, #0 |
| 38 | + .cfi_negate_ra_state // Incorrect CFI in signed state |
| 39 | + hint #29 |
| 40 | + .cfi_negate_ra_state |
| 41 | + ret |
| 42 | + .cfi_endproc |
| 43 | + .size foo, .-foo |
| 44 | + |
| 45 | + .text |
| 46 | + .globl bar |
| 47 | + .p2align 2 |
| 48 | + .type bar,@function |
| 49 | +bar: |
| 50 | + .cfi_startproc |
| 51 | + mov x1, #0 |
| 52 | + .cfi_negate_ra_state // Incorrect CFI in unsigned state |
| 53 | + hint #25 |
30 | 54 | .cfi_negate_ra_state |
31 | | - add w0, w8, #1 |
32 | | - ldp x29, x30, [sp, #16] // 16-byte Folded Reload |
33 | | - add sp, sp, #16 |
| 55 | + mov x1, #0 |
34 | 56 | hint #29 |
35 | 57 | .cfi_negate_ra_state |
36 | 58 | ret |
37 | | -.Lfunc_end1: |
38 | | - .size foo, .Lfunc_end1-foo |
39 | 59 | .cfi_endproc |
| 60 | + .size bar, .-bar |
| 61 | + |
| 62 | + .text |
| 63 | + .globl baz |
| 64 | + .p2align 2 |
| 65 | + .type baz,@function |
| 66 | +baz: |
| 67 | + .cfi_startproc |
| 68 | + mov x1, #0 |
| 69 | + hint #25 |
| 70 | + .cfi_negate_ra_state |
| 71 | + mov x1, #0 |
| 72 | + hint #29 |
| 73 | + // Missing .cfi_negate_ra_state |
| 74 | + ret |
| 75 | + .cfi_endproc |
| 76 | + .size baz, .-baz |
40 | 77 |
|
41 | 78 | .global _start |
42 | 79 | .type _start, %function |
43 | 80 | _start: |
44 | 81 | b foo |
| 82 | + b bar |
| 83 | + b baz |
0 commit comments