Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion objdiff-cli/src/cmd/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ fn report_object(
}
_ => {}
}
let diff_config = diff::DiffObjConfig { relax_reloc_diffs: true, ..Default::default() };
let diff_config = diff::DiffObjConfig {
function_reloc_diffs: diff::FunctionRelocDiffs::None,
..Default::default()
};
let mapping_config = diff::MappingConfig::default();
let target = object
.target_path
Expand Down
13 changes: 9 additions & 4 deletions objdiff-cli/src/views/function_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crossterm::event::{Event, KeyCode, KeyEventKind, KeyModifiers, MouseButton,
use objdiff_core::{
diff::{
display::{display_diff, DiffText, HighlightKind},
ObjDiff, ObjInsDiffKind, ObjSymbolDiff,
FunctionRelocDiffs, ObjDiff, ObjInsDiffKind, ObjSymbolDiff,
},
obj::{ObjInfo, ObjSectionKind, ObjSymbol, SymbolRef},
};
Expand Down Expand Up @@ -368,10 +368,15 @@ impl UiView for FunctionDiffUi {
self.scroll_x = self.scroll_x.saturating_sub(1);
result.redraw = true;
}
// Toggle relax relocation diffs
// Cycle through function relocation diff mode
KeyCode::Char('x') => {
state.diff_obj_config.relax_reloc_diffs =
!state.diff_obj_config.relax_reloc_diffs;
state.diff_obj_config.function_reloc_diffs =
match state.diff_obj_config.function_reloc_diffs {
FunctionRelocDiffs::None => FunctionRelocDiffs::NameAddress,
FunctionRelocDiffs::NameAddress => FunctionRelocDiffs::DataValue,
FunctionRelocDiffs::DataValue => FunctionRelocDiffs::All,
FunctionRelocDiffs::All => FunctionRelocDiffs::None,
};
result.redraw = true;
return EventControlFlow::Reload;
}
Expand Down
30 changes: 24 additions & 6 deletions objdiff-core/config-schema.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
{
"properties": [
{
"id": "relaxRelocDiffs",
"type": "boolean",
"default": false,
"name": "Relax relocation diffs",
"description": "Ignores differences in relocation targets. (Address, name, etc)"
"id": "functionRelocDiffs",
"type": "choice",
"default": "name_address",
"name": "Function relocation diffs",
"description": "How relocation targets will be diffed in the function view.",
"items": [
{
"value": "none",
"name": "None"
},
{
"value": "name_address",
"name": "Name or address"
},
{
"value": "data_value",
"name": "Data value"
},
{
"value": "all",
"name": "Name or address, data value"
}
]
},
{
"id": "spaceBetweenArgs",
Expand Down Expand Up @@ -193,7 +211,7 @@
"id": "general",
"name": "General",
"properties": [
"relaxRelocDiffs",
"functionRelocDiffs",
"spaceBetweenArgs",
"combineDataSections"
]
Expand Down
11 changes: 11 additions & 0 deletions objdiff-core/src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ pub trait ObjArch: Send + Sync {
Some(format!("Bytes: {:#x?}", bytes))
}

fn display_ins_data(&self, ins: &ObjIns) -> Option<String> {
let reloc = ins.reloc.as_ref()?;
if reloc.addend >= 0 && reloc.target.bytes.len() > reloc.addend as usize {
self.guess_data_type(ins).and_then(|ty| {
self.display_data_type(ty, &reloc.target.bytes[reloc.addend as usize..])
})
} else {
None
}
}

// Downcast methods
#[cfg(feature = "ppc")]
fn ppc(&self) -> Option<&ppc::ObjArchPpc> { None }
Expand Down
Loading
Loading