Check relocation addends when diffing functions (#158)

* Check relocation addends when diffing functions

* Also highlight addend when reloc differs
This commit is contained in:
LagoLunatic
2025-02-10 00:26:49 -05:00
committed by GitHub
parent 674c942d7d
commit 3e6efb7736
5 changed files with 53 additions and 34 deletions

View File

@@ -1,3 +1,5 @@
use std::cmp::Ordering;
use anyhow::{bail, Result};
use crossterm::event::{Event, KeyCode, KeyEventKind, KeyModifiers, MouseButton, MouseEventKind};
use objdiff_core::{
@@ -563,6 +565,18 @@ impl FunctionDiffUi {
base_color = Color::White;
}
}
DiffText::Addend(addend, diff) => {
label_text = match addend.cmp(&0i64) {
Ordering::Greater => format!("+{:#x}", addend),
Ordering::Less => format!("-{:#x}", -addend),
_ => "".to_string(),
};
if let Some(diff) = diff {
base_color = COLOR_ROTATION[diff.idx % COLOR_ROTATION.len()]
} else {
base_color = Color::White;
}
}
DiffText::Spacing(n) => {
line.spans.push(Span::raw(" ".repeat(n)));
sx += n as u16;