mirror of
https://github.com/encounter/objdiff.git
synced 2026-07-10 12:18:36 -07:00
Merge branch 'refs/heads/main' into line-info
# Conflicts: # objdiff-core/src/arch/x86.rs
This commit is contained in:
@@ -52,6 +52,7 @@ impl ObjArch for ObjArchMips {
|
||||
let code = self.endianness.read_u32_bytes(chunk.try_into()?);
|
||||
let instruction = Instruction::new(code, cur_addr, InstrCategory::CPU);
|
||||
|
||||
let formatted = instruction.disassemble(None, 0);
|
||||
let op = instruction.unique_id as u16;
|
||||
ops.push(op);
|
||||
|
||||
@@ -124,6 +125,7 @@ impl ObjArch for ObjArchMips {
|
||||
reloc: reloc.cloned(),
|
||||
branch_dest,
|
||||
line,
|
||||
formatted,
|
||||
orig: None,
|
||||
});
|
||||
cur_addr += 4;
|
||||
|
||||
@@ -62,6 +62,7 @@ impl ObjArch for ObjArchPpc {
|
||||
|
||||
let orig = ins.basic().to_string();
|
||||
let simplified = ins.simplified();
|
||||
let formatted = simplified.to_string();
|
||||
|
||||
let mut reloc_arg = None;
|
||||
if let Some(reloc) = reloc {
|
||||
@@ -145,6 +146,7 @@ impl ObjArch for ObjArchPpc {
|
||||
op: ins.op as u16,
|
||||
branch_dest,
|
||||
line,
|
||||
formatted,
|
||||
orig: Some(orig),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ impl ObjArch for ObjArchX86 {
|
||||
reloc: None,
|
||||
branch_dest: None,
|
||||
line: None,
|
||||
formatted: String::new(),
|
||||
orig: None,
|
||||
},
|
||||
error: None,
|
||||
@@ -84,6 +85,7 @@ impl ObjArch for ObjArchX86 {
|
||||
reloc: reloc.cloned(),
|
||||
branch_dest: None,
|
||||
line: line_info.and_then(|m| m.get(&address).cloned()),
|
||||
formatted: String::new(),
|
||||
orig: None,
|
||||
};
|
||||
// Run the formatter, which will populate output.ins
|
||||
@@ -92,7 +94,7 @@ impl ObjArch for ObjArchX86 {
|
||||
return Err(error);
|
||||
}
|
||||
ensure!(output.ins_operands.len() == output.ins.args.len());
|
||||
output.ins.orig = Some(output.formatted.clone());
|
||||
output.ins.formatted.clone_from(&output.formatted);
|
||||
|
||||
// Make sure we've put the relocation somewhere in the instruction
|
||||
if reloc.is_some() && !output.ins.args.iter().any(|a| matches!(a, ObjInsArg::Reloc)) {
|
||||
|
||||
@@ -39,7 +39,7 @@ pub fn diff_code(
|
||||
config: &DiffObjConfig,
|
||||
) -> Result<(ObjSymbolDiff, ObjSymbolDiff)> {
|
||||
let left_out = left_obj.arch.process_code(left_obj, left_symbol_ref, config)?;
|
||||
let right_out = left_obj.arch.process_code(right_obj, right_symbol_ref, config)?;
|
||||
let right_out = right_obj.arch.process_code(right_obj, right_symbol_ref, config)?;
|
||||
|
||||
let mut left_diff = Vec::<ObjInsDiff>::new();
|
||||
let mut right_diff = Vec::<ObjInsDiff>::new();
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::{
|
||||
obj::{ObjInsArg, ObjInsArgValue, ObjReloc, ObjSymbol},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum DiffText<'a> {
|
||||
/// Basic text
|
||||
Basic(&'a str),
|
||||
@@ -95,8 +95,8 @@ fn display_reloc_name<E>(
|
||||
) -> Result<(), E> {
|
||||
cb(DiffText::Symbol(&reloc.target))?;
|
||||
match reloc.target.addend.cmp(&0i64) {
|
||||
Ordering::Greater => cb(DiffText::Basic(&format!("+{:#X}", reloc.target.addend))),
|
||||
Ordering::Less => cb(DiffText::Basic(&format!("-{:#X}", -reloc.target.addend))),
|
||||
Ordering::Greater => cb(DiffText::Basic(&format!("+{:#x}", reloc.target.addend))),
|
||||
Ordering::Less => cb(DiffText::Basic(&format!("-{:#x}", -reloc.target.addend))),
|
||||
_ => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,8 @@ pub struct ObjIns {
|
||||
pub branch_dest: Option<u64>,
|
||||
/// Line number
|
||||
pub line: Option<u64>,
|
||||
/// Formatted instruction
|
||||
pub formatted: String,
|
||||
/// Original (unsimplified) instruction
|
||||
pub orig: Option<String>,
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ fn relocations_by_section(
|
||||
} else {
|
||||
reloc.addend()
|
||||
};
|
||||
// println!("Reloc: {reloc:?}, symbol: {symbol:?}, addend: {addend:#X}");
|
||||
// println!("Reloc: {reloc:?}, symbol: {symbol:?}, addend: {addend:#x}");
|
||||
let target = match symbol.kind() {
|
||||
SymbolKind::Text | SymbolKind::Data | SymbolKind::Label | SymbolKind::Unknown => {
|
||||
to_obj_symbol(arch, obj_file, &symbol, addend, split_meta)
|
||||
|
||||
Reference in New Issue
Block a user