Fix extab hover window display issue (#344)

* Bleh

* Fix formatting

* Update arch_ppc__read_extab.snap

* Put code in separate function

* Make compiler shut up

* Update mod.rs
This commit is contained in:
Amber Brault
2026-03-21 16:38:01 +01:00
committed by GitHub
parent b643265809
commit ab0538e9a4
5 changed files with 22 additions and 6 deletions
+1 -1
View File
@@ -162,7 +162,7 @@ impl ArchArm {
}
impl Arch for ArchArm {
fn post_init(&mut self, sections: &[Section], symbols: &[Symbol]) {
fn post_init(&mut self, sections: &[Section], symbols: &[Symbol], _symbol_indices: &[usize]) {
self.disasm_modes = Self::get_mapping_symbols(sections, symbols);
}
+2 -1
View File
@@ -340,7 +340,8 @@ impl dyn Arch {
pub trait Arch: Any + Debug + Send + Sync {
/// Finishes arch-specific initialization that must be done after sections have been combined.
fn post_init(&mut self, _sections: &[Section], _symbols: &[Symbol]) {}
fn post_init(&mut self, _sections: &[Section], _symbols: &[Symbol], _symbol_indices: &[usize]) {
}
/// Generate a list of instructions references (offset, size, opcode) from the given code.
///
+15
View File
@@ -472,12 +472,27 @@ impl Arch for ArchPpc {
}
Ok(next_address.saturating_sub(symbol.address))
}
fn post_init(&mut self, _sections: &[Section], _symbols: &[Symbol], symbol_indices: &[usize]) {
// Change the indices used as keys from the original symbol indices to the new symbol array indices
self.extab = Self::convert_extab_map_indices(self, symbol_indices);
}
}
impl ArchPpc {
pub fn extab_for_symbol(&self, symbol_index: usize) -> Option<&ExceptionInfo> {
self.extab.as_ref()?.get(&symbol_index)
}
pub fn convert_extab_map_indices(
&self,
symbol_indices: &[usize],
) -> Option<BTreeMap<usize, ExceptionInfo>> {
let new_map: BTreeMap<usize, ExceptionInfo> =
self.extab.as_ref()?.iter().map(|e| (symbol_indices[*e.0 + 1], e.1.clone())).collect();
Some(new_map)
}
}
fn zero_reloc(code: u32, reloc: &Relocation) -> u32 {
+1 -1
View File
@@ -1089,7 +1089,7 @@ pub fn parse(data: &[u8], config: &DiffObjConfig, diff_side: DiffSide) -> Result
combine_sections(&mut sections, &mut symbols, config)?;
}
add_section_symbols(&sections, &mut symbols);
arch.post_init(&sections, &symbols);
arch.post_init(&sections, &symbols, &symbol_indices);
let mut obj = Object {
arch,
endianness: obj_file.endianness(),
@@ -9,7 +9,7 @@ Object {
),
extab: Some(
{
10: ExceptionInfo {
1: ExceptionInfo {
eti_symbol: ExtabSymbolRef {
original_index: 5,
name: "@31",
@@ -35,7 +35,7 @@ Object {
},
dtors: [],
},
11: ExceptionInfo {
2: ExceptionInfo {
eti_symbol: ExtabSymbolRef {
original_index: 7,
name: "@52",
@@ -95,7 +95,7 @@ Object {
},
],
},
12: ExceptionInfo {
3: ExceptionInfo {
eti_symbol: ExtabSymbolRef {
original_index: 9,
name: "@60",