diff --git a/src/libdwarf/src/eh.rs b/src/libdwarf/src/eh.rs index aa79e7d..9cac2f3 100644 --- a/src/libdwarf/src/eh.rs +++ b/src/libdwarf/src/eh.rs @@ -75,17 +75,23 @@ unsafe fn get_ttype_entry( ttype_base: usize, ttype: *const u8, ) -> Result, ()> { + if encoding != DW_EH_PE_absptr { + return Err(()); + } + let i = (offset * size_of_encoded_value(encoding)) as isize; - read_encoded_pointer_with_base( - &mut DwarfReader::new(ttype.offset(-i)), - // the DW_EH_PE_pcrel is a hack. - // It seems that the default encoding is absolute, but we have to take reallocation into - // account. Unsure if we can fix this in the compiler setting or if this would be affected - // by updating the compiler - encoding | DW_EH_PE_pcrel, - ttype_base, - ) - .map(|v| (v != ttype_base).then(|| v as *const u8)) + + // Read in a target2 value. See "Personality routine exception-handling table + // entries" in the ehabi32 spec, and the ARM_EHABI version of `get_shim_type_info` + // in LLVM's libcxxabi/src/cxa_personality.cpp. + let mut reader = DwarfReader::new(ttype.offset(-i)); + let original_ptr = reader.ptr; + let offset = reader.read::(); + if (offset == 0) { + Ok(None) + } else { + Ok(Some(original_ptr.add(offset))) + } } pub unsafe fn find_eh_action(