Skip to content

Commit ab0538e

Browse files
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
1 parent b643265 commit ab0538e

5 files changed

Lines changed: 22 additions & 6 deletions

File tree

objdiff-core/src/arch/arm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl ArchArm {
162162
}
163163

164164
impl Arch for ArchArm {
165-
fn post_init(&mut self, sections: &[Section], symbols: &[Symbol]) {
165+
fn post_init(&mut self, sections: &[Section], symbols: &[Symbol], _symbol_indices: &[usize]) {
166166
self.disasm_modes = Self::get_mapping_symbols(sections, symbols);
167167
}
168168

objdiff-core/src/arch/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ impl dyn Arch {
340340

341341
pub trait Arch: Any + Debug + Send + Sync {
342342
/// Finishes arch-specific initialization that must be done after sections have been combined.
343-
fn post_init(&mut self, _sections: &[Section], _symbols: &[Symbol]) {}
343+
fn post_init(&mut self, _sections: &[Section], _symbols: &[Symbol], _symbol_indices: &[usize]) {
344+
}
344345

345346
/// Generate a list of instructions references (offset, size, opcode) from the given code.
346347
///

objdiff-core/src/arch/ppc/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,27 @@ impl Arch for ArchPpc {
472472
}
473473
Ok(next_address.saturating_sub(symbol.address))
474474
}
475+
476+
fn post_init(&mut self, _sections: &[Section], _symbols: &[Symbol], symbol_indices: &[usize]) {
477+
// Change the indices used as keys from the original symbol indices to the new symbol array indices
478+
self.extab = Self::convert_extab_map_indices(self, symbol_indices);
479+
}
475480
}
476481

477482
impl ArchPpc {
478483
pub fn extab_for_symbol(&self, symbol_index: usize) -> Option<&ExceptionInfo> {
479484
self.extab.as_ref()?.get(&symbol_index)
480485
}
486+
487+
pub fn convert_extab_map_indices(
488+
&self,
489+
symbol_indices: &[usize],
490+
) -> Option<BTreeMap<usize, ExceptionInfo>> {
491+
let new_map: BTreeMap<usize, ExceptionInfo> =
492+
self.extab.as_ref()?.iter().map(|e| (symbol_indices[*e.0 + 1], e.1.clone())).collect();
493+
494+
Some(new_map)
495+
}
481496
}
482497

483498
fn zero_reloc(code: u32, reloc: &Relocation) -> u32 {

objdiff-core/src/obj/read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ pub fn parse(data: &[u8], config: &DiffObjConfig, diff_side: DiffSide) -> Result
10891089
combine_sections(&mut sections, &mut symbols, config)?;
10901090
}
10911091
add_section_symbols(&sections, &mut symbols);
1092-
arch.post_init(&sections, &symbols);
1092+
arch.post_init(&sections, &symbols, &symbol_indices);
10931093
let mut obj = Object {
10941094
arch,
10951095
endianness: obj_file.endianness(),

objdiff-core/tests/snapshots/arch_ppc__read_extab.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Object {
99
),
1010
extab: Some(
1111
{
12-
10: ExceptionInfo {
12+
1: ExceptionInfo {
1313
eti_symbol: ExtabSymbolRef {
1414
original_index: 5,
1515
name: "@31",
@@ -35,7 +35,7 @@ Object {
3535
},
3636
dtors: [],
3737
},
38-
11: ExceptionInfo {
38+
2: ExceptionInfo {
3939
eti_symbol: ExtabSymbolRef {
4040
original_index: 7,
4141
name: "@52",
@@ -95,7 +95,7 @@ Object {
9595
},
9696
],
9797
},
98-
12: ExceptionInfo {
98+
3: ExceptionInfo {
9999
eti_symbol: ExtabSymbolRef {
100100
original_index: 9,
101101
name: "@60",

0 commit comments

Comments
 (0)