2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 // REQUIRES: linux && target={{aarch64-.+}}
11 // XFAIL: no-exceptions
13 // This test ensures the .cfi_negate_ra_state the RA_SIGN_STATE pseudo register
14 // could be set directly set by a DWARF expression and the unwinder handles it
15 // correctly. The two directives can't be mixed in one CIE/FDE sqeuence.
19 __attribute__((noinline
, target("branch-protection=pac-ret+leaf")))
21 // ".cfi_negate_ra_state" is emitted by the compiler.
25 __attribute__((noinline
, target("branch-protection=none")))
27 // Here a DWARF expression sets RA_SIGN_STATE.
28 // The LR is signed manually and stored on the stack.
30 ".cfi_escape 0x16," // DW_CFA_val_expression
31 "34," // REG_34(RA_SIGN_STATE)
32 "1," // expression_length(1)
33 "0x31\n" // DW_OP_lit1
34 "add sp, sp, 16\n" // Restore SP's value before the stack frame is
36 "paciasp\n" // Sign the LR.
37 "str lr, [sp, -0x8]\n" // Overwrite LR on the stack.
38 "sub sp, sp, 16\n" // Restore SP's value.
44 __attribute__((noinline
, target("branch-protection=pac-ret")))
46 // ".cfi_negate_ra_state" is emitted by the compiler.