[PATCH] Update the barrier cache during ARM EHABI unwinding
authorAmanieu d'Antras <amanieu@gmail.com>
Wed, 1 Jan 2020 16:11:45 +0000 (17:11 +0100)
committerEmilio Pozuelo Monfort <pochu@debian.org>
Tue, 8 Sep 2020 16:38:19 +0000 (17:38 +0100)
Gbp-Pq: Name 0001-Update-the-barrier-cache-during-ARM-EHABI-unwinding.patch

src/libpanic_unwind/gcc.rs
src/libunwind/libunwind.rs

index 4f572fe21b30baeb36ded4232fba107fdc38465e..328d0d4ce7be33174575d71e7d6519c52de93d14 100644 (file)
@@ -187,7 +187,13 @@ cfg_if::cfg_if! {
                 match eh_action {
                     EHAction::None |
                     EHAction::Cleanup(_) => return continue_unwind(exception_object, context),
-                    EHAction::Catch(_) => return uw::_URC_HANDLER_FOUND,
+                    EHAction::Catch(_) => {
+                        // EHABI requires the personality routine to update the
+                        // SP value in the barrier cache of the exception object.
+                        (*exception_object).private[5] =
+                            uw::_Unwind_GetGR(context, uw::UNWIND_SP_REG);
+                        return uw::_URC_HANDLER_FOUND;
+                    }
                     EHAction::Terminate => return uw::_URC_FAILURE,
                 }
             } else {
index 0b39503c0d03453b08da3bf2a5f0420b6433747b..30658ce328d8bf507beed311e411d406b82f659a 100644 (file)
@@ -23,6 +23,7 @@ pub type _Unwind_Word = uintptr_t;
 pub type _Unwind_Ptr = uintptr_t;
 pub type _Unwind_Trace_Fn = extern "C" fn(ctx: *mut _Unwind_Context, arg: *mut c_void)
                                           -> _Unwind_Reason_Code;
+
 #[cfg(target_arch = "x86")]
 pub const unwinder_private_data_size: usize = 5;
 
@@ -151,6 +152,7 @@ if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm
     use _Unwind_VRS_DataRepresentation::*;
 
     pub const UNWIND_POINTER_REG: c_int = 12;
+    pub const UNWIND_SP_REG: c_int = 13;
     pub const UNWIND_IP_REG: c_int = 15;
 
     #[cfg_attr(all(feature = "llvm-libunwind",