From 106652ae7da874e425635a165cbfc1478c024e25 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 22 Mar 2024 23:06:41 -0600 Subject: [PATCH] Fix PPC branch display; update README.md --- README.md | 5 +++-- objdiff-cli/src/cmd/diff.rs | 4 +--- objdiff-core/src/diff/display.rs | 6 +++++- objdiff-core/src/diff/mod.rs | 4 ++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9e79a3d..e00f6d0 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A local diffing tool for decompilation projects. Inspired by [decomp.me](https:/ Features: - Compare entire object files: functions and data. -- Built-in symbol demangling for C++. +- Built-in symbol demangling for C++. (CodeWarrior, Itanium & MSVC) - Automatic rebuild on source file changes. - Project integration via [configuration file](#configuration). - Search and filter all of a project's objects and quickly switch. @@ -15,7 +15,8 @@ Features: Supports: - PowerPC 750CL (GameCube & Wii) -- MIPS (Nintendo 64) +- MIPS (Nintendo 64 & PS2) +- x86 (PE only at the moment) See [Usage](#usage) for more information. diff --git a/objdiff-cli/src/cmd/diff.rs b/objdiff-cli/src/cmd/diff.rs index 2ff1af1..f0e0a3d 100644 --- a/objdiff-cli/src/cmd/diff.rs +++ b/objdiff-cli/src/cmd/diff.rs @@ -89,9 +89,7 @@ pub fn run(args: Args) -> Result<()> { return Some(obj); } - let Some(up) = unit_path.as_deref() else { - return None; - }; + let up = unit_path.as_deref()?; resolve_paths(obj); diff --git a/objdiff-core/src/diff/display.rs b/objdiff-core/src/diff/display.rs index f92dd2a..ee097e0 100644 --- a/objdiff-core/src/diff/display.rs +++ b/objdiff-core/src/diff/display.rs @@ -74,7 +74,11 @@ pub fn display_diff( display_reloc_name(ins.reloc.as_ref().unwrap(), &mut cb)?; } ObjInsArg::BranchDest(dest) => { - cb(DiffText::BranchDest(*dest))?; + if let Some(dest) = dest.checked_sub(base_addr) { + cb(DiffText::BranchDest(dest))?; + } else { + cb(DiffText::Basic(""))?; + } } } } diff --git a/objdiff-core/src/diff/mod.rs b/objdiff-core/src/diff/mod.rs index 20a9225..399a6d7 100644 --- a/objdiff-core/src/diff/mod.rs +++ b/objdiff-core/src/diff/mod.rs @@ -23,10 +23,14 @@ pub enum X86Formatter { Masm, } +#[inline] +const fn default_true() -> bool { true } + #[derive(Debug, Clone, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize)] #[serde(default)] pub struct DiffObjConfig { pub relax_reloc_diffs: bool, + #[serde(default = "default_true")] pub space_between_args: bool, pub x86_formatter: X86Formatter, }