[libc-commits] [libc] [libc][AArch64] Add an AArch64 setjmp/longjmp. (PR #101177)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Tue Jul 30 10:42:53 PDT 2024


================
@@ -0,0 +1,93 @@
+//===-- Implementation of setjmp for AArch64 ------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/setjmp/setjmp_impl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+[[gnu::naked]] LLVM_LIBC_FUNCTION(int, setjmp, (__jmp_buf * buf)) {
+  // If BTI branch protection is in use, the compiler will automatically insert
+  // a BTI here, so we don't need to make any extra effort to do so.
+
+  asm(
+#if __ARM_FEATURE_PAC_DEFAULT & 1
+      // Sign the return address using the PAC A key.
+      R"(
+        hint #25 // PACIASP
----------------
SchrodingerZhu wrote:

I think you can directly use `paciasp` and `autiasp` which translates to no-op on targets without support?

https://github.com/llvm/llvm-project/pull/101177


More information about the libc-commits mailing list