[libunwind] [LFI][libunwind] Omit unsuppported stg/za instructions for LFI target (PR #209392)
Zachary Yedidia via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 18 14:26:52 PDT 2026
https://github.com/zyedidia updated https://github.com/llvm/llvm-project/pull/209392
>From f359b85d31fca47d5f2d3d45767a579661124fc1 Mon Sep 17 00:00:00 2001
From: Zachary Yedidia <zyedidia at gmail.com>
Date: Wed, 29 Apr 2026 18:00:29 -0400
Subject: [PATCH 1/2] [LFI] Remove stg/za instructions in libunwind
---
libunwind/src/DwarfInstructions.hpp | 2 +-
libunwind/src/UnwindRegistersSave.S | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/libunwind/src/DwarfInstructions.hpp b/libunwind/src/DwarfInstructions.hpp
index 56220c327a7fa..4f53df3e74b75 100644
--- a/libunwind/src/DwarfInstructions.hpp
+++ b/libunwind/src/DwarfInstructions.hpp
@@ -216,7 +216,7 @@ int DwarfInstructions<A, R>::stepWithDwarf(
// __unw_step_stage2 is not used for cross unwinding, so we use
// __aarch64__ rather than LIBUNWIND_TARGET_AARCH64 to make sure we are
// building for AArch64 natively.
-#if defined(__aarch64__)
+#if defined(__aarch64__) && !defined(__LFI__)
if (stage2 && cieInfo.mteTaggedFrame) {
pint_t sp = registers.getSP();
pint_t p = sp;
diff --git a/libunwind/src/UnwindRegistersSave.S b/libunwind/src/UnwindRegistersSave.S
index a82ebd1ead23b..708dcd9c50711 100644
--- a/libunwind/src/UnwindRegistersSave.S
+++ b/libunwind/src/UnwindRegistersSave.S
@@ -854,6 +854,10 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
.p2align 2
DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_za_disable)
.variant_pcs __libunwind_Registers_arm64_za_disable
+#if defined(__LFI__)
+ mov x0, xzr
+ ret
+#else
#if __has_feature(ptrauth_calls)
pacibsp
#endif
@@ -897,6 +901,7 @@ DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_za_disable)
#else
ret
#endif
+#endif
#elif defined(__arm__) && !defined(__APPLE__)
>From 593b10db637bea6c46a4b69fbdb6972ac6ba40fb Mon Sep 17 00:00:00 2001
From: Zachary Yedidia <zyedidia at gmail.com>
Date: Sat, 18 Jul 2026 17:26:39 -0400
Subject: [PATCH 2/2] Return 1 from function to indicate failure
---
libunwind/src/UnwindRegistersSave.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libunwind/src/UnwindRegistersSave.S b/libunwind/src/UnwindRegistersSave.S
index 708dcd9c50711..f89709d64358d 100644
--- a/libunwind/src/UnwindRegistersSave.S
+++ b/libunwind/src/UnwindRegistersSave.S
@@ -855,7 +855,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_arm64_za_disable)
.variant_pcs __libunwind_Registers_arm64_za_disable
#if defined(__LFI__)
- mov x0, xzr
+ mov x0, #1
ret
#else
#if __has_feature(ptrauth_calls)
More information about the cfe-commits
mailing list