mirror of
https://github.com/Noratrieb/uwuwind.git
synced 2026-01-14 16:45:08 +01:00
add samples
This commit is contained in:
parent
764239958f
commit
2e191506ff
7 changed files with 105327 additions and 13 deletions
|
|
@ -11,7 +11,9 @@ edition = "2021"
|
||||||
libc = { version = "0.2.140", default-features = false, features = ["extra_traits"] }
|
libc = { version = "0.2.140", default-features = false, features = ["extra_traits"] }
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
panic = "abort"
|
# the test binary needs uwutables
|
||||||
|
panic = "unwind"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
panic = "abort"
|
# the test binary needs uwutables
|
||||||
|
panic = "unwind"
|
||||||
|
|
|
||||||
BIN
eh_frame.bin
Normal file
BIN
eh_frame.bin
Normal file
Binary file not shown.
105307
eh_frame.txt
Normal file
105307
eh_frame.txt
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -29,10 +29,8 @@ extern "C" {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct DwarfInfo {
|
pub struct DwarfInfo {
|
||||||
/// The text segment
|
|
||||||
pub(super) map: *const [u8],
|
|
||||||
/// PT_GNU_EH_FRAME
|
/// PT_GNU_EH_FRAME
|
||||||
pub(super) dwarf: *const u8,
|
pub(crate) eh_frame: *const u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dwarf_info(addr: *const ffi::c_void) -> Option<DwarfInfo> {
|
pub fn dwarf_info(addr: *const ffi::c_void) -> Option<DwarfInfo> {
|
||||||
|
|
@ -62,8 +60,7 @@ pub fn dwarf_info(addr: *const ffi::c_void) -> Option<DwarfInfo> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(DwarfInfo {
|
Some(DwarfInfo {
|
||||||
map: core::ptr::slice_from_raw_parts(out.dlfo_map_start as _, text_len),
|
eh_frame: out.dlfo_eh_frame as _,
|
||||||
dwarf: out.dlfo_eh_frame as _,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ mod parse;
|
||||||
|
|
||||||
pub use divination::{dwarf_info, DwarfInfo};
|
pub use divination::{dwarf_info, DwarfInfo};
|
||||||
|
|
||||||
pub fn uwutables(dwarf_info: DwarfInfo) {
|
pub unsafe fn uwutables(eh_frame: *const u8) {
|
||||||
trace!("getting uwutables from {:p}", dwarf_info.dwarf);
|
trace!("getting uwutables from {:p}", eh_frame);
|
||||||
unsafe {
|
unsafe {
|
||||||
parse::parse_cie(dwarf_info.dwarf);
|
parse::parse_cie(eh_frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod stdext;
|
||||||
pub mod uw;
|
pub mod uw;
|
||||||
|
|
||||||
mod arch;
|
mod arch;
|
||||||
mod dwarf;
|
pub mod dwarf;
|
||||||
mod identify;
|
mod identify;
|
||||||
|
|
||||||
mod walk;
|
mod walk;
|
||||||
|
|
@ -21,8 +21,7 @@ pub unsafe extern "C" fn _UnwindRaiseException(
|
||||||
) -> uw::_Unwind_Reason_Code {
|
) -> uw::_Unwind_Reason_Code {
|
||||||
trace!("someone raised an exception with addr {exception_object:p}");
|
trace!("someone raised an exception with addr {exception_object:p}");
|
||||||
let di = crate::dwarf::dwarf_info(arch::get_rip() as _).unwrap();
|
let di = crate::dwarf::dwarf_info(arch::get_rip() as _).unwrap();
|
||||||
crate::dwarf::uwutables(di);
|
crate::dwarf::uwutables(di.eh_frame);
|
||||||
// walk::fp::walk();
|
|
||||||
|
|
||||||
stdext::abort();
|
stdext::abort();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,19 @@
|
||||||
use uwuwind::uw;
|
use uwuwind::uw;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
#[allow(dead_code)]
|
||||||
struct Exception {
|
struct Exception {
|
||||||
_uwe: uw::_Unwind_Exception,
|
_uwe: uw::_Unwind_Exception,
|
||||||
uwu: &'static str,
|
uwu: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
let eh_frame = std::fs::read("eh_frame.bin").expect("could not find ./eh_frame.bin");
|
||||||
|
unsafe {
|
||||||
|
uwuwind::dwarf::uwutables(eh_frame.as_ptr());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
/*
|
||||||
unsafe {
|
unsafe {
|
||||||
uwuwind::set_personality_routine(personality_routine);
|
uwuwind::set_personality_routine(personality_routine);
|
||||||
|
|
||||||
|
|
@ -22,8 +29,10 @@ fn main() {
|
||||||
|
|
||||||
uwuwind::_UnwindRaiseException(exception.cast::<uw::_Unwind_Exception>());
|
uwuwind::_UnwindRaiseException(exception.cast::<uw::_Unwind_Exception>());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn personality_routine(
|
fn personality_routine(
|
||||||
_version: i32,
|
_version: i32,
|
||||||
_actions: uw::_UnwindAction,
|
_actions: uw::_UnwindAction,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue