2022-09-08 21:19:20 +00:00
# objdiff [![Build Status]][actions]
[Build Status]: https://github.com/encounter/objdiff/actions/workflows/build.yaml/badge.svg
[actions]: https://github.com/encounter/objdiff/actions
2023-11-25 04:17:35 +00:00
A local diffing tool for decompilation projects. Inspired by [decomp.me ](https://decomp.me ) and [asm-differ ](https://github.com/simonlindholm/asm-differ ).
Features:
2024-09-10 01:34:50 +00:00
2023-11-25 04:17:35 +00:00
- Compare entire object files: functions and data.
2024-03-23 05:06:41 +00:00
- Built-in symbol demangling for C++. (CodeWarrior, Itanium & MSVC)
2023-11-25 04:17:35 +00:00
- Automatic rebuild on source file changes.
- Project integration via [configuration file ](#configuration ).
- Search and filter all of a project's objects and quickly switch.
- Click to highlight all instances of values and registers.
2022-09-08 21:19:20 +00:00
2023-08-12 18:18:09 +00:00
Supports:
2024-09-10 01:34:50 +00:00
2024-05-22 00:12:58 +00:00
- PowerPC 750CL (GameCube, Wii)
- MIPS (N64, PS1, PS2, PSP)
2024-05-16 01:01:55 +00:00
- x86 (COFF only at the moment)
2024-06-21 00:36:25 +00:00
- ARM (GBA, DS, 3DS)
2024-10-31 06:37:01 +00:00
- ARM64 (Switch, experimental)
2022-09-08 21:19:20 +00:00
2023-08-12 18:18:09 +00:00
See [Usage ](#usage ) for more information.
2024-09-10 01:34:50 +00:00
## Downloads
To build from source, see [Building ](#building ).
### GUI
- [Windows (x86_64) ](https://github.com/encounter/objdiff/releases/latest/download/objdiff-windows-x86_64.exe )
- [Linux (x86_64) ](https://github.com/encounter/objdiff/releases/latest/download/objdiff-linux-x86_64 )
- [macOS (arm64) ](https://github.com/encounter/objdiff/releases/latest/download/objdiff-macos-arm64 )
- [macOS (x86_64) ](https://github.com/encounter/objdiff/releases/latest/download/objdiff-macos-x86_64 )
For Linux and macOS, run `chmod +x objdiff-*` to make the binary executable.
### CLI
CLI binaries can be found on the [releases page ](https://github.com/encounter/objdiff/releases ).
## Screenshots
2022-09-08 23:46:19 +00:00
![Symbol Screenshot ](assets/screen-symbols.png )
![Diff Screenshot ](assets/screen-diff.png )
2022-09-08 21:19:20 +00:00
2023-08-12 18:18:09 +00:00
## Usage
2023-08-12 18:41:19 +00:00
objdiff works by comparing two relocatable object files (`.o`). The objects are expected to have the same relative path
from the "target" and "base" directories.
2023-08-12 18:18:09 +00:00
2023-08-12 18:41:19 +00:00
For example, if the target ("expected") object is located at `build/asm/MetroTRK/mslsupp.o` and the base ("actual")
object is located at `build/src/MetroTRK/mslsupp.o` , the following configuration would be used:
2023-08-12 18:18:09 +00:00
- Target build directory: `build/asm`
- Base build directory: `build/src`
- Object: `MetroTRK/mslsupp.o`
objdiff will then execute the build system from the project directory to build both objects:
```sh
$ make build/asm/MetroTRK/mslsupp.o # Only if "Build target object" is enabled
$ make build/src/MetroTRK/mslsupp.o
```
The objects will then be compared and the results will be displayed in the UI.
See [Configuration ](#configuration ) for more information.
## Configuration
2024-09-04 02:48:45 +00:00
While **not required** (most settings can be specified in the UI), projects can add an `objdiff.json` file to configure the tool automatically. The configuration file must be located in
2023-08-12 18:41:19 +00:00
the root project directory.
If your project has a generator script (e.g. `configure.py` ), it's recommended to generate the objdiff configuration
file as well. You can then add `objdiff.json` to your `.gitignore` to prevent it from being committed.
2023-08-12 18:18:09 +00:00
2024-09-04 02:48:45 +00:00
```json
2023-08-12 18:18:09 +00:00
{
2024-09-04 02:48:45 +00:00
"$schema": "https://raw.githubusercontent.com/encounter/objdiff/main/config.schema.json",
2023-08-12 18:18:09 +00:00
"custom_make": "ninja",
2024-05-16 00:53:14 +00:00
"custom_args": [
2024-05-16 01:01:55 +00:00
"-d",
"keeprsp"
2024-05-16 00:53:14 +00:00
],
2024-09-04 02:48:45 +00:00
"build_target": false,
"build_base": true,
2023-08-12 18:18:09 +00:00
"watch_patterns": [
"*.c",
"*.cp",
"*.cpp",
2024-09-04 02:48:45 +00:00
"*.cxx",
2023-08-12 18:18:09 +00:00
"*.h",
2024-09-04 02:48:45 +00:00
"*.hp",
2023-08-12 18:18:09 +00:00
"*.hpp",
2024-09-04 02:48:45 +00:00
"*.hxx",
"*.s",
"*.S",
"*.asm",
"*.inc",
"*.py",
"*.yml",
"*.txt",
"*.json"
2023-08-12 18:18:09 +00:00
],
2024-09-04 02:48:45 +00:00
"units": [
2023-08-12 18:18:09 +00:00
{
2023-09-03 13:28:22 +00:00
"name": "main/MetroTRK/mslsupp",
"target_path": "build/asm/MetroTRK/mslsupp.o",
"base_path": "build/src/MetroTRK/mslsupp.o",
2024-09-04 02:48:45 +00:00
"metadata": {}
}
2023-08-12 18:18:09 +00:00
]
}
```
2024-09-04 02:48:45 +00:00
### Schema
View [config.schema.json ](config.schema.json ) for all available options. The below list is a summary of the most important options.
2023-09-03 13:28:22 +00:00
`custom_make` _(optional)_ : By default, objdiff will use `make` to build the project.
2024-05-16 01:01:55 +00:00
If the project uses a different build system (e.g. `ninja` ), specify it here.
The build command will be `[custom_make] [custom_args] path/to/object.o` .
`custom_args` _(optional)_ : Additional arguments to pass to the build command prior to the object path.
2023-09-03 13:28:22 +00:00
`build_target` : If true, objdiff will tell the build system to build the target objects before diffing (e.g.
2023-08-12 18:41:19 +00:00
`make path/to/target.o` ).
2023-09-03 13:28:22 +00:00
This is useful if the target objects are not built by default or can change based on project configuration or edits
to assembly files.
Requires the build system to be configured properly.
2024-09-04 02:48:45 +00:00
`build_base` : If true, objdiff will tell the build system to build the base objects before diffing (e.g. `make path/to/base.o` ).
It's unlikely you'll want to disable this, unless you're using an external tool to rebuild the base object on source file changes.
2023-09-03 13:28:22 +00:00
`watch_patterns` _(optional)_ : A list of glob patterns to watch for changes.
([Supported syntax](https://docs.rs/globset/latest/globset/#syntax))
If any of these files change, objdiff will automatically rebuild the objects and re-compare them.
If not specified, objdiff will use the default patterns listed above.
2024-09-04 02:48:45 +00:00
`units` _(optional)_ : If specified, objdiff will display a list of objects in the sidebar for easy navigation.
2023-09-03 13:28:22 +00:00
> `name` _(optional)_: The name of the object in the UI. If not specified, the object's `path` will be used.
>
2024-09-04 02:48:45 +00:00
> `target_path`: Path to the "target" or "expected" object from the project root.
> This object is the **intended result** of the match.
2023-09-03 13:28:22 +00:00
>
2024-09-04 02:48:45 +00:00
> `base_path`: Path to the "base" or "actual" object from the project root.
> This object is built from the **current source code**.
2023-09-03 13:28:22 +00:00
>
2024-09-04 02:48:45 +00:00
> `metadata.auto_generated` _(optional)_: Hides the object from the object list, but still includes it in reports.
2023-09-03 13:28:22 +00:00
>
2024-09-04 02:48:45 +00:00
> `metadata.complete` _(optional)_: Marks the object as "complete" (or "linked") in the object list.
> This is useful for marking objects that are fully decompiled. A value of `false` will mark the object as "incomplete".
2023-09-03 13:28:22 +00:00
2023-11-28 00:52:12 +00:00
## Building
2023-09-03 13:28:22 +00:00
2023-11-28 00:52:12 +00:00
Install Rust via [rustup ](https://rustup.rs ).
```shell
$ git clone https://github.com/encounter/objdiff.git
$ cd objdiff
$ cargo run --release
```
2023-08-12 18:18:09 +00:00
2024-09-10 01:38:06 +00:00
Or using `cargo install` .
```shell
2024-09-10 01:41:29 +00:00
$ cargo install --locked --git https://github.com/encounter/objdiff.git objdiff-gui objdiff-cli
2024-09-10 01:38:06 +00:00
```
2024-09-10 01:41:29 +00:00
The binaries will be installed to `~/.cargo/bin` as `objdiff` and `objdiff-cli` .
2023-08-12 18:18:09 +00:00
## License
2022-09-08 21:19:20 +00:00
Licensed under either of
2024-09-10 01:34:50 +00:00
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or < http: // www . apache . org / licenses / LICENSE-2 . 0 > )
- MIT license ([LICENSE-MIT](LICENSE-MIT) or < http: // opensource . org / licenses / MIT > )
2022-09-08 21:19:20 +00:00
at your option.
### Contribution
2023-08-12 18:41:19 +00:00
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as
defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.