From 22052ea10b47258402513e44951cccde4600f4c7 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Wed, 14 May 2025 23:12:59 -0400 Subject: [PATCH] Data diff view: Show bytes with relocations as `??` instead of `00` (#204) * Data diff view: Show bytes with relocations as `xx` * xx -> ?? --- objdiff-gui/src/views/data_diff.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/objdiff-gui/src/views/data_diff.rs b/objdiff-gui/src/views/data_diff.rs index 36b71c5..7954f3b 100644 --- a/objdiff-gui/src/views/data_diff.rs +++ b/objdiff-gui/src/views/data_diff.rs @@ -147,14 +147,20 @@ pub(crate) fn data_row_ui( cur_addr += diff.len; } else { for byte in &diff.data { + let mut byte_text = format!("{byte:02x} "); let mut byte_color = base_color; - if let Some(reloc_diff) = reloc_diffs.iter().find(|reloc_diff| { - reloc_diff.kind != DataDiffKind::None - && reloc_diff.range.contains(&cur_addr_actual) - }) { - byte_color = get_color_for_diff_kind(reloc_diff.kind, appearance); + if let Some(reloc_diff) = reloc_diffs + .iter() + .find(|reloc_diff| reloc_diff.range.contains(&cur_addr_actual)) + { + if *byte == 0 { + // Display 00 data bytes with a relocation as ?? instead. + byte_text = "?? ".to_string(); + } + if reloc_diff.kind != DataDiffKind::None { + byte_color = get_color_for_diff_kind(reloc_diff.kind, appearance); + } } - let byte_text = format!("{byte:02x} "); write_text(byte_text.as_str(), byte_color, &mut job, appearance.code_font.clone()); cur_addr += 1; cur_addr_actual += 1;