Move dummy personality to libunwind

This commit is contained in:
Gary Guo 2021-08-26 08:17:04 +01:00
parent bf908d9562
commit e205fb9e64
5 changed files with 21 additions and 17 deletions

View File

@ -18,6 +18,7 @@ fde-phdr = ["libc"]
fde-registry = ["alloc"]
dwarf-expr = []
hide-trace = []
personality-dummy = []
system-alloc = []
default = ["dwarf-expr", "hide-trace", "fde-phdr", "fde-registry"]

View File

@ -8,5 +8,5 @@ edition = "2018"
crate-type = ["cdylib"]
[dependencies]
unwind = { path = "../", features = ["system-alloc"] }
unwind = { path = "../", features = ["system-alloc", "personality-dummy"] }
libc = "0.2"

View File

@ -9,25 +9,9 @@
extern crate unwind;
use core::panic::PanicInfo;
use libc::c_int;
pub use unwind::*;
#[panic_handler]
fn panic(_info: &PanicInfo<'_>) -> ! {
// `unwind` crate should never panic.
unsafe { core::hint::unreachable_unchecked() }
}
#[lang = "eh_personality"]
extern "C" fn personality(
version: c_int,
_actions: UnwindAction,
_exception_class: u64,
_exception: &mut UnwindException,
_ctx: &mut UnwindContext<'_>,
) -> UnwindReasonCode {
if version != 1 {
return UnwindReasonCode::FATAL_PHASE1_ERROR;
}
UnwindReasonCode::CONTINUE_UNWIND
}

View File

@ -14,6 +14,9 @@ mod find_fde;
mod frame;
mod util;
#[cfg(feature = "personality-dummy")]
mod personality_dummy;
#[cfg(feature = "system-alloc")]
mod system_alloc;

16
src/personality_dummy.rs Normal file
View File

@ -0,0 +1,16 @@
use crate::abi::*;
use crate::util::*;
#[lang = "eh_personality"]
extern "C" fn personality(
version: c_int,
_actions: UnwindAction,
_exception_class: u64,
_exception: &mut UnwindException,
_ctx: &mut UnwindContext<'_>,
) -> UnwindReasonCode {
if version != 1 {
return UnwindReasonCode::FATAL_PHASE1_ERROR;
}
UnwindReasonCode::CONTINUE_UNWIND
}