diff options
author | Victor Do Nascimento <Victor.DoNascimento@arm.com> | 2022-06-22 14:59:37 +0100 |
---|---|---|
committer | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2022-06-22 15:01:33 +0100 |
commit | 7b5e5cb19d5f2d1c09d6196a4acfbd8a943e1f36 (patch) | |
tree | 2788e18f12936ccbbaceb46234afaeaf8a370d97 | |
parent | 40b662ce7b65d5eaefa40fd8046d6f3c6b3238c1 (diff) | |
download | arm-optimized-routines-7b5e5cb19d5f2d1c09d6196a4acfbd8a943e1f36.tar.gz |
string: Add M-profile PACBTI-enablement header file
Header adds assembler macro to handle Pointer Authentication and Branch
Target Identification assembly instructions in function prologues
and epilogues according to selected flags at compile-time.
-rw-r--r-- | string/pacbti.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/string/pacbti.h b/string/pacbti.h new file mode 100644 index 0000000..4b6e7df --- /dev/null +++ b/string/pacbti.h @@ -0,0 +1,36 @@ +/* + * Macros for pacbti asm code. + * + * Copyright (c) 2022, Arm Limited. + * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception + */ + +/* Macro to handle function entry depending on branch-protection + schemes */ + .macro pacbti_prologue +#if __ARM_FEATURE_PAC_DEFAULT +#if __ARM_FEATURE_BTI_DEFAULT + pacbti ip, lr, sp +#else + pac ip, lr, sp +#endif /* __ARM_FEATURE_BTI_DEFAULT */ + str ip, [sp, #-4]! + .save {ra_auth_code} + .cfi_def_cfa_offset 4 + .cfi_offset 143, -4 +#elif __ARM_FEATURE_BTI_DEFAULT + bti +#endif /* __ARM_FEATURE_PAC_DEFAULT */ + .endm + +/* Macro to handle different branch exchange cases depending on + branch-protection schemes */ + .macro pacbti_epilogue +#if __ARM_FEATURE_PAC_DEFAULT + ldr ip, [sp], #4 + .cfi_restore 143 + .cfi_def_cfa_offset 0 + aut ip, lr, sp +#endif /* __ARM_FEATURE_PAC_DEFAULT */ + bx lr + .endm |