[libcxx-commits] [compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

Daniil Kovalev via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 22 09:59:11 PDT 2025


================
@@ -118,22 +119,51 @@ _LIBUNWIND_HIDDEN int __unw_set_reg(unw_cursor_t *cursor, unw_regnum_t regNum,
   typedef LocalAddressSpace::pint_t pint_t;
   AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
   if (co->validReg(regNum)) {
-    co->setReg(regNum, (pint_t)value);
     // special case altering IP to re-find info (being called by personality
     // function)
     if (regNum == UNW_REG_IP) {
       unw_proc_info_t info;
       // First, get the FDE for the old location and then update it.
       co->getInfo(&info);
-      co->setInfoBasedOnIPRegister(false);
+
+      pint_t sp = (pint_t)co->getReg(UNW_REG_SP);
+
+#if __has_feature(ptrauth_calls)
+      // It is only valid to set the IP within the current function.
+      // This is important for ptrauth, otherwise the IP cannot be correctly
+      // signed.
+      [[maybe_unused]]unw_word_t stripped_value =
----------------
kovdan01 wrote:

I guess this would break builds with older C++ versions.

@ldionne Since this code is not in a public header, can we assume that libunwind is built with at least C++17, or do we need to use old trick with dummy cast to void to silence the warning?

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


More information about the libcxx-commits mailing list