[llvm-branch-commits] compiler-rt: Introduce runtime functions for emulated PAC. (PR #133530)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Apr 2 21:37:57 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff f2e0ad9c6c60da547b91f170520a2b97cfd967a9 84a0613573c370d902dc32a529f2d30f2b83863f --extensions cpp -- compiler-rt/lib/builtins/aarch64/emupac.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/compiler-rt/lib/builtins/aarch64/emupac.cpp b/compiler-rt/lib/builtins/aarch64/emupac.cpp
index 95a21c969d..dbcd9a0983 100644
--- a/compiler-rt/lib/builtins/aarch64/emupac.cpp
+++ b/compiler-rt/lib/builtins/aarch64/emupac.cpp
@@ -55,34 +55,34 @@ static bool pac_supported() {
// may crash if an auth failure is detected and may be unwound past using a
// frame pointer based unwinder.
#ifdef __GCC_HAVE_DWARF2_CFI_ASM
-#define frame_pointer_wrap(sym) \
- "stp x29, x30, [sp, #-16]!\n" \
- ".cfi_def_cfa_offset 16\n" \
- "mov x29, sp\n" \
- ".cfi_def_cfa w29, 16\n" \
- ".cfi_offset w30, -8\n" \
- ".cfi_offset w29, -16\n" \
- "bl " #sym "\n" \
- ".cfi_def_cfa wsp, 16\n" \
- "ldp x29, x30, [sp], #16\n" \
- ".cfi_def_cfa_offset 0\n" \
- ".cfi_restore w30\n" \
- ".cfi_restore w29\n" \
+#define frame_pointer_wrap(sym) \
+ "stp x29, x30, [sp, #-16]!\n" \
+ ".cfi_def_cfa_offset 16\n" \
+ "mov x29, sp\n" \
+ ".cfi_def_cfa w29, 16\n" \
+ ".cfi_offset w30, -8\n" \
+ ".cfi_offset w29, -16\n" \
+ "bl " #sym "\n" \
+ ".cfi_def_cfa wsp, 16\n" \
+ "ldp x29, x30, [sp], #16\n" \
+ ".cfi_def_cfa_offset 0\n" \
+ ".cfi_restore w30\n" \
+ ".cfi_restore w29\n" \
"ret"
#else
-#define frame_pointer_wrap(sym) \
- "stp x29, x30, [sp, #-16]!\n" \
- "mov x29, sp\n" \
- "bl " #sym "\n" \
- "ldp x29, x30, [sp], #16\n" \
+#define frame_pointer_wrap(sym) \
+ "stp x29, x30, [sp, #-16]!\n" \
+ "mov x29, sp\n" \
+ "bl " #sym "\n" \
+ "ldp x29, x30, [sp], #16\n" \
"ret"
#endif
static const uint8_t K[16] = {0xb5, 0xd4, 0xc9, 0xeb, 0x79, 0x10, 0x4a, 0x79,
0x6f, 0xec, 0x8b, 0x1b, 0x42, 0x87, 0x81, 0xd4};
-__attribute__((flatten))
-extern "C" uint64_t __emupac_pacda_impl(uint64_t ptr, uint64_t disc) {
+__attribute__((flatten)) extern "C" uint64_t
+__emupac_pacda_impl(uint64_t ptr, uint64_t disc) {
if (pac_supported()) {
__asm__ __volatile__(".arch_extension pauth\npacda %0, %1"
: "+r"(ptr)
@@ -100,16 +100,17 @@ extern "C" uint64_t __emupac_pacda_impl(uint64_t ptr, uint64_t disc) {
}
uint64_t hash;
siphash<2, 4>(reinterpret_cast<uint8_t *>(&ptr), 8, K,
- *reinterpret_cast<uint8_t (*)[8]>(&hash));
+ *reinterpret_cast<uint8_t(*)[8]>(&hash));
return (ptr & ~kPACMask) | (hash & kPACMask);
}
-extern "C" __attribute__((naked)) uint64_t __emupac_pacda(uint64_t ptr, uint64_t disc) {
+extern "C" __attribute__((naked)) uint64_t __emupac_pacda(uint64_t ptr,
+ uint64_t disc) {
__asm__(frame_pointer_wrap(__emupac_pacda_impl));
}
-__attribute__((flatten))
-extern "C" uint64_t __emupac_autda_impl(uint64_t ptr, uint64_t disc) {
+__attribute__((flatten)) extern "C" uint64_t
+__emupac_autda_impl(uint64_t ptr, uint64_t disc) {
if (pac_supported()) {
__asm__ __volatile__(".arch_extension pauth\nautda %0, %1"
: "+r"(ptr)
@@ -120,13 +121,14 @@ extern "C" uint64_t __emupac_autda_impl(uint64_t ptr, uint64_t disc) {
(ptr & kTTBR1Mask) ? (ptr | kPACMask) : (ptr & ~kPACMask);
uint64_t hash;
siphash<2, 4>(reinterpret_cast<uint8_t *>(&ptr_without_pac), 8, K,
- *reinterpret_cast<uint8_t (*)[8]>(&hash));
+ *reinterpret_cast<uint8_t(*)[8]>(&hash));
if (((ptr & ~kPACMask) | (hash & kPACMask)) != ptr) {
__builtin_trap();
}
return ptr_without_pac;
}
-extern "C" __attribute__((naked)) uint64_t __emupac_autda(uint64_t ptr, uint64_t disc) {
+extern "C" __attribute__((naked)) uint64_t __emupac_autda(uint64_t ptr,
+ uint64_t disc) {
__asm__(frame_pointer_wrap(__emupac_autda_impl));
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/133530
More information about the llvm-branch-commits
mailing list