rust/0001-Update-the-barrier-cache-during-ARM-EHABI-unwinding.patch
2020-01-08 09:02:41 -08:00

53 lines
2.1 KiB
Diff

From b6fd4598c5367e78b5841fd99412484f0e86fc21 Mon Sep 17 00:00:00 2001
From: Amanieu d'Antras <amanieu@gmail.com>
Date: Wed, 1 Jan 2020 17:11:45 +0100
Subject: [PATCH] Update the barrier cache during ARM EHABI unwinding
---
src/libpanic_unwind/gcc.rs | 8 +++++++-
src/libunwind/libunwind.rs | 2 ++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/libpanic_unwind/gcc.rs b/src/libpanic_unwind/gcc.rs
index 4f572fe21b30..328d0d4ce7be 100644
--- a/src/libpanic_unwind/gcc.rs
+++ b/src/libpanic_unwind/gcc.rs
@@ -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 {
diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs
index 0b39503c0d03..30658ce328d8 100644
--- a/src/libunwind/libunwind.rs
+++ b/src/libunwind/libunwind.rs
@@ -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",
--
2.24.1