diff --git a/library/std/src/sys/personality/dwarf/eh.rs b/library/std/src/sys/personality/dwarf/eh.rs index ef5112ad74f13..116833913f9a3 100644 --- a/library/std/src/sys/personality/dwarf/eh.rs +++ b/library/std/src/sys/personality/dwarf/eh.rs @@ -37,11 +37,10 @@ pub const DW_EH_PE_aligned: u8 = 0x50; pub const DW_EH_PE_indirect: u8 = 0x80; #[derive(Copy, Clone)] -pub struct EHContext<'a> { - pub ip: *const u8, // Current instruction pointer - pub func_start: *const u8, // Pointer to the current function - pub get_text_start: &'a dyn Fn() -> *const u8, // Get pointer to the code section - pub get_data_start: &'a dyn Fn() -> *const u8, // Get pointer to the data section +pub(crate) struct EHContext { + pub(crate) ip: *const u8, // Current instruction pointer + pub(crate) func_start: *const u8, // Pointer to the current function + pub(crate) raw_context: *mut unwind::_Unwind_Context, } /// Landing pad. @@ -63,7 +62,7 @@ pub enum EHAction { pub const USING_SJLJ_EXCEPTIONS: bool = cfg!(all(target_vendor = "apple", not(target_os = "watchos"), target_arch = "arm")); -pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result { +pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext) -> Result { if lsda.is_null() { return Ok(EHAction::None); } @@ -224,7 +223,7 @@ unsafe fn read_encoded_offset(reader: &mut DwarfReader, encoding: u8) -> Result< /// [LSB-dwarf-ext]: https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/dwarfext.html unsafe fn read_encoded_pointer( reader: &mut DwarfReader, - context: &EHContext<'_>, + context: &EHContext, encoding: u8, ) -> Result<*const u8, ()> { if encoding == DW_EH_PE_omit { @@ -241,8 +240,8 @@ unsafe fn read_encoded_pointer( } context.func_start } - DW_EH_PE_textrel => (*context.get_text_start)(), - DW_EH_PE_datarel => (*context.get_data_start)(), + DW_EH_PE_textrel => unsafe { unwind::_Unwind_GetTextRelBase(context.raw_context) }, + DW_EH_PE_datarel => unsafe { unwind::_Unwind_GetDataRelBase(context.raw_context) }, // aligned means the value is aligned to the size of a pointer DW_EH_PE_aligned => { reader.ptr = reader.ptr.with_addr(round_up(reader.ptr.addr(), size_of::<*const u8>())?); diff --git a/library/std/src/sys/personality/gcc.rs b/library/std/src/sys/personality/gcc.rs index 019d5629d6d6e..74e0863c01702 100644 --- a/library/std/src/sys/personality/gcc.rs +++ b/library/std/src/sys/personality/gcc.rs @@ -332,8 +332,7 @@ unsafe fn find_eh_action(context: *mut uw::_Unwind_Context) -> Result