From 6d7d0242b472327cd8a709b5db5cfeec96411a19 Mon Sep 17 00:00:00 2001 From: Amber Brault Date: Sat, 21 Mar 2026 01:10:14 +0100 Subject: [PATCH 1/6] Bleh --- objdiff-core/src/arch/arm.rs | 2 +- objdiff-core/src/arch/mod.rs | 2 +- objdiff-core/src/arch/ppc/mod.rs | 12 ++++++++++++ objdiff-core/src/obj/read.rs | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/objdiff-core/src/arch/arm.rs b/objdiff-core/src/arch/arm.rs index a8feea7..70374ff 100644 --- a/objdiff-core/src/arch/arm.rs +++ b/objdiff-core/src/arch/arm.rs @@ -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); } diff --git a/objdiff-core/src/arch/mod.rs b/objdiff-core/src/arch/mod.rs index 30179fd..94affdb 100644 --- a/objdiff-core/src/arch/mod.rs +++ b/objdiff-core/src/arch/mod.rs @@ -340,7 +340,7 @@ 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. /// diff --git a/objdiff-core/src/arch/ppc/mod.rs b/objdiff-core/src/arch/ppc/mod.rs index 7f06f31..3f2e85c 100644 --- a/objdiff-core/src/arch/ppc/mod.rs +++ b/objdiff-core/src/arch/ppc/mod.rs @@ -472,6 +472,18 @@ 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 + if let Some(extab) = self.extab.as_ref() { + let new_map: BTreeMap = extab.iter().map(|e| { + (symbol_indices[*e.0 + 1], e.1.clone()) + }).collect(); + + self.extab.replace(new_map); + } + + } } impl ArchPpc { diff --git a/objdiff-core/src/obj/read.rs b/objdiff-core/src/obj/read.rs index e78e501..6046070 100644 --- a/objdiff-core/src/obj/read.rs +++ b/objdiff-core/src/obj/read.rs @@ -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(§ions, &mut symbols); - arch.post_init(§ions, &symbols); + arch.post_init(§ions, &symbols, &symbol_indices); let mut obj = Object { arch, endianness: obj_file.endianness(), From 085913446ee9fcd9312400de5aba64db2262ccce Mon Sep 17 00:00:00 2001 From: Amber Brault Date: Sat, 21 Mar 2026 01:27:06 +0100 Subject: [PATCH 2/6] Fix formatting --- objdiff-core/src/arch/mod.rs | 3 ++- objdiff-core/src/arch/ppc/mod.rs | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/objdiff-core/src/arch/mod.rs b/objdiff-core/src/arch/mod.rs index 94affdb..59da3cc 100644 --- a/objdiff-core/src/arch/mod.rs +++ b/objdiff-core/src/arch/mod.rs @@ -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], _symbol_indices: &[usize]) {} + 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. /// diff --git a/objdiff-core/src/arch/ppc/mod.rs b/objdiff-core/src/arch/ppc/mod.rs index 3f2e85c..7f658a4 100644 --- a/objdiff-core/src/arch/ppc/mod.rs +++ b/objdiff-core/src/arch/ppc/mod.rs @@ -476,13 +476,11 @@ impl Arch for ArchPpc { 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 if let Some(extab) = self.extab.as_ref() { - let new_map: BTreeMap = extab.iter().map(|e| { - (symbol_indices[*e.0 + 1], e.1.clone()) - }).collect(); + let new_map: BTreeMap = + extab.iter().map(|e| (symbol_indices[*e.0 + 1], e.1.clone())).collect(); self.extab.replace(new_map); } - } } From 03332e9ffff7a2631086f4d309cffd53f2bc3c05 Mon Sep 17 00:00:00 2001 From: Amber Brault Date: Sat, 21 Mar 2026 01:32:39 +0100 Subject: [PATCH 3/6] Update arch_ppc__read_extab.snap --- objdiff-core/tests/snapshots/arch_ppc__read_extab.snap | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/objdiff-core/tests/snapshots/arch_ppc__read_extab.snap b/objdiff-core/tests/snapshots/arch_ppc__read_extab.snap index 8f06216..4a2911a 100644 --- a/objdiff-core/tests/snapshots/arch_ppc__read_extab.snap +++ b/objdiff-core/tests/snapshots/arch_ppc__read_extab.snap @@ -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", From 8b3bb288011fd673aafe09518b15cbee79fbc80d Mon Sep 17 00:00:00 2001 From: Amber Brault Date: Sat, 21 Mar 2026 16:07:28 +0100 Subject: [PATCH 4/6] Put code in separate function --- objdiff-core/src/arch/ppc/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/objdiff-core/src/arch/ppc/mod.rs b/objdiff-core/src/arch/ppc/mod.rs index 7f658a4..7ec873b 100644 --- a/objdiff-core/src/arch/ppc/mod.rs +++ b/objdiff-core/src/arch/ppc/mod.rs @@ -475,10 +475,7 @@ impl Arch for ArchPpc { 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 - if let Some(extab) = self.extab.as_ref() { - let new_map: BTreeMap = - extab.iter().map(|e| (symbol_indices[*e.0 + 1], e.1.clone())).collect(); - + if let Some(new_map) = Self::convert_extab_map_indices(&self, symbol_indices) { self.extab.replace(new_map); } } @@ -488,6 +485,13 @@ 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> { + let new_map: BTreeMap = + self.extab.as_ref()?.iter().map(|e| (symbol_indices[*e.0 + 1], e.1.clone())).collect(); + + return Some(new_map) + } } fn zero_reloc(code: u32, reloc: &Relocation) -> u32 { From 7b34b557602724d6e718b38f3b90f812dab5c829 Mon Sep 17 00:00:00 2001 From: Amber Brault Date: Sat, 21 Mar 2026 16:11:45 +0100 Subject: [PATCH 5/6] Make compiler shut up --- objdiff-core/src/arch/ppc/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/objdiff-core/src/arch/ppc/mod.rs b/objdiff-core/src/arch/ppc/mod.rs index 7ec873b..2727560 100644 --- a/objdiff-core/src/arch/ppc/mod.rs +++ b/objdiff-core/src/arch/ppc/mod.rs @@ -475,7 +475,7 @@ impl Arch for ArchPpc { 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 - if let Some(new_map) = Self::convert_extab_map_indices(&self, symbol_indices) { + if let Some(new_map) = Self::convert_extab_map_indices(self, symbol_indices) { self.extab.replace(new_map); } } @@ -486,11 +486,14 @@ impl ArchPpc { self.extab.as_ref()?.get(&symbol_index) } - pub fn convert_extab_map_indices(&self, symbol_indices: &[usize]) -> Option> { + pub fn convert_extab_map_indices( + &self, + symbol_indices: &[usize] + ) -> Option> { let new_map: BTreeMap = self.extab.as_ref()?.iter().map(|e| (symbol_indices[*e.0 + 1], e.1.clone())).collect(); - return Some(new_map) + Some(new_map) } } From 472d54e812ed6f9909c05c090112d26b56ffe21f Mon Sep 17 00:00:00 2001 From: Amber Brault Date: Sat, 21 Mar 2026 16:15:24 +0100 Subject: [PATCH 6/6] Update mod.rs --- objdiff-core/src/arch/ppc/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/objdiff-core/src/arch/ppc/mod.rs b/objdiff-core/src/arch/ppc/mod.rs index 2727560..b8a6bab 100644 --- a/objdiff-core/src/arch/ppc/mod.rs +++ b/objdiff-core/src/arch/ppc/mod.rs @@ -475,9 +475,7 @@ impl Arch for ArchPpc { 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 - if let Some(new_map) = Self::convert_extab_map_indices(self, symbol_indices) { - self.extab.replace(new_map); - } + self.extab = Self::convert_extab_map_indices(self, symbol_indices); } } @@ -488,7 +486,7 @@ impl ArchPpc { pub fn convert_extab_map_indices( &self, - symbol_indices: &[usize] + symbol_indices: &[usize], ) -> Option> { let new_map: BTreeMap = self.extab.as_ref()?.iter().map(|e| (symbol_indices[*e.0 + 1], e.1.clone())).collect();