mirror of
https://github.com/encounter/objdiff.git
synced 2025-12-12 22:56:19 +00:00
PPC: Reimplement pooled data reference calculation (#167)
* PPC: Calculate pooled relocations Reimplements #140 The relocations are now generated when the object is first read in `parse`, right after the real relocations are read. `resolve_relocation` was changed to take `obj.symbols` instead of `obj` as an argument, because `obj` itself doesn't exist yet at the time the relocations are being read. * Improve readability of PPC pool relocs code * Fix regression causing extern pool relocs to be ignored * Fix showing incorrect diff when diffing weak stripped symbol with an addend This is a regression that was introduced by #158 diffing addends in addition to symbol names. But it's not really a bug in that PR, rather it seems like I simply never added the offset into the addend when creating a fake pool relocation for an extern symbol. So this commit fixes that root issue instead. * Add PPC "Calculate pooled data references" option * Fix objdiff-wasm compilation errors * Update PPC test snapshots
This commit is contained in:
@@ -502,17 +502,3 @@ fn diff_instruction(
|
||||
|
||||
Ok(InstructionDiffResult::new(InstructionDiffKind::None))
|
||||
}
|
||||
|
||||
// TODO
|
||||
// fn find_symbol_matching_fake_symbol_in_sections(
|
||||
// fake_symbol: &ObjSymbol,
|
||||
// sections: &[ObjSection],
|
||||
// ) -> Option<ObjSymbol> {
|
||||
// let orig_section_index = fake_symbol.orig_section_index?;
|
||||
// let section = sections.iter().find(|s| s.orig_index == orig_section_index)?;
|
||||
// let real_symbol = section
|
||||
// .symbols
|
||||
// .iter()
|
||||
// .find(|s| s.size > 0 && (s.address..s.address + s.size).contains(&fake_symbol.address))?;
|
||||
// Some(real_symbol.clone())
|
||||
// }
|
||||
|
||||
@@ -8,7 +8,7 @@ use super::{
|
||||
code::{address_eq, section_name_eq},
|
||||
DataDiff, DataDiffKind, DataRelocationDiff, ObjectDiff, SectionDiff, SymbolDiff,
|
||||
};
|
||||
use crate::obj::{Object, Relocation, ResolvedRelocation, SymbolFlag, SymbolKind};
|
||||
use crate::obj::{Object, Relocation, ResolvedRelocation, Symbol, SymbolFlag, SymbolKind};
|
||||
|
||||
pub fn diff_bss_symbol(
|
||||
left_obj: &Object,
|
||||
@@ -64,10 +64,10 @@ fn reloc_eq(
|
||||
|
||||
#[inline]
|
||||
pub fn resolve_relocation<'obj>(
|
||||
obj: &'obj Object,
|
||||
symbols: &'obj [Symbol],
|
||||
reloc: &'obj Relocation,
|
||||
) -> ResolvedRelocation<'obj> {
|
||||
let symbol = &obj.symbols[reloc.target_symbol];
|
||||
let symbol = &symbols[reloc.target_symbol];
|
||||
ResolvedRelocation { relocation: reloc, symbol }
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ fn diff_data_relocs_for_range<'left, 'right>(
|
||||
continue;
|
||||
}
|
||||
let left_offset = left_reloc.address as usize - left_range.start;
|
||||
let left_reloc = resolve_relocation(left_obj, left_reloc);
|
||||
let left_reloc = resolve_relocation(&left_obj.symbols, left_reloc);
|
||||
let Some(right_reloc) = right_section.relocations.iter().find(|r| {
|
||||
if !right_range.contains(&(r.address as usize)) {
|
||||
return false;
|
||||
@@ -99,7 +99,7 @@ fn diff_data_relocs_for_range<'left, 'right>(
|
||||
diffs.push((DataDiffKind::Delete, Some(left_reloc), None));
|
||||
continue;
|
||||
};
|
||||
let right_reloc = resolve_relocation(right_obj, right_reloc);
|
||||
let right_reloc = resolve_relocation(&right_obj.symbols, right_reloc);
|
||||
if reloc_eq(left_obj, right_obj, left_reloc, right_reloc) {
|
||||
diffs.push((DataDiffKind::None, Some(left_reloc), Some(right_reloc)));
|
||||
} else {
|
||||
@@ -111,7 +111,7 @@ fn diff_data_relocs_for_range<'left, 'right>(
|
||||
continue;
|
||||
}
|
||||
let right_offset = right_reloc.address as usize - right_range.start;
|
||||
let right_reloc = resolve_relocation(right_obj, right_reloc);
|
||||
let right_reloc = resolve_relocation(&right_obj.symbols, right_reloc);
|
||||
let Some(_) = left_section.relocations.iter().find(|r| {
|
||||
if !left_range.contains(&(r.address as usize)) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user