libdwarf: make catch type field singly referenced #192

Merged
sb10q merged 1 commits from occheung/artiq-zynq:target2-rel into master 2022-05-31 18:26:30 +08:00
1 changed files with 11 additions and 8 deletions
Showing only changes of commit b296bef855 - Show all commits

View File

@ -72,7 +72,7 @@ unsafe fn get_ttype_entry(
encoding: u8, encoding: u8,
ttype_base: usize, ttype_base: usize,
ttype: *const u8, ttype: *const u8,
) -> Result<*const u8, ()> { ) -> Result<Option<*const u8>, ()> {
let i = (offset * size_of_encoded_value(encoding)) as isize; let i = (offset * size_of_encoded_value(encoding)) as isize;
read_encoded_pointer_with_base( read_encoded_pointer_with_base(
&mut DwarfReader::new(ttype.offset(-i)), &mut DwarfReader::new(ttype.offset(-i)),
@ -83,7 +83,10 @@ unsafe fn get_ttype_entry(
encoding | DW_EH_PE_pcrel, encoding | DW_EH_PE_pcrel,
ttype_base, ttype_base,
) )
.map(|v| v as *const u8) .map(|v| match v {
ttype_base => None,
ttype_entry => Some(ttype_entry as *const u8),
})
} }
pub unsafe fn find_eh_action( pub unsafe fn find_eh_action(
@ -163,12 +166,12 @@ pub unsafe fn find_eh_action(
ttype_base, ttype_base,
ttype_table, ttype_table,
)?; )?;
let clause_ptr = *(catch_type as *const *const u32); match catch_type {
if clause_ptr.is_null() { Some(clause_ptr) if *(clause_ptr as *const u32) == id => {
return Ok(EHAction::Catch(lpad)); return Ok(EHAction::Catch(lpad))
} }
if *clause_ptr == id { None => return Ok(EHAction::Catch(lpad)),
return Ok(EHAction::Catch(lpad)); _ => {}
} }
} else if ar_filter < 0 { } else if ar_filter < 0 {
// FIXME: how to handle this? // FIXME: how to handle this?