[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)
Daniil Kovalev via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 15 09:20:36 PDT 2025
================
@@ -557,7 +596,19 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context,
reinterpret_cast<uintptr_t>(unwind_exception));
_Unwind_SetGR(context, __builtin_eh_return_data_regno(1),
static_cast<uintptr_t>(results.ttypeIndex));
+#if defined(__APPLE__) && __has_feature(ptrauth_qualifier)
+ auto stack_pointer = _Unwind_GetGR(context, UNW_REG_SP);
+ // We manually re-sign the IP as the __ptrauth qualifiers cannot
+ // express the required relationship with the destination address
+ const auto existingDiscriminator = ptrauth_blend_discriminator(
+ &results.landingPad, ptrauth_string_discriminator(_LIBCXXABI_PTRAUTH_SCANRESULT_LANDINGPAD_DISC));
+ unw_word_t newIP =
+ (unw_word_t)ptrauth_auth_and_resign(*(void**)&results.landingPad, _LIBCXXABI_PTRAUTH_KEY, existingDiscriminator,
+ ptrauth_key_return_address, stack_pointer);
+ _Unwind_SetIP(context, newIP);
+#else
----------------
kovdan01 wrote:
@atrosinenko Could you please add a little bit of context for your question? I tried to dive into your comments related to gcc_personality_v0.c (as you are referring to that here), but I'm not sure I get your question.
I just want to resolve all the threads which are no longer relevant, and I'm not sure if we have an issue here.
https://github.com/llvm/llvm-project/pull/143230
More information about the llvm-commits
mailing list