Skip to content

Commit 22052ea

Browse files
authored
Data diff view: Show bytes with relocations as ?? instead of 00 (#204)
* Data diff view: Show bytes with relocations as `xx` * xx -> ??
1 parent f7c3501 commit 22052ea

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

objdiff-gui/src/views/data_diff.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,20 @@ pub(crate) fn data_row_ui(
147147
cur_addr += diff.len;
148148
} else {
149149
for byte in &diff.data {
150+
let mut byte_text = format!("{byte:02x} ");
150151
let mut byte_color = base_color;
151-
if let Some(reloc_diff) = reloc_diffs.iter().find(|reloc_diff| {
152-
reloc_diff.kind != DataDiffKind::None
153-
&& reloc_diff.range.contains(&cur_addr_actual)
154-
}) {
155-
byte_color = get_color_for_diff_kind(reloc_diff.kind, appearance);
152+
if let Some(reloc_diff) = reloc_diffs
153+
.iter()
154+
.find(|reloc_diff| reloc_diff.range.contains(&cur_addr_actual))
155+
{
156+
if *byte == 0 {
157+
// Display 00 data bytes with a relocation as ?? instead.
158+
byte_text = "?? ".to_string();
159+
}
160+
if reloc_diff.kind != DataDiffKind::None {
161+
byte_color = get_color_for_diff_kind(reloc_diff.kind, appearance);
162+
}
156163
}
157-
let byte_text = format!("{byte:02x} ");
158164
write_text(byte_text.as_str(), byte_color, &mut job, appearance.code_font.clone());
159165
cur_addr += 1;
160166
cur_addr_actual += 1;

0 commit comments

Comments
 (0)