mirror of https://github.com/encounter/objdiff.git
Compare commits
3 Commits
cd46be7726
...
2f778932a4
Author | SHA1 | Date |
---|---|---|
Luke Street | 2f778932a4 | |
Luke Street | 42601b4750 | |
Luke Street | 636a8e00c5 |
|
@ -620,9 +620,9 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cwdemangle"
|
name = "cwdemangle"
|
||||||
version = "0.1.4"
|
version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c6db639f6653b14e5d248de711796d8a082a19bfd242a2bba03051074cd3498e"
|
checksum = "b58d34a3a03cfe0a4ebfd03aeda6ee8a0f2e99bd3308476a8a89815add3ec373"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argh",
|
"argh",
|
||||||
]
|
]
|
||||||
|
@ -2189,7 +2189,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objdiff"
|
name = "objdiff"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "objdiff"
|
name = "objdiff"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.65"
|
rust-version = "1.65"
|
||||||
authors = ["Luke Street <luke@street.dev>"]
|
authors = ["Luke Street <luke@street.dev>"]
|
||||||
|
@ -25,7 +25,7 @@ anyhow = "1.0.68"
|
||||||
bytes = "1.3.0"
|
bytes = "1.3.0"
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
const_format = "0.2.30"
|
const_format = "0.2.30"
|
||||||
cwdemangle = "0.1.4"
|
cwdemangle = "0.1.5"
|
||||||
eframe = { version = "0.20.1", features = ["persistence"] }
|
eframe = { version = "0.20.1", features = ["persistence"] }
|
||||||
egui = "0.20.1"
|
egui = "0.20.1"
|
||||||
egui_extras = "0.20.0"
|
egui_extras = "0.20.0"
|
||||||
|
|
59
src/diff.rs
59
src/diff.rs
|
@ -362,20 +362,26 @@ fn compare_ins(
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_symbol<'a>(symbols: &'a mut [ObjSymbol], name: &str) -> Option<&'a mut ObjSymbol> {
|
fn find_section_and_symbol(obj: &ObjInfo, name: &str) -> Option<(usize, usize)> {
|
||||||
symbols.iter_mut().find(|s| s.name == name)
|
for (section_idx, section) in obj.sections.iter().enumerate() {
|
||||||
|
let symbol_idx = match section.symbols.iter().position(|symbol| symbol.name == name) {
|
||||||
|
Some(symbol_idx) => symbol_idx,
|
||||||
|
None => continue,
|
||||||
|
};
|
||||||
|
return Some((section_idx, symbol_idx));
|
||||||
|
}
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn diff_objs(left: &mut ObjInfo, right: &mut ObjInfo, _diff_config: &DiffConfig) -> Result<()> {
|
pub fn diff_objs(left: &mut ObjInfo, right: &mut ObjInfo, _diff_config: &DiffConfig) -> Result<()> {
|
||||||
for left_section in &mut left.sections {
|
for left_section in &mut left.sections {
|
||||||
let Some(right_section) = right.sections.iter_mut().find(|s| s.name == left_section.name) else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
if left_section.kind == ObjSectionKind::Code {
|
if left_section.kind == ObjSectionKind::Code {
|
||||||
for left_symbol in &mut left_section.symbols {
|
for left_symbol in &mut left_section.symbols {
|
||||||
if let Some(right_symbol) =
|
if let Some((right_section_idx, right_symbol_idx)) =
|
||||||
find_symbol(&mut right_section.symbols, &left_symbol.name)
|
find_section_and_symbol(right, &left_symbol.name)
|
||||||
{
|
{
|
||||||
|
let right_section = &mut right.sections[right_section_idx];
|
||||||
|
let right_symbol = &mut right_section.symbols[right_symbol_idx];
|
||||||
left_symbol.diff_symbol = Some(right_symbol.name.clone());
|
left_symbol.diff_symbol = Some(right_symbol.name.clone());
|
||||||
right_symbol.diff_symbol = Some(left_symbol.name.clone());
|
right_symbol.diff_symbol = Some(left_symbol.name.clone());
|
||||||
diff_code(
|
diff_code(
|
||||||
|
@ -399,22 +405,29 @@ pub fn diff_objs(left: &mut ObjInfo, right: &mut ObjInfo, _diff_config: &DiffCon
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for right_symbol in &mut right_section.symbols {
|
} else {
|
||||||
if right_symbol.instructions.is_empty() {
|
let Some(right_section) = right.sections.iter_mut().find(|s| s.name == left_section.name) else {
|
||||||
no_diff_code(
|
continue;
|
||||||
left.architecture,
|
};
|
||||||
&right_section.data,
|
if left_section.kind == ObjSectionKind::Data {
|
||||||
right_symbol,
|
diff_data(left_section, right_section);
|
||||||
&right_section.relocations,
|
// diff_data_symbols(left_section, right_section)?;
|
||||||
&left.line_info,
|
} else if left_section.kind == ObjSectionKind::Bss {
|
||||||
)?;
|
diff_bss_symbols(&mut left_section.symbols, &mut right_section.symbols)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for right_section in right.sections.iter_mut().filter(|s| s.kind == ObjSectionKind::Code) {
|
||||||
|
for right_symbol in &mut right_section.symbols {
|
||||||
|
if right_symbol.instructions.is_empty() {
|
||||||
|
no_diff_code(
|
||||||
|
right.architecture,
|
||||||
|
&right_section.data,
|
||||||
|
right_symbol,
|
||||||
|
&right_section.relocations,
|
||||||
|
&right.line_info,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
} else if left_section.kind == ObjSectionKind::Data {
|
|
||||||
diff_data(left_section, right_section);
|
|
||||||
// diff_data_symbols(left_section, right_section)?;
|
|
||||||
} else if left_section.kind == ObjSectionKind::Bss {
|
|
||||||
diff_bss_symbols(&mut left_section.symbols, &mut right_section.symbols)?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff_bss_symbols(&mut left.common, &mut right.common)?;
|
diff_bss_symbols(&mut left.common, &mut right.common)?;
|
||||||
|
@ -423,7 +436,7 @@ pub fn diff_objs(left: &mut ObjInfo, right: &mut ObjInfo, _diff_config: &DiffCon
|
||||||
|
|
||||||
fn diff_bss_symbols(left_symbols: &mut [ObjSymbol], right_symbols: &mut [ObjSymbol]) -> Result<()> {
|
fn diff_bss_symbols(left_symbols: &mut [ObjSymbol], right_symbols: &mut [ObjSymbol]) -> Result<()> {
|
||||||
for left_symbol in left_symbols {
|
for left_symbol in left_symbols {
|
||||||
if let Some(right_symbol) = find_symbol(right_symbols, &left_symbol.name) {
|
if let Some(right_symbol) = right_symbols.iter_mut().find(|s| s.name == left_symbol.name) {
|
||||||
left_symbol.diff_symbol = Some(right_symbol.name.clone());
|
left_symbol.diff_symbol = Some(right_symbol.name.clone());
|
||||||
right_symbol.diff_symbol = Some(left_symbol.name.clone());
|
right_symbol.diff_symbol = Some(left_symbol.name.clone());
|
||||||
let percent = if left_symbol.size == right_symbol.size { 100.0 } else { 50.0 };
|
let percent = if left_symbol.size == right_symbol.size { 100.0 } else { 50.0 };
|
||||||
|
|
Loading…
Reference in New Issue