mirror of
https://github.com/Noratrieb/uwuwind.git
synced 2026-01-14 16:45:08 +01:00
decode CIE
This commit is contained in:
parent
e3246ede0b
commit
c4dd3a7153
5 changed files with 194 additions and 37 deletions
|
|
@ -23,6 +23,7 @@ struct dl_find_object {
|
|||
dlfo_map_start: *const ffi::c_void,
|
||||
dlfo_map_end: *const ffi::c_void,
|
||||
dlf_link_map: *const ffi::c_void,
|
||||
/// A pointer to the `PT_GNU_EH_FRAME` segment (the `.eh_frame_hdr` section).
|
||||
dlfo_eh_frame: *const ffi::c_void,
|
||||
}
|
||||
|
||||
|
|
@ -30,12 +31,6 @@ extern "C" {
|
|||
fn _dl_find_object(address: *const ffi::c_void, result: *mut dl_find_object) -> ffi::c_int;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct DwarfInfo {
|
||||
/// A pointer to the `PT_GNU_EH_FRAME` segment (the `.eh_frame_hdr` section).
|
||||
pub(crate) eh_frame_hdr: *const u8,
|
||||
}
|
||||
|
||||
/// The `.eh_frame_hdr` section.
|
||||
/// See <https://refspecs.linuxfoundation.org/LSB_1.3.0/gLSB/gLSB/ehframehdr.html>
|
||||
/// and <https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html>.
|
||||
|
|
@ -78,7 +73,7 @@ fn eh_frame_hdr_ptr(addr: Addr) -> Option<*const EhFrameHeader> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn dwarf_info(addr: Addr) -> Option<DwarfInfo> {
|
||||
pub(crate) fn eh_frame(addr: Addr) -> Option<*const u8> {
|
||||
unsafe {
|
||||
let ptr = eh_frame_hdr_ptr(addr)?;
|
||||
let header = ptr.read();
|
||||
|
|
@ -99,10 +94,12 @@ pub(crate) fn dwarf_info(addr: Addr) -> Option<DwarfInfo> {
|
|||
|
||||
trace!(
|
||||
"eh_frame start: {:x?}",
|
||||
core::slice::from_raw_parts(eh_frame_ptr as *const u8, 10)
|
||||
core::slice::from_raw_parts(eh_frame_ptr as *const u8, 15)
|
||||
);
|
||||
|
||||
crate::stdext::abort();
|
||||
crate::dwarf::uwutables(eh_frame_ptr as *const u8);
|
||||
|
||||
Some(eh_frame_ptr as *const u8)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -118,8 +115,6 @@ unsafe fn read_encoded(ptr: *const u8, encoding: Encoding) -> (*const u8, usize)
|
|||
ValueFormat::DW_EH_PE_sdata8 => (ptr.add(8), ptr.cast::<i64>().read_unaligned() as usize),
|
||||
};
|
||||
|
||||
trace!("{ptr:p}, {value}");
|
||||
|
||||
let value = match encoding.application() {
|
||||
ValueApplication::DW_EH_PE_absptr => value,
|
||||
ValueApplication::DW_EH_PE_pcrel => ((value as isize) + (ptr as isize)) as usize,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue