Skip to content

Commit ed5d092

Browse files
authored
objdiff-cli diff: Support "Relax relocation diffs" (#50)
Bound to the `-x` flag or the `x` key.
1 parent 023dd7a commit ed5d092

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

objdiff-cli/src/cmd/diff.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ pub struct Args {
4343
#[argp(option, short = 'u')]
4444
/// Unit name within project
4545
unit: Option<String>,
46+
#[argp(switch, short = 'x')]
47+
/// Relax relocation diffs
48+
relax_reloc_diffs: bool,
4649
#[argp(positional)]
4750
/// Function symbol to diff
4851
symbol: String,
@@ -144,6 +147,7 @@ pub fn run(args: Args) -> Result<()> {
144147
.context("Failed to parse time format")?;
145148
let mut state = Box::new(FunctionDiffUi {
146149
redraw: true,
150+
relax_reloc_diffs: args.relax_reloc_diffs,
147151
click_xy: None,
148152
left_highlight: HighlightKind::None,
149153
right_highlight: HighlightKind::None,
@@ -216,6 +220,7 @@ fn find_function(obj: &ObjInfo, name: &str) -> Option<ObjSymbol> {
216220
#[allow(dead_code)]
217221
struct FunctionDiffUi {
218222
redraw: bool,
223+
relax_reloc_diffs: bool,
219224
click_xy: Option<(u16, u16)>,
220225
left_highlight: HighlightKind,
221226
right_highlight: HighlightKind,
@@ -472,6 +477,12 @@ impl FunctionDiffUi {
472477
self.scroll_x = self.scroll_x.saturating_sub(1);
473478
self.redraw = true;
474479
}
480+
// Toggle relax relocation diffs
481+
KeyCode::Char('x') => {
482+
self.relax_reloc_diffs = !self.relax_reloc_diffs;
483+
self.redraw = true;
484+
return FunctionDiffResult::Reload;
485+
}
475486
_ => {}
476487
}
477488
}
@@ -630,7 +641,7 @@ impl FunctionDiffUi {
630641
.as_deref()
631642
.map(|p| obj::elf::read(p).with_context(|| format!("Loading {}", p.display())))
632643
.transpose()?;
633-
let config = diff::DiffObjConfig::default();
644+
let config = diff::DiffObjConfig { relax_reloc_diffs: self.relax_reloc_diffs };
634645
diff::diff_objs(&config, target.as_mut(), base.as_mut())?;
635646

636647
let left_sym = target.as_ref().and_then(|o| find_function(o, &self.symbol_name));

0 commit comments

Comments
 (0)