mirror of
https://github.com/encounter/objdiff.git
synced 2025-12-15 16:16:15 +00:00
Compare commits
27 Commits
v3.0.0-bet
...
v3.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb1d434bbc | ||
|
|
23009bf9a3 | ||
|
|
6fb4bb8855 | ||
| a138dfa907 | |||
|
|
0b95613768 | ||
| 5d4b33a500 | |||
|
|
f2a591356e | ||
| 8d24ec6373 | |||
| 58430d947b | |||
| 1533125f9d | |||
| 5654060dc8 | |||
| 84079c3934 | |||
|
|
48804dc2e3 | ||
|
|
8cfa8b7dab | ||
|
|
93a4d7e55d | ||
|
|
7c424a7966 | ||
| 678210d58a | |||
| 4302821615 | |||
| c4b4244b59 | |||
| 52c138bf06 | |||
| 813c8aa539 | |||
| 0f0aaab795 | |||
| b21892be31 | |||
| 247d6da94b | |||
| bd95faa9c3 | |||
| 2c57e4960f | |||
| cff4be2979 |
24
.github/workflows/build.yaml
vendored
24
.github/workflows/build.yaml
vendored
@@ -36,9 +36,9 @@ jobs:
|
||||
- name: Cache Rust workspace
|
||||
uses: Swatinem/rust-cache@v2
|
||||
- name: Cargo check
|
||||
run: cargo check --all-targets --all-features
|
||||
run: cargo check --all-targets --all-features --workspace
|
||||
- name: Cargo clippy
|
||||
run: cargo clippy --all-targets --all-features
|
||||
run: cargo clippy --all-targets --all-features --workspace
|
||||
|
||||
fmt:
|
||||
name: Format
|
||||
@@ -92,7 +92,7 @@ jobs:
|
||||
- name: Cache Rust workspace
|
||||
uses: Swatinem/rust-cache@v2
|
||||
- name: Cargo test
|
||||
run: cargo test --release --features all
|
||||
run: cargo test --release --all-features --workspace
|
||||
|
||||
build-cli:
|
||||
name: Build objdiff-cli
|
||||
@@ -146,13 +146,14 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Install uv
|
||||
if: matrix.build == 'zigbuild'
|
||||
uses: astral-sh/setup-uv@v6
|
||||
- name: Install cargo-zigbuild
|
||||
if: matrix.build == 'zigbuild'
|
||||
run: |
|
||||
python3 -m venv .venv
|
||||
. .venv/bin/activate
|
||||
echo PATH=$PATH >> $GITHUB_ENV
|
||||
pip install ziglang==0.13.0.post1 cargo-zigbuild==0.19.8
|
||||
uv tool install cargo-zigbuild==0.20.1 --with-executables-from ziglang==0.15.1
|
||||
echo "CARGO_ZIGBUILD_ZIG_PATH=$(uv tool dir)/cargo-zigbuild/bin/python-zig" >> $GITHUB_ENV
|
||||
- name: Setup Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
@@ -213,13 +214,14 @@ jobs:
|
||||
sudo apt-get -y install ${{ matrix.packages }}
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Install uv
|
||||
if: matrix.build == 'zigbuild'
|
||||
uses: astral-sh/setup-uv@v6
|
||||
- name: Install cargo-zigbuild
|
||||
if: matrix.build == 'zigbuild'
|
||||
run: |
|
||||
python3 -m venv .venv
|
||||
. .venv/bin/activate
|
||||
echo PATH=$PATH >> $GITHUB_ENV
|
||||
pip install ziglang==0.13.0.post1 cargo-zigbuild==0.19.8
|
||||
uv tool install cargo-zigbuild==0.20.1 --with-executables-from ziglang==0.15.1
|
||||
echo "CARGO_ZIGBUILD_ZIG_PATH=$(uv tool dir)/cargo-zigbuild/bin/python-zig" >> $GITHUB_ENV
|
||||
- name: Setup Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
|
||||
@@ -24,7 +24,7 @@ repos:
|
||||
description: Run cargo clippy on all project files.
|
||||
language: system
|
||||
entry: cargo
|
||||
args: ["+nightly", "clippy", "--all-targets", "--all-features"]
|
||||
args: ["+nightly", "clippy", "--all-targets", "--all-features", "--workspace"]
|
||||
pass_filenames: false
|
||||
- id: cargo-deny
|
||||
name: cargo deny
|
||||
|
||||
189
Cargo.lock
generated
189
Cargo.lock
generated
@@ -123,7 +123,7 @@ dependencies = [
|
||||
"clipboard-win",
|
||||
"image",
|
||||
"log",
|
||||
"objc2 0.6.1",
|
||||
"objc2 0.6.2",
|
||||
"objc2-app-kit 0.3.1",
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-graphics",
|
||||
@@ -390,9 +390,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "async-std"
|
||||
version = "1.13.1"
|
||||
version = "1.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "730294c1c08c2e0f85759590518f6333f0d5a0a766a27d519c1b244c3dfd8a24"
|
||||
checksum = "2c8e079a4ab67ae52b7403632e4618815d6db36d2a010cfe41b02c1b1578f93b"
|
||||
dependencies = [
|
||||
"async-channel 1.9.0",
|
||||
"async-global-executor",
|
||||
@@ -436,9 +436,9 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de"
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.88"
|
||||
version = "0.1.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5"
|
||||
checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -556,7 +556,7 @@ version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "340d2f0bdb2a43c1d3cd40513185b2bd7def0aa1052f956455114bc98f82dcf2"
|
||||
dependencies = [
|
||||
"objc2 0.6.1",
|
||||
"objc2 0.6.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1126,7 +1126,7 @@ dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"block2 0.6.1",
|
||||
"libc",
|
||||
"objc2 0.6.1",
|
||||
"objc2 0.6.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1184,9 +1184,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ecolor"
|
||||
version = "0.32.0"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a631732d995184114016fab22fc7e3faf73d6841c2d7650395fe251fbcd9285"
|
||||
checksum = "b6a7fc3172c2ef56966b2ce4f84177e159804c40b9a84de8861558ce4a59f422"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"emath",
|
||||
@@ -1195,9 +1195,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "eframe"
|
||||
version = "0.32.0"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c790ccfbb3dd556588342463454b2b2b13909e5fdce5bc2a1432a8aa69c8b7a"
|
||||
checksum = "34037a80dc03a4147e1684bff4e4fdab2b1408d715d7b78470cd3179258964b9"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -1236,9 +1236,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "egui"
|
||||
version = "0.32.0"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8470210c95a42cc985d9ffebfd5067eea55bdb1c3f7611484907db9639675e28"
|
||||
checksum = "49e2be082f77715496b4a39fdc6f5dc7491fefe2833111781b8697ea6ee919a7"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"ahash",
|
||||
@@ -1256,9 +1256,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "egui-wgpu"
|
||||
version = "0.32.0"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14de9942d8b9e99e2d830403c208ab1a6e052e925a7456a4f6f66d567d90de1d"
|
||||
checksum = "64c7277a171ec1b711080ddb3b0bfa1b3aa9358834d5386d39e83fbc16d61212"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -1276,9 +1276,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "egui-winit"
|
||||
version = "0.32.0"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c490804a035cec9c826082894a3e1ecf4198accd3817deb10f7919108ebafab0"
|
||||
checksum = "fe6d8b0f8d6de4d43e794e343f03bacc3908aada931f0ed6fd7041871388a590"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"arboard",
|
||||
@@ -1296,9 +1296,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "egui_extras"
|
||||
version = "0.32.0"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f791a5937f518249016b276b3639ad2aa3824048b6f2161ec2b431ab325880a"
|
||||
checksum = "8ae8f23013328beb6be7ab29c75807142e8e1c7951643780a813e54cceaa9929"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"egui",
|
||||
@@ -1310,9 +1310,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "egui_glow"
|
||||
version = "0.32.0"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d44f3fd4fdc5f960c9e9ef7327c26647edc3141abf96102980647129d49358e6"
|
||||
checksum = "0ab645760288e42eab70283a5cccf44509a6f43b554351855d3c73594bfe3c23"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bytemuck",
|
||||
@@ -1334,9 +1334,9 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
||||
|
||||
[[package]]
|
||||
name = "emath"
|
||||
version = "0.32.0"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45f057b141e7e46340c321400be74b793543b1b213036f0f989c35d35957c32e"
|
||||
checksum = "935df67dc48fdeef132f2f7ada156ddc79e021344dd42c17f066b956bb88dde3"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"serde",
|
||||
@@ -1440,9 +1440,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "epaint"
|
||||
version = "0.32.0"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94cca02195f0552c17cabdc02f39aa9ab6fbd815dac60ab1cd3d5b0aa6f9551c"
|
||||
checksum = "b66fc0a5a9d322917de9bd3ac7d426ca8aa3127fbf1e76fae5b6b25e051e06a3"
|
||||
dependencies = [
|
||||
"ab_glyph",
|
||||
"ahash",
|
||||
@@ -1459,9 +1459,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "epaint_default_fonts"
|
||||
version = "0.32.0"
|
||||
version = "0.32.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8495e11ed527dff39663b8c36b6c2b2799d7e4287fb90556e455d72eca0b4d3"
|
||||
checksum = "4f6cf8ce0fb817000aa24f5e630bda904a353536bd430b83ebc1dceee95b4a3a"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
@@ -1876,8 +1876,7 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.32.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93563d740bc9ef04104f9ed6f86f1e3275c2cdafb95664e26584b9ca807a8ffe"
|
||||
source = "git+https://github.com/gimli-rs/gimli?rev=7335f00e7c39fd501511584fefb0ba974117c950#7335f00e7c39fd501511584fefb0ba974117c950"
|
||||
|
||||
[[package]]
|
||||
name = "gl_generator"
|
||||
@@ -1899,8 +1898,8 @@ dependencies = [
|
||||
"aho-corasick",
|
||||
"bstr",
|
||||
"log",
|
||||
"regex-automata 0.4.9",
|
||||
"regex-syntax 0.8.5",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
"serde",
|
||||
]
|
||||
|
||||
@@ -1942,7 +1941,7 @@ dependencies = [
|
||||
"glutin_glx_sys",
|
||||
"glutin_wgl_sys",
|
||||
"libloading",
|
||||
"objc2 0.6.1",
|
||||
"objc2 0.6.2",
|
||||
"objc2-app-kit 0.3.1",
|
||||
"objc2-core-foundation",
|
||||
"objc2-foundation 0.3.1",
|
||||
@@ -2833,11 +2832,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
||||
checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9"
|
||||
dependencies = [
|
||||
"regex-automata 0.1.10",
|
||||
"regex-automata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3093,12 +3092,11 @@ checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d"
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
version = "0.50.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
|
||||
checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399"
|
||||
dependencies = [
|
||||
"overload",
|
||||
"winapi",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3181,9 +3179,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "objc2"
|
||||
version = "0.6.1"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88c6597e14493ab2e44ce58f2fdecf095a51f12ca57bec060a11c57332520551"
|
||||
checksum = "561f357ba7f3a2a61563a186a163d0a3a5247e1089524a3981d49adb775078bc"
|
||||
dependencies = [
|
||||
"objc2-encode",
|
||||
]
|
||||
@@ -3212,7 +3210,7 @@ checksum = "e6f29f568bec459b0ddff777cec4fe3fd8666d82d5a40ebd0ff7e66134f89bcc"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"block2 0.6.1",
|
||||
"objc2 0.6.1",
|
||||
"objc2 0.6.2",
|
||||
"objc2-core-foundation",
|
||||
"objc2-core-graphics",
|
||||
"objc2-foundation 0.3.1",
|
||||
@@ -3262,7 +3260,7 @@ checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"dispatch2",
|
||||
"objc2 0.6.1",
|
||||
"objc2 0.6.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3273,7 +3271,7 @@ checksum = "989c6c68c13021b5c2d6b71456ebb0f9dc78d752e86a98da7c716f4f9470f5a4"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"dispatch2",
|
||||
"objc2 0.6.1",
|
||||
"objc2 0.6.2",
|
||||
"objc2-core-foundation",
|
||||
"objc2-io-surface",
|
||||
]
|
||||
@@ -3328,7 +3326,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "900831247d2fe1a09a683278e5384cfb8c80c79fe6b166f9d14bfdde0ea1b03c"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"objc2 0.6.1",
|
||||
"objc2 0.6.2",
|
||||
"objc2-core-foundation",
|
||||
]
|
||||
|
||||
@@ -3339,7 +3337,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7282e9ac92529fa3457ce90ebb15f4ecbc383e8338060960760fa2cf75420c3c"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"objc2 0.6.1",
|
||||
"objc2 0.6.2",
|
||||
"objc2-core-foundation",
|
||||
]
|
||||
|
||||
@@ -3437,7 +3435,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "objdiff-cli"
|
||||
version = "3.0.0-beta.14"
|
||||
version = "3.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"argp",
|
||||
@@ -3460,7 +3458,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "objdiff-core"
|
||||
version = "3.0.0-beta.14"
|
||||
version = "3.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arm-attr",
|
||||
@@ -3483,7 +3481,7 @@ dependencies = [
|
||||
"notify-debouncer-full",
|
||||
"num-traits",
|
||||
"objdiff-core",
|
||||
"object 0.37.1",
|
||||
"object 0.37.3",
|
||||
"pbjson",
|
||||
"pbjson-build",
|
||||
"powerpc",
|
||||
@@ -3515,9 +3513,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "objdiff-gui"
|
||||
version = "3.0.0-beta.14"
|
||||
version = "3.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"argp",
|
||||
"cfg-if",
|
||||
"const_format",
|
||||
"cwdemangle",
|
||||
@@ -3551,7 +3550,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "objdiff-wasm"
|
||||
version = "3.0.0-beta.14"
|
||||
version = "3.1.0"
|
||||
dependencies = [
|
||||
"log",
|
||||
"objdiff-core",
|
||||
@@ -3573,8 +3572,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.37.1"
|
||||
source = "git+https://github.com/gimli-rs/object?rev=16ff70aa6fbd97d6bb7b92375929f4d72414c32b#16ff70aa6fbd97d6bb7b92375929f4d72414c32b"
|
||||
version = "0.37.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
@@ -3683,12 +3683,6 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||
|
||||
[[package]]
|
||||
name = "owned_ttf_parser"
|
||||
version = "0.25.1"
|
||||
@@ -4311,17 +4305,8 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata 0.4.9",
|
||||
"regex-syntax 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||
dependencies = [
|
||||
"regex-syntax 0.6.29",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4332,15 +4317,9 @@ checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax 0.8.5",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.5"
|
||||
@@ -4452,7 +4431,7 @@ dependencies = [
|
||||
"dispatch2",
|
||||
"js-sys",
|
||||
"log",
|
||||
"objc2 0.6.1",
|
||||
"objc2 0.6.2",
|
||||
"objc2-app-kit 0.3.1",
|
||||
"objc2-core-foundation",
|
||||
"objc2-foundation 0.3.1",
|
||||
@@ -5069,9 +5048,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.104"
|
||||
version = "2.0.105"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
|
||||
checksum = "7bc3fcb250e53458e712715cf74285c1f889686520d79294a9ef3bd7aa1fc619"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -5562,14 +5541,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.3.19"
|
||||
version = "0.3.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
|
||||
checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5"
|
||||
dependencies = [
|
||||
"matchers",
|
||||
"nu-ansi-term",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"regex-automata",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
@@ -5862,9 +5841,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-encoder"
|
||||
version = "0.235.0"
|
||||
version = "0.236.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3bc393c395cb621367ff02d854179882b9a351b4e0c93d1397e6090b53a5c2a"
|
||||
checksum = "724fccfd4f3c24b7e589d333fc0429c68042897a7e8a5f8694f31792471841e7"
|
||||
dependencies = [
|
||||
"leb128fmt",
|
||||
"wasmparser",
|
||||
@@ -5872,9 +5851,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-metadata"
|
||||
version = "0.235.0"
|
||||
version = "0.236.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b055604ba04189d54b8c0ab2c2fc98848f208e103882d5c0b984f045d5ea4d20"
|
||||
checksum = "c909f94a49a8de3365f3c0344f064818f1e369ff1740c5b04f455f85d454768e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"indexmap",
|
||||
@@ -5897,9 +5876,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmparser"
|
||||
version = "0.235.0"
|
||||
version = "0.236.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "161296c618fa2d63f6ed5fffd1112937e803cb9ec71b32b01a76321555660917"
|
||||
checksum = "a9b1e81f3eb254cf7404a82cee6926a4a3ccc5aad80cc3d43608a070c67aa1d7"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"hashbrown",
|
||||
@@ -6046,7 +6025,7 @@ dependencies = [
|
||||
"jni",
|
||||
"log",
|
||||
"ndk-context",
|
||||
"objc2 0.6.1",
|
||||
"objc2 0.6.2",
|
||||
"objc2-foundation 0.3.1",
|
||||
"url",
|
||||
"web-sys",
|
||||
@@ -6725,19 +6704,19 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a18712ff1ec5bd09da500fe1e91dec11256b310da0ff33f8b4ec92b927cf0c6"
|
||||
checksum = "04bd9ed271234163b18c92783b0d406f08ca32c232e972f207a68c7b324c44bf"
|
||||
dependencies = [
|
||||
"wit-bindgen-rt 0.43.0",
|
||||
"wit-bindgen-rt 0.44.0",
|
||||
"wit-bindgen-rust-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-core"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c53468e077362201de11999c85c07c36e12048a990a3e0d69da2bd61da355d0"
|
||||
checksum = "b4103c7a3e178b75cd8b0b574fa199ed015e8399c9859b003865cc28834b474b"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
@@ -6755,18 +6734,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rt"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fd734226eac1fd7c450956964e3a9094c9cee65e9dafdf126feef8c0096db65"
|
||||
checksum = "653c85dd7aee6fe6f4bded0d242406deadae9819029ce6f7d258c920c384358a"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rust"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "531ebfcec48e56473805285febdb450e270fa75b2dacb92816861d0473b4c15f"
|
||||
checksum = "95d164b3b6fbd2b0dd8b639b1012110c0bc256519a0a6def410d4020fa8ae106"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
@@ -6780,9 +6759,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rust-macro"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7852bf8a9d1ea80884d26b864ddebd7b0c7636697c6ca10f4c6c93945e023966"
|
||||
checksum = "2c9100a5e1ac85e526dcd4ef49c3ff7689e026fa5e56e2a2047fd377fc682e02"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"prettyplease",
|
||||
@@ -6795,9 +6774,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wit-component"
|
||||
version = "0.235.0"
|
||||
version = "0.236.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64a57a11109cc553396f89f3a38a158a97d0b1adaec113bd73e0f64d30fb601f"
|
||||
checksum = "3622959ed7ed6341c38e5aa35af243632534b0a36226852faa802939ce11e00f"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags 2.9.1",
|
||||
@@ -6839,9 +6818,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wit-parser"
|
||||
version = "0.235.0"
|
||||
version = "0.236.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a1f95a87d03a33e259af286b857a95911eb46236a0f726cbaec1227b3dfc67a"
|
||||
checksum = "16e4833a20cd6e85d6abfea0e63a399472d6f88c6262957c17f546879a80ba15"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"id-arena",
|
||||
|
||||
24
Cargo.toml
24
Cargo.toml
@@ -5,18 +5,28 @@ members = [
|
||||
"objdiff-gui",
|
||||
"objdiff-wasm",
|
||||
]
|
||||
default-members = [
|
||||
"objdiff-cli",
|
||||
"objdiff-core",
|
||||
"objdiff-gui",
|
||||
# Exclude objdiff-wasm by default
|
||||
]
|
||||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "3.1.0"
|
||||
authors = ["Luke Street <luke@street.dev>"]
|
||||
edition = "2024"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/encounter/objdiff"
|
||||
rust-version = "1.88"
|
||||
|
||||
[profile.release-lto]
|
||||
inherits = "release"
|
||||
lto = "fat"
|
||||
strip = "debuginfo"
|
||||
codegen-units = 1
|
||||
|
||||
[workspace.package]
|
||||
version = "3.0.0-beta.14"
|
||||
authors = ["Luke Street <luke@street.dev>"]
|
||||
edition = "2024"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/encounter/objdiff"
|
||||
rust-version = "1.88"
|
||||
[profile.release-min]
|
||||
inherits = "release-lto"
|
||||
opt-level = "z"
|
||||
|
||||
141
README.md
141
README.md
@@ -7,12 +7,14 @@ 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++. (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.
|
||||
- Click to highlight all instances of values and registers.
|
||||
- Compare entire object files: functions and data
|
||||
- Built-in C++ symbol demangling (GCC, MSVC, CodeWarrior, Itanium)
|
||||
- Automatic rebuild on source file changes
|
||||
- Project integration via [configuration file](#configuration)
|
||||
- Search and filter objects with quick switching
|
||||
- Click-to-highlight values and registers
|
||||
- Detailed progress reporting (powers [decomp.dev](https://decomp.dev))
|
||||
- WebAssembly API, [web interface](https://github.com/encounter/objdiff-web) and [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=decomp-dev.objdiff) (WIP)
|
||||
|
||||
Supports:
|
||||
|
||||
@@ -40,7 +42,7 @@ 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).
|
||||
CLI binaries are available on the [releases page](https://github.com/encounter/objdiff/releases).
|
||||
|
||||
## Screenshots
|
||||
|
||||
@@ -49,33 +51,30 @@ CLI binaries can be found on the [releases page](https://github.com/encounter/ob
|
||||
|
||||
## Usage
|
||||
|
||||
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.
|
||||
objdiff compares two relocatable object files (`.o`). Here's how it works:
|
||||
|
||||
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:
|
||||
1. **Create an `objdiff.json` configuration file** in your project root (or generate it with your build script).
|
||||
This file lists **all objects in the project** with their target ("expected") and base ("current") paths.
|
||||
|
||||
- Target build directory: `build/asm`
|
||||
- Base build directory: `build/src`
|
||||
- Object: `MetroTRK/mslsupp.o`
|
||||
2. **Load the project** in objdiff.
|
||||
|
||||
objdiff will then execute the build system from the project directory to build both objects:
|
||||
3. **Select an object** from the sidebar to begin diffing.
|
||||
|
||||
```sh
|
||||
$ make build/asm/MetroTRK/mslsupp.o # Only if "Build target object" is enabled
|
||||
$ make build/src/MetroTRK/mslsupp.o
|
||||
```
|
||||
4. **objdiff automatically:**
|
||||
- Executes the build system to compile the base object (from current source code)
|
||||
- Compares the two objects and displays the differences
|
||||
- Watches for source file changes and rebuilds when detected
|
||||
|
||||
The objects will then be compared and the results will be displayed in the UI.
|
||||
The configuration file allows complete flexibility in project structure - your build directories can have any layout as long as the paths are specified correctly.
|
||||
|
||||
See [Configuration](#configuration) for more information.
|
||||
See [Configuration](#configuration) for setup details.
|
||||
|
||||
## Configuration
|
||||
|
||||
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
|
||||
Projects can add an `objdiff.json` file to configure the tool automatically. The configuration file must be located in
|
||||
the root project directory.
|
||||
|
||||
If your project has a generator script (e.g. `configure.py`), it's recommended to generate the objdiff configuration
|
||||
If your project has a generator script (e.g. `configure.py`), it's highly recommended to generate the objdiff configuration
|
||||
file as well. You can then add `objdiff.json` to your `.gitignore` to prevent it from being committed.
|
||||
|
||||
```json
|
||||
@@ -90,22 +89,31 @@ file as well. You can then add `objdiff.json` to your `.gitignore` to prevent it
|
||||
"build_base": true,
|
||||
"watch_patterns": [
|
||||
"*.c",
|
||||
"*.cc",
|
||||
"*.cp",
|
||||
"*.cpp",
|
||||
"*.cxx",
|
||||
"*.c++",
|
||||
"*.h",
|
||||
"*.hh",
|
||||
"*.hp",
|
||||
"*.hpp",
|
||||
"*.hxx",
|
||||
"*.h++",
|
||||
"*.pch",
|
||||
"*.pch++",
|
||||
"*.inc",
|
||||
"*.s",
|
||||
"*.S",
|
||||
"*.asm",
|
||||
"*.inc",
|
||||
"*.py",
|
||||
"*.yml",
|
||||
"*.txt",
|
||||
"*.json"
|
||||
],
|
||||
"ignore_patterns": [
|
||||
"build/**/*"
|
||||
],
|
||||
"units": [
|
||||
{
|
||||
"name": "main/MetroTRK/mslsupp",
|
||||
@@ -119,74 +127,69 @@ file as well. You can then add `objdiff.json` to your `.gitignore` to prevent it
|
||||
|
||||
### Schema
|
||||
|
||||
View [config.schema.json](config.schema.json) for all available options. The below list is a summary of the most important options.
|
||||
> [!NOTE]
|
||||
> View [config.schema.json](config.schema.json) for all available options. Below is a summary of the most important options.
|
||||
|
||||
`custom_make` _(optional)_: By default, objdiff will use `make` to build the project.
|
||||
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`.
|
||||
#### Build Configuration
|
||||
|
||||
`custom_args` _(optional)_: Additional arguments to pass to the build command prior to the object path.
|
||||
**`custom_make`** _(optional, default: `"make"`)_
|
||||
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`.
|
||||
|
||||
`build_target`: If true, objdiff will tell the build system to build the target objects before diffing (e.g.
|
||||
`make path/to/target.o`).
|
||||
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.
|
||||
**`custom_args`** _(optional)_
|
||||
Additional arguments to pass to the build command prior to the object path.
|
||||
|
||||
`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.
|
||||
**`build_target`** _(default: `false`)_
|
||||
If true, objdiff will build the target objects before diffing (e.g. `make path/to/target.o`). Useful if target objects are not built by default or can change based on project configuration. Requires proper build system configuration.
|
||||
|
||||
`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.
|
||||
**`build_base`** _(default: `true`)_
|
||||
If true, objdiff will build the base objects before diffing (e.g. `make path/to/base.o`). It's unlikely you'll want to disable this unless using an external tool to rebuild the base object.
|
||||
|
||||
`units` _(optional)_: If specified, objdiff will display a list of objects in the sidebar for easy navigation.
|
||||
#### File Watching
|
||||
|
||||
> `name` _(optional)_: The name of the object in the UI. If not specified, the object's `path` will be used.
|
||||
>
|
||||
> `target_path`: Path to the "target" or "expected" object from the project root.
|
||||
> This object is the **intended result** of the match.
|
||||
>
|
||||
> `base_path`: Path to the "base" or "actual" object from the project root.
|
||||
> This object is built from the **current source code**.
|
||||
>
|
||||
> `metadata.auto_generated` _(optional)_: Hides the object from the object list, but still includes it in reports.
|
||||
>
|
||||
> `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".
|
||||
**`watch_patterns`** _(optional, default: listed above)_
|
||||
A list of glob patterns to watch for changes ([supported syntax](https://docs.rs/globset/latest/globset/#syntax)). When these files change, objdiff automatically rebuilds and re-compares objects.
|
||||
|
||||
**`ignore_patterns`** _(optional, default: listed above)_
|
||||
A list of glob patterns to explicitly ignore when watching for changes ([supported syntax](https://docs.rs/globset/latest/globset/#syntax)).
|
||||
|
||||
#### Units (Objects)
|
||||
|
||||
**`units`** _(optional)_
|
||||
If specified, objdiff displays a list of objects in the sidebar for easy navigation. Each unit contains:
|
||||
|
||||
- **`name`** _(optional)_ - The display name in the UI. Defaults to the object's `path`.
|
||||
- **`target_path`** _(optional)_ - Path to the "target" or "expected" object (the **intended result**).
|
||||
- **`base_path`** _(optional)_ - Path to the "base" or "current" object (built from **current source code**). Omit if there is no source object yet.
|
||||
- **`metadata.auto_generated`** _(optional)_ - Hides the object from the sidebar but includes it in progress reports.
|
||||
- **`metadata.complete`** _(optional)_ - Marks the object as "complete" (linked) when `true` or "incomplete" when `false`.
|
||||
|
||||
## Building
|
||||
|
||||
Install Rust via [rustup](https://rustup.rs).
|
||||
|
||||
```shell
|
||||
$ git clone https://github.com/encounter/objdiff.git
|
||||
$ cd objdiff
|
||||
$ cargo run --release
|
||||
git clone https://github.com/encounter/objdiff.git
|
||||
cd objdiff
|
||||
cargo run --release
|
||||
```
|
||||
|
||||
Or using `cargo install`.
|
||||
Or install directly with cargo:
|
||||
|
||||
```shell
|
||||
$ cargo install --locked --git https://github.com/encounter/objdiff.git objdiff-gui objdiff-cli
|
||||
cargo install --locked --git https://github.com/encounter/objdiff.git objdiff-gui objdiff-cli
|
||||
```
|
||||
|
||||
The binaries will be installed to `~/.cargo/bin` as `objdiff` and `objdiff-cli`.
|
||||
Binaries will be installed to `~/.cargo/bin` as `objdiff` and `objdiff-cli`.
|
||||
|
||||
## Installing `pre-commit`
|
||||
## Contributing
|
||||
|
||||
When contributing, it's recommended to install `pre-commit` to automatically run the linter and formatter before a commit.
|
||||
|
||||
[`uv`](https://github.com/astral-sh/uv#installation) is recommended to manage Python version and tools.
|
||||
|
||||
Rust nightly is required for `cargo +nightly fmt` and `cargo +nightly clippy`.
|
||||
Install `pre-commit` to run linting and formatting automatically:
|
||||
|
||||
```shell
|
||||
$ cargo install --locked cargo-deny
|
||||
$ rustup toolchain install nightly
|
||||
$ uv tool install pre-commit
|
||||
$ pre-commit install
|
||||
rustup toolchain install nightly # Required for cargo fmt/clippy
|
||||
cargo install --locked cargo-deny # https://github.com/EmbarkStudios/cargo-deny
|
||||
uv tool install pre-commit # https://docs.astral.sh/uv, or use pipx or pip
|
||||
pre-commit install
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
},
|
||||
"custom_make": {
|
||||
"type": "string",
|
||||
"description": "By default, objdiff will use make to build the project.\nIf the project uses a different build system (e.g. ninja), specify it here.\nThe build command will be `[custom_make] [custom_args] path/to/object.o`.",
|
||||
"description": "If the project uses a different build system (e.g. ninja), specify it here.\nThe build command will be `[custom_make] [custom_args] path/to/object.o`.",
|
||||
"examples": [
|
||||
"make",
|
||||
"ninja"
|
||||
@@ -41,39 +41,55 @@
|
||||
},
|
||||
"build_target": {
|
||||
"type": "boolean",
|
||||
"description": "If true, objdiff will tell the build system to build the target objects before diffing (e.g. `make path/to/target.o`).\nThis is useful if the target objects are not built by default or can change based on project configuration or edits to assembly files.\nRequires the build system to be configured properly.",
|
||||
"description": "If true, objdiff will build the target objects before diffing (e.g. `make path/to/target.o`).\nUseful if target objects are not built by default or can change based on project configuration.\nRequires proper build system configuration.",
|
||||
"default": false
|
||||
},
|
||||
"build_base": {
|
||||
"type": "boolean",
|
||||
"description": "If true, objdiff will tell the build system to build the base objects before diffing (e.g. `make path/to/base.o`).\nIt's unlikely you'll want to disable this, unless you're using an external tool to rebuild the base object on source file changes.",
|
||||
"description": "If true, objdiff will build the base objects before diffing (e.g. `make path/to/base.o`).\nIt's unlikely you'll want to disable this unless using an external tool to rebuild the base object.",
|
||||
"default": true
|
||||
},
|
||||
"watch_patterns": {
|
||||
"type": "array",
|
||||
"description": "List of glob patterns to watch for changes in the project.\nIf any of these files change, objdiff will automatically rebuild the objects and re-compare them.\nSupported syntax: https://docs.rs/globset/latest/globset/#syntax",
|
||||
"description": "A list of glob patterns to watch for changes.\nWhen these files change, objdiff automatically rebuilds and re-compares objects.\nSupported syntax: https://docs.rs/globset/latest/globset/#syntax",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": [
|
||||
"*.c",
|
||||
"*.cc",
|
||||
"*.cp",
|
||||
"*.cpp",
|
||||
"*.cxx",
|
||||
"*.c++",
|
||||
"*.h",
|
||||
"*.hh",
|
||||
"*.hp",
|
||||
"*.hpp",
|
||||
"*.hxx",
|
||||
"*.h++",
|
||||
"*.pch",
|
||||
"*.pch++",
|
||||
"*.inc",
|
||||
"*.s",
|
||||
"*.S",
|
||||
"*.asm",
|
||||
"*.inc",
|
||||
"*.py",
|
||||
"*.yml",
|
||||
"*.txt",
|
||||
"*.json"
|
||||
]
|
||||
},
|
||||
"ignore_patterns": {
|
||||
"type": "array",
|
||||
"description": "A list of glob patterns to explicitly ignore when watching for changes.\nSupported syntax: https://docs.rs/globset/latest/globset/#syntax",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": [
|
||||
"build/**/*"
|
||||
]
|
||||
},
|
||||
"objects": {
|
||||
"type": "array",
|
||||
"description": "Use units instead.",
|
||||
@@ -103,7 +119,7 @@
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "The name of the object in the UI. If not specified, the object's path will be used."
|
||||
"description": "The display name in the UI. Defaults to the object's path."
|
||||
},
|
||||
"path": {
|
||||
"type": "string",
|
||||
@@ -112,11 +128,11 @@
|
||||
},
|
||||
"target_path": {
|
||||
"type": "string",
|
||||
"description": "Path to the target object from the project root.\nRequired if path is not specified."
|
||||
"description": "Path to the \"target\" or \"expected\" object (the intended result)."
|
||||
},
|
||||
"base_path": {
|
||||
"type": "string",
|
||||
"description": "Path to the base object from the project root.\nRequired if path is not specified."
|
||||
"description": "Path to the \"base\" or \"current\" object (built from current source code).\nOmit if there is no source object yet."
|
||||
},
|
||||
"reverse_fn_order": {
|
||||
"type": "boolean",
|
||||
@@ -191,7 +207,7 @@
|
||||
"properties": {
|
||||
"complete": {
|
||||
"type": "boolean",
|
||||
"description": "Marks the object as \"complete\" (or \"linked\") in the object list.\nThis is useful for marking objects that are fully decompiled. A value of `false` will mark the object as \"incomplete\"."
|
||||
"description": "Marks the object as \"complete\" (linked) when `true` or \"incomplete\" when `false`."
|
||||
},
|
||||
"reverse_fn_order": {
|
||||
"type": "boolean",
|
||||
@@ -211,7 +227,7 @@
|
||||
},
|
||||
"auto_generated": {
|
||||
"type": "boolean",
|
||||
"description": "Hides the object from the object list by default, but still includes it in reports."
|
||||
"description": "Hides the object from the sidebar but includes it in progress reports."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -74,6 +74,7 @@ ignore = [
|
||||
#"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish
|
||||
#{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" },
|
||||
{ id = "RUSTSEC-2024-0436", reason = "Unmaintained paste crate is an indirect dependency" },
|
||||
{ id = "RUSTSEC-2025-0052", reason = "Unmaintained async-std crate is an indirect dependency" },
|
||||
]
|
||||
# If this is true, then cargo deny will use the git executable to fetch advisory database.
|
||||
# If this is false, then it uses a built-in git library.
|
||||
@@ -241,8 +242,8 @@ allow-git = []
|
||||
[sources.allow-org]
|
||||
# github.com organizations to allow git sources for
|
||||
github = [
|
||||
"enarx", # flagset
|
||||
"encounter",
|
||||
"gimli-rs", # gimli
|
||||
]
|
||||
# gitlab.com organizations to allow git sources for
|
||||
gitlab = []
|
||||
|
||||
@@ -19,7 +19,6 @@ use crossterm::{
|
||||
},
|
||||
};
|
||||
use objdiff_core::{
|
||||
bindings::diff::DiffResult,
|
||||
build::{
|
||||
BuildConfig, BuildStatus,
|
||||
watcher::{Watcher, create_watcher},
|
||||
@@ -28,7 +27,7 @@ use objdiff_core::{
|
||||
ProjectConfig, ProjectObject, ProjectObjectMetadata, build_globset,
|
||||
path::{check_path_buf, platform_path, platform_path_serde_option},
|
||||
},
|
||||
diff::{self, DiffObjConfig, MappingConfig, ObjectDiff},
|
||||
diff::{DiffObjConfig, MappingConfig, ObjectDiff},
|
||||
jobs::{
|
||||
Job, JobQueue, JobResult,
|
||||
objdiff::{ObjDiffConfig, start_build},
|
||||
@@ -40,10 +39,7 @@ use typed_path::{Utf8PlatformPath, Utf8PlatformPathBuf};
|
||||
|
||||
use crate::{
|
||||
cmd::apply_config_args,
|
||||
util::{
|
||||
output::{OutputFormat, write_output},
|
||||
term::crossterm_panic_handler,
|
||||
},
|
||||
util::term::crossterm_panic_handler,
|
||||
views::{EventControlFlow, EventResult, UiView, function_diff::FunctionDiffUi},
|
||||
};
|
||||
|
||||
@@ -63,12 +59,6 @@ pub struct Args {
|
||||
#[argp(option, short = 'u')]
|
||||
/// Unit name within project
|
||||
unit: Option<String>,
|
||||
#[argp(option, short = 'o', from_str_fn(platform_path))]
|
||||
/// Output file (one-shot mode) ("-" for stdout)
|
||||
output: Option<Utf8PlatformPathBuf>,
|
||||
#[argp(option)]
|
||||
/// Output format (json, json-pretty, proto) (default: json)
|
||||
format: Option<String>,
|
||||
#[argp(positional)]
|
||||
/// Function symbol to diff
|
||||
symbol: Option<String>,
|
||||
@@ -171,11 +161,7 @@ pub fn run(args: Args) -> Result<()> {
|
||||
_ => bail!("Either target and base or project and unit must be specified"),
|
||||
};
|
||||
|
||||
if let Some(output) = &args.output {
|
||||
run_oneshot(&args, output, target_path.as_deref(), base_path.as_deref())
|
||||
} else {
|
||||
run_interactive(args, target_path, base_path, project_config)
|
||||
}
|
||||
run_interactive(args, target_path, base_path, project_config)
|
||||
}
|
||||
|
||||
fn build_config_from_args(args: &Args) -> Result<(DiffObjConfig, MappingConfig)> {
|
||||
@@ -194,28 +180,6 @@ fn build_config_from_args(args: &Args) -> Result<(DiffObjConfig, MappingConfig)>
|
||||
Ok((diff_config, mapping_config))
|
||||
}
|
||||
|
||||
fn run_oneshot(
|
||||
args: &Args,
|
||||
output: &Utf8PlatformPath,
|
||||
target_path: Option<&Utf8PlatformPath>,
|
||||
base_path: Option<&Utf8PlatformPath>,
|
||||
) -> Result<()> {
|
||||
let output_format = OutputFormat::from_option(args.format.as_deref())?;
|
||||
let (diff_config, mapping_config) = build_config_from_args(args)?;
|
||||
let target = target_path
|
||||
.map(|p| obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {p}")))
|
||||
.transpose()?;
|
||||
let base = base_path
|
||||
.map(|p| obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {p}")))
|
||||
.transpose()?;
|
||||
let result =
|
||||
diff::diff_objs(target.as_ref(), base.as_ref(), None, &diff_config, &mapping_config)?;
|
||||
let left = target.as_ref().and_then(|o| result.left.as_ref().map(|d| (o, d)));
|
||||
let right = base.as_ref().and_then(|o| result.right.as_ref().map(|d| (o, d)));
|
||||
write_output(&DiffResult::new(left, right), Some(output), output_format)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub struct AppState {
|
||||
pub jobs: JobQueue,
|
||||
pub waker: Arc<TermWaker>,
|
||||
@@ -378,10 +342,12 @@ fn run_interactive(
|
||||
};
|
||||
if let (Some(project_dir), Some(project_config)) = (&state.project_dir, &state.project_config) {
|
||||
let watch_patterns = project_config.build_watch_patterns()?;
|
||||
let ignore_patterns = project_config.build_ignore_patterns()?;
|
||||
state.watcher = Some(create_watcher(
|
||||
state.modified.clone(),
|
||||
project_dir.as_ref(),
|
||||
build_globset(&watch_patterns)?,
|
||||
build_globset(&ignore_patterns)?,
|
||||
Waker::from(state.waker.clone()),
|
||||
)?);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ use objdiff_core::{
|
||||
Report, ReportCategory, ReportItem, ReportItemMetadata, ReportUnit, ReportUnitMetadata,
|
||||
},
|
||||
config::path::platform_path,
|
||||
diff, obj,
|
||||
obj::{SectionKind, SymbolFlag},
|
||||
diff,
|
||||
obj::{self, SectionKind, SymbolFlag, SymbolKind},
|
||||
};
|
||||
use prost::Message;
|
||||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||
@@ -177,14 +177,16 @@ fn report_object(
|
||||
.target_path
|
||||
.as_ref()
|
||||
.map(|p| {
|
||||
obj::read::read(p.as_ref(), diff_config).with_context(|| format!("Failed to open {p}"))
|
||||
obj::read::read(p.as_ref(), diff_config, diff::DiffSide::Target)
|
||||
.with_context(|| format!("Failed to open {p}"))
|
||||
})
|
||||
.transpose()?;
|
||||
let base = object
|
||||
.base_path
|
||||
.as_ref()
|
||||
.map(|p| {
|
||||
obj::read::read(p.as_ref(), diff_config).with_context(|| format!("Failed to open {p}"))
|
||||
obj::read::read(p.as_ref(), diff_config, diff::DiffSide::Base)
|
||||
.with_context(|| format!("Failed to open {p}"))
|
||||
})
|
||||
.transpose()?;
|
||||
let result =
|
||||
@@ -245,6 +247,7 @@ fn report_object(
|
||||
|| symbol.size == 0
|
||||
|| symbol.flags.contains(SymbolFlag::Hidden)
|
||||
|| symbol.flags.contains(SymbolFlag::Ignored)
|
||||
|| symbol.kind == SymbolKind::Section
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -132,12 +132,12 @@ itertools = { version = "0.14", default-features = false, features = ["use_alloc
|
||||
log = { version = "0.4", default-features = false, optional = true }
|
||||
memmap2 = { version = "0.9", optional = true }
|
||||
num-traits = { version = "0.2", default-features = false, optional = true }
|
||||
object = { git = "https://github.com/gimli-rs/object", rev = "16ff70aa6fbd97d6bb7b92375929f4d72414c32b", default-features = false, features = ["read_core", "elf", "coff"] }
|
||||
object = { version = "0.37", default-features = false, features = ["read_core", "elf", "coff"] }
|
||||
pbjson = { version = "0.8", default-features = false, optional = true }
|
||||
prost = { version = "0.14", default-features = false, features = ["derive"], optional = true }
|
||||
regex = { version = "1.11", default-features = false, features = [], optional = true }
|
||||
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
|
||||
similar = { version = "2.7", default-features = false, features = ["hashbrown"], optional = true, git = "https://github.com/encounter/similar.git", branch = "no_std" }
|
||||
similar = { git = "https://github.com/encounter/similar.git", branch = "no_std", default-features = false, features = ["hashbrown"], optional = true }
|
||||
typed-path = { version = "0.11", default-features = false, optional = true }
|
||||
|
||||
# config
|
||||
@@ -146,7 +146,7 @@ semver = { version = "1.0", default-features = false, optional = true }
|
||||
serde_json = { version = "1.0", default-features = false, features = ["alloc"], optional = true }
|
||||
|
||||
# dwarf
|
||||
gimli = { version = "0.32", default-features = false, features = ["read"], optional = true }
|
||||
gimli = { git = "https://github.com/gimli-rs/gimli", rev = "7335f00e7c39fd501511584fefb0ba974117c950", default-features = false, features = ["read"], optional = true }
|
||||
typed-arena = { version = "2.0", default-features = false, optional = true }
|
||||
|
||||
# ppc
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package objdiff.diff;
|
||||
|
||||
// A symbol
|
||||
message Symbol {
|
||||
// Name of the symbol
|
||||
string name = 1;
|
||||
// Demangled name of the symbol
|
||||
optional string demangled_name = 2;
|
||||
// Symbol address
|
||||
uint64 address = 3;
|
||||
// Symbol size
|
||||
uint64 size = 4;
|
||||
// Bitmask of SymbolFlag
|
||||
uint32 flags = 5;
|
||||
}
|
||||
|
||||
// Symbol visibility flags
|
||||
enum SymbolFlag {
|
||||
SYMBOL_NONE = 0;
|
||||
SYMBOL_GLOBAL = 1;
|
||||
SYMBOL_LOCAL = 2;
|
||||
SYMBOL_WEAK = 4;
|
||||
SYMBOL_COMMON = 8;
|
||||
SYMBOL_HIDDEN = 16;
|
||||
}
|
||||
|
||||
// A single parsed instruction
|
||||
message Instruction {
|
||||
// Instruction address
|
||||
uint64 address = 1;
|
||||
// Instruction size
|
||||
uint32 size = 2;
|
||||
// Instruction opcode
|
||||
uint32 opcode = 3;
|
||||
// Instruction mnemonic
|
||||
string mnemonic = 4;
|
||||
// Instruction formatted string
|
||||
string formatted = 5;
|
||||
// Original (unsimplified) instruction string
|
||||
optional string original = 6;
|
||||
// Instruction arguments
|
||||
repeated Argument arguments = 7;
|
||||
// Instruction relocation
|
||||
optional Relocation relocation = 8;
|
||||
// Instruction branch destination
|
||||
optional uint64 branch_dest = 9;
|
||||
// Instruction line number
|
||||
optional uint32 line_number = 10;
|
||||
}
|
||||
|
||||
// An instruction argument
|
||||
message Argument {
|
||||
oneof value {
|
||||
// Plain text
|
||||
string plain_text = 1;
|
||||
// Value
|
||||
ArgumentValue argument = 2;
|
||||
// Relocation
|
||||
ArgumentRelocation relocation = 3;
|
||||
// Branch destination
|
||||
uint64 branch_dest = 4;
|
||||
}
|
||||
}
|
||||
|
||||
// An instruction argument value
|
||||
message ArgumentValue {
|
||||
oneof value {
|
||||
// Signed integer
|
||||
int64 signed = 1;
|
||||
// Unsigned integer
|
||||
uint64 unsigned = 2;
|
||||
// Opaque value
|
||||
string opaque = 3;
|
||||
}
|
||||
}
|
||||
|
||||
// Marker type for relocation arguments
|
||||
message ArgumentRelocation {
|
||||
}
|
||||
|
||||
message Relocation {
|
||||
uint32 type = 1;
|
||||
string type_name = 2;
|
||||
RelocationTarget target = 3;
|
||||
}
|
||||
|
||||
message RelocationTarget {
|
||||
uint32 symbol_index = 1;
|
||||
int64 addend = 2;
|
||||
}
|
||||
|
||||
message InstructionDiffRow {
|
||||
DiffKind diff_kind = 1;
|
||||
optional Instruction instruction = 2;
|
||||
optional InstructionBranchFrom branch_from = 3;
|
||||
optional InstructionBranchTo branch_to = 4;
|
||||
repeated ArgumentDiff arg_diff = 5;
|
||||
}
|
||||
|
||||
message ArgumentDiff {
|
||||
optional uint32 diff_index = 1;
|
||||
}
|
||||
|
||||
enum DiffKind {
|
||||
DIFF_NONE = 0;
|
||||
DIFF_REPLACE = 1;
|
||||
DIFF_DELETE = 2;
|
||||
DIFF_INSERT = 3;
|
||||
DIFF_OP_MISMATCH = 4;
|
||||
DIFF_ARG_MISMATCH = 5;
|
||||
}
|
||||
|
||||
message InstructionBranchFrom {
|
||||
repeated uint32 instruction_index = 1;
|
||||
uint32 branch_index = 2;
|
||||
}
|
||||
|
||||
message InstructionBranchTo {
|
||||
uint32 instruction_index = 1;
|
||||
uint32 branch_index = 2;
|
||||
}
|
||||
|
||||
message SymbolDiff {
|
||||
Symbol symbol = 1;
|
||||
repeated InstructionDiffRow instruction_rows = 2;
|
||||
optional float match_percent = 3;
|
||||
// The symbol index in the _other_ object that this symbol was diffed against
|
||||
optional uint32 target_symbol = 5;
|
||||
}
|
||||
|
||||
message DataDiff {
|
||||
DiffKind kind = 1;
|
||||
bytes data = 2;
|
||||
// May be larger than data
|
||||
uint64 size = 3;
|
||||
}
|
||||
|
||||
message SectionDiff {
|
||||
string name = 1;
|
||||
SectionKind kind = 2;
|
||||
uint64 size = 3;
|
||||
uint64 address = 4;
|
||||
reserved 5;
|
||||
repeated DataDiff data = 6;
|
||||
optional float match_percent = 7;
|
||||
}
|
||||
|
||||
enum SectionKind {
|
||||
SECTION_UNKNOWN = 0;
|
||||
SECTION_TEXT = 1;
|
||||
SECTION_DATA = 2;
|
||||
SECTION_BSS = 3;
|
||||
}
|
||||
|
||||
message ObjectDiff {
|
||||
repeated SectionDiff sections = 1;
|
||||
repeated SymbolDiff symbols = 2;
|
||||
}
|
||||
|
||||
message DiffResult {
|
||||
optional ObjectDiff left = 1;
|
||||
optional ObjectDiff right = 2;
|
||||
}
|
||||
Binary file not shown.
@@ -464,6 +464,22 @@ impl Arch for ArchArm {
|
||||
}
|
||||
flags
|
||||
}
|
||||
|
||||
fn infer_function_size(
|
||||
&self,
|
||||
symbol: &Symbol,
|
||||
section: &Section,
|
||||
mut next_address: u64,
|
||||
) -> Result<u64> {
|
||||
// Trim any trailing 4-byte zeroes from the end (padding)
|
||||
while next_address >= symbol.address + 4
|
||||
&& let Some(data) = section.data_range(next_address - 4, 4)
|
||||
&& data == [0u8; 4]
|
||||
{
|
||||
next_address -= 4;
|
||||
}
|
||||
Ok(next_address.saturating_sub(symbol.address))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
||||
@@ -12,7 +12,7 @@ use rabbitizer::{
|
||||
|
||||
use crate::{
|
||||
arch::{Arch, RelocationOverride, RelocationOverrideTarget},
|
||||
diff::{DiffObjConfig, MipsAbi, MipsInstrCategory, display::InstructionPart},
|
||||
diff::{DiffObjConfig, DiffSide, MipsAbi, MipsInstrCategory, display::InstructionPart},
|
||||
obj::{
|
||||
InstructionArg, InstructionArgValue, InstructionRef, Relocation, RelocationFlags,
|
||||
ResolvedInstructionRef, ResolvedRelocation, Section, Symbol, SymbolFlag, SymbolFlagSet,
|
||||
@@ -27,6 +27,7 @@ pub struct ArchMips {
|
||||
pub ri_gp_value: i32,
|
||||
pub paired_relocations: Vec<BTreeMap<u64, i64>>,
|
||||
pub ignored_symbols: BTreeSet<usize>,
|
||||
pub diff_side: DiffSide,
|
||||
}
|
||||
|
||||
const EF_MIPS_ABI: u32 = 0x0000F000;
|
||||
@@ -38,7 +39,7 @@ const EF_MIPS_MACH_5900: u32 = 0x00920000;
|
||||
const R_MIPS15_S3: u32 = 119;
|
||||
|
||||
impl ArchMips {
|
||||
pub fn new(object: &object::File) -> Result<Self> {
|
||||
pub fn new(object: &object::File, diff_side: DiffSide) -> Result<Self> {
|
||||
let mut abi = Abi::O32;
|
||||
let mut isa_extension = None;
|
||||
match object.flags() {
|
||||
@@ -124,7 +125,11 @@ impl ArchMips {
|
||||
let Ok(name) = obj_symbol.name() else { continue };
|
||||
if let Some(prefix) = name.strip_suffix(".NON_MATCHING") {
|
||||
ignored_symbols.insert(obj_symbol.index().0);
|
||||
if let Some(target_symbol) = object.symbol_by_name(prefix) {
|
||||
// Only remove the prefixless symbols if we are on the Base side of the diff,
|
||||
// to allow diffing against target objects that contain `.NON_MATCHING` markers.
|
||||
if diff_side == DiffSide::Base
|
||||
&& let Some(target_symbol) = object.symbol_by_name(prefix)
|
||||
{
|
||||
ignored_symbols.insert(target_symbol.index().0);
|
||||
}
|
||||
}
|
||||
@@ -137,6 +142,7 @@ impl ArchMips {
|
||||
ri_gp_value,
|
||||
paired_relocations,
|
||||
ignored_symbols,
|
||||
diff_side,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use alloc::{
|
||||
vec::Vec,
|
||||
};
|
||||
use core::{
|
||||
any::Any,
|
||||
ffi::CStr,
|
||||
fmt::{self, Debug},
|
||||
};
|
||||
@@ -16,7 +17,7 @@ use object::Endian as _;
|
||||
|
||||
use crate::{
|
||||
diff::{
|
||||
DiffObjConfig,
|
||||
DiffObjConfig, DiffSide,
|
||||
display::{ContextItem, HoverItem, InstructionPart},
|
||||
},
|
||||
obj::{
|
||||
@@ -305,7 +306,7 @@ impl dyn Arch {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Arch: Send + Sync + Debug {
|
||||
pub trait Arch: Any + Debug + Send + Sync {
|
||||
/// Finishes arch-specific initialization that must be done after sections have been combined.
|
||||
fn post_init(&mut self, _sections: &[Section], _symbols: &[Symbol]) {}
|
||||
|
||||
@@ -417,15 +418,18 @@ pub trait Arch: Send + Sync + Debug {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_arch(object: &object::File) -> Result<Box<dyn Arch>> {
|
||||
pub fn new_arch(object: &object::File, diff_side: DiffSide) -> Result<Box<dyn Arch>> {
|
||||
use object::Object as _;
|
||||
// Avoid unused warnings on non-mips builds
|
||||
let _ = diff_side;
|
||||
|
||||
Ok(match object.architecture() {
|
||||
#[cfg(feature = "ppc")]
|
||||
object::Architecture::PowerPc | object::Architecture::PowerPc64 => {
|
||||
Box::new(ppc::ArchPpc::new(object)?)
|
||||
}
|
||||
#[cfg(feature = "mips")]
|
||||
object::Architecture::Mips => Box::new(mips::ArchMips::new(object)?),
|
||||
object::Architecture::Mips => Box::new(mips::ArchMips::new(object, diff_side)?),
|
||||
#[cfg(feature = "x86")]
|
||||
object::Architecture::I386 | object::Architecture::X86_64 => {
|
||||
Box::new(x86::ArchX86::new(object)?)
|
||||
|
||||
@@ -21,6 +21,7 @@ use crate::{
|
||||
obj::{
|
||||
FlowAnalysisResult, InstructionRef, Object, Relocation, RelocationFlags,
|
||||
ResolvedInstructionRef, ResolvedRelocation, Section, Symbol, SymbolFlag, SymbolFlagSet,
|
||||
SymbolKind,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -675,7 +676,7 @@ fn make_symbol_ref(symbol: &object::Symbol) -> Result<ExtabSymbolRef> {
|
||||
#[derive(Debug)]
|
||||
struct PoolReference {
|
||||
addr_src_gpr: powerpc::GPR,
|
||||
addr_offset: i16,
|
||||
addr_offset: i64,
|
||||
addr_dst_gpr: Option<powerpc::GPR>,
|
||||
}
|
||||
|
||||
@@ -683,16 +684,20 @@ struct PoolReference {
|
||||
// If so, return information pertaining to where the instruction is getting that address from and
|
||||
// what it's doing with the address (e.g. copying it into another register, adding an offset, etc).
|
||||
fn get_pool_reference_for_inst(
|
||||
opcode: powerpc::Opcode,
|
||||
ins: powerpc::Ins,
|
||||
simplified: &powerpc::ParsedIns,
|
||||
) -> Option<PoolReference> {
|
||||
use powerpc::{Argument, Opcode};
|
||||
let args = &simplified.args;
|
||||
if flow_analysis::guess_data_type_from_load_store_inst_op(opcode).is_some() {
|
||||
if flow_analysis::guess_data_type_from_load_store_inst_op(ins.op).is_some() {
|
||||
match (args[1], args[2]) {
|
||||
(Argument::Offset(offset), Argument::GPR(addr_src_gpr)) => {
|
||||
// e.g. lwz. Immediate offset.
|
||||
Some(PoolReference { addr_src_gpr, addr_offset: offset.0, addr_dst_gpr: None })
|
||||
Some(PoolReference {
|
||||
addr_src_gpr,
|
||||
addr_offset: offset.0 as i64,
|
||||
addr_dst_gpr: None,
|
||||
})
|
||||
}
|
||||
(Argument::GPR(addr_src_gpr), Argument::GPR(_offset_gpr)) => {
|
||||
// e.g. lwzx. The offset is in a register and was likely calculated from an index.
|
||||
@@ -712,17 +717,51 @@ fn get_pool_reference_for_inst(
|
||||
// If either of these match, we also want to return the destination register that the
|
||||
// address is being copied into so that we can detect any future references to that new
|
||||
// register as well.
|
||||
match (opcode, args[0], args[1], args[2]) {
|
||||
match (ins.op, args[0], args[1], args[2]) {
|
||||
(
|
||||
// `addi` or `subi`
|
||||
Opcode::Addi,
|
||||
Argument::GPR(addr_dst_gpr),
|
||||
Argument::GPR(addr_src_gpr),
|
||||
Argument::Simm(simm),
|
||||
) => Some(PoolReference {
|
||||
addr_src_gpr,
|
||||
addr_offset: simm.0,
|
||||
addr_dst_gpr: Some(addr_dst_gpr),
|
||||
}),
|
||||
) => {
|
||||
let offset = if simplified.mnemonic == "addi" { simm.0 } else { -simm.0 };
|
||||
Some(PoolReference {
|
||||
addr_src_gpr,
|
||||
addr_offset: offset as i64,
|
||||
addr_dst_gpr: Some(addr_dst_gpr),
|
||||
})
|
||||
}
|
||||
(
|
||||
// `addis`
|
||||
Opcode::Addis,
|
||||
Argument::GPR(addr_dst_gpr),
|
||||
Argument::GPR(addr_src_gpr),
|
||||
Argument::Uimm(uimm), // Note: `addis` uses UIMM, unlike `addi`, `subi`, and `subis`
|
||||
) => {
|
||||
assert_eq!(simplified.mnemonic, "addis");
|
||||
let offset = (uimm.0 as i64) << 16;
|
||||
Some(PoolReference {
|
||||
addr_src_gpr,
|
||||
addr_offset: offset,
|
||||
addr_dst_gpr: Some(addr_dst_gpr),
|
||||
})
|
||||
}
|
||||
(
|
||||
// `subis`
|
||||
Opcode::Addis,
|
||||
Argument::GPR(addr_dst_gpr),
|
||||
Argument::GPR(addr_src_gpr),
|
||||
Argument::Simm(simm),
|
||||
) => {
|
||||
assert_eq!(simplified.mnemonic, "subis");
|
||||
let offset = (simm.0 as i64) << 16;
|
||||
Some(PoolReference {
|
||||
addr_src_gpr,
|
||||
addr_offset: offset,
|
||||
addr_dst_gpr: Some(addr_dst_gpr),
|
||||
})
|
||||
}
|
||||
(
|
||||
// `mr` or `mr.`
|
||||
Opcode::Or,
|
||||
@@ -777,13 +816,13 @@ fn clear_overwritten_gprs(ins: powerpc::Ins, gpr_pool_relocs: &mut BTreeMap<u8,
|
||||
// Also, if this instruction is accessing the middle of a symbol instead of the start, we add an
|
||||
// addend to indicate that.
|
||||
fn make_fake_pool_reloc(
|
||||
offset: i16,
|
||||
offset: i64,
|
||||
cur_addr: u32,
|
||||
pool_reloc: &Relocation,
|
||||
symbols: &[Symbol],
|
||||
) -> Option<Relocation> {
|
||||
let pool_reloc = resolve_relocation(symbols, pool_reloc);
|
||||
let offset_from_pool = pool_reloc.relocation.addend + offset as i64;
|
||||
let offset_from_pool = pool_reloc.relocation.addend + offset;
|
||||
let target_address = pool_reloc.symbol.address.checked_add_signed(offset_from_pool)?;
|
||||
let target_symbol;
|
||||
let addend;
|
||||
@@ -794,6 +833,7 @@ fn make_fake_pool_reloc(
|
||||
&& s.size > 0
|
||||
&& !s.flags.contains(SymbolFlag::Hidden)
|
||||
&& !s.flags.contains(SymbolFlag::Ignored)
|
||||
&& s.kind != SymbolKind::Section
|
||||
&& (s.address..s.address + s.size).contains(&target_address)
|
||||
})?;
|
||||
addend = target_address.checked_sub(symbols[target_symbol].address)? as i64;
|
||||
@@ -946,7 +986,7 @@ fn generate_fake_pool_relocations_for_function(
|
||||
clear_overwritten_gprs(ins, &mut gpr_pool_relocs);
|
||||
}
|
||||
}
|
||||
} else if let Some(pool_ref) = get_pool_reference_for_inst(ins.op, &simplified) {
|
||||
} else if let Some(pool_ref) = get_pool_reference_for_inst(ins, &simplified) {
|
||||
// This instruction doesn't have a real relocation, so it may be a reference to one of
|
||||
// the already-loaded pools.
|
||||
if let Some(pool_reloc) = gpr_pool_relocs.get(&pool_ref.addr_src_gpr.0) {
|
||||
@@ -965,7 +1005,7 @@ fn generate_fake_pool_relocations_for_function(
|
||||
// with the offset within the .data section of an array variable into r21.
|
||||
// Then the body of the loop will `lwzx` one of the array elements from r21.
|
||||
let mut new_reloc = pool_reloc.clone();
|
||||
new_reloc.addend += pool_ref.addr_offset as i64;
|
||||
new_reloc.addend += pool_ref.addr_offset;
|
||||
gpr_pool_relocs.insert(addr_dst_gpr.0, new_reloc);
|
||||
} else {
|
||||
clear_overwritten_gprs(ins, &mut gpr_pool_relocs);
|
||||
|
||||
@@ -1,242 +0,0 @@
|
||||
#![allow(clippy::needless_lifetimes)] // Generated serde code
|
||||
|
||||
use crate::{diff, obj};
|
||||
|
||||
// Protobuf diff types
|
||||
include!(concat!(env!("OUT_DIR"), "/objdiff.diff.rs"));
|
||||
#[cfg(feature = "serde")]
|
||||
include!(concat!(env!("OUT_DIR"), "/objdiff.diff.serde.rs"));
|
||||
|
||||
impl DiffResult {
|
||||
pub fn new(
|
||||
_left: Option<(&obj::Object, &diff::ObjectDiff)>,
|
||||
_right: Option<(&obj::Object, &diff::ObjectDiff)>,
|
||||
) -> Self {
|
||||
Self {
|
||||
// TODO
|
||||
// left: left.map(|(obj, diff)| ObjectDiff::new(obj, diff)),
|
||||
// right: right.map(|(obj, diff)| ObjectDiff::new(obj, diff)),
|
||||
left: None,
|
||||
right: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// impl ObjectDiff {
|
||||
// pub fn new(obj: &obj::Object, diff: &diff::ObjectDiff) -> Self {
|
||||
// Self {
|
||||
// sections: diff
|
||||
// .sections
|
||||
// .iter()
|
||||
// .enumerate()
|
||||
// .map(|(i, d)| SectionDiff::new(obj, i, d))
|
||||
// .collect(),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl SectionDiff {
|
||||
// pub fn new(obj: &obj::Object, section_index: usize, section_diff: &diff::SectionDiff) -> Self {
|
||||
// let section = &obj.sections[section_index];
|
||||
// let symbols = section_diff.symbols.iter().map(|d| SymbolDiff::new(obj, d)).collect();
|
||||
// let data = section_diff.data_diff.iter().map(|d| DataDiff::new(obj, d)).collect();
|
||||
// // TODO: section_diff.reloc_diff
|
||||
// Self {
|
||||
// name: section.name.to_string(),
|
||||
// kind: SectionKind::from(section.kind) as i32,
|
||||
// size: section.size,
|
||||
// address: section.address,
|
||||
// symbols,
|
||||
// data,
|
||||
// match_percent: section_diff.match_percent,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl From<obj::SectionKind> for SectionKind {
|
||||
// fn from(value: obj::SectionKind) -> Self {
|
||||
// match value {
|
||||
// obj::SectionKind::Code => SectionKind::SectionText,
|
||||
// obj::SectionKind::Data => SectionKind::SectionData,
|
||||
// obj::SectionKind::Bss => SectionKind::SectionBss,
|
||||
// // TODO common
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl SymbolDiff {
|
||||
// pub fn new(object: &obj::Object, symbol_diff: &diff::SymbolDiff) -> Self {
|
||||
// let symbol = object.symbols[symbol_diff.symbol_index];
|
||||
// let instructions = symbol_diff
|
||||
// .instruction_rows
|
||||
// .iter()
|
||||
// .map(|ins_diff| InstructionDiff::new(object, ins_diff))
|
||||
// .collect();
|
||||
// Self {
|
||||
// symbol: Some(Symbol::new(symbol)),
|
||||
// instructions,
|
||||
// match_percent: symbol_diff.match_percent,
|
||||
// target: symbol_diff.target_symbol.map(SymbolRef::from),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl DataDiff {
|
||||
// pub fn new(_object: &obj::Object, data_diff: &diff::DataDiff) -> Self {
|
||||
// Self {
|
||||
// kind: DiffKind::from(data_diff.kind) as i32,
|
||||
// data: data_diff.data.clone(),
|
||||
// size: data_diff.len as u64,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl Symbol {
|
||||
// pub fn new(value: &ObjSymbol) -> Self {
|
||||
// Self {
|
||||
// name: value.name.to_string(),
|
||||
// demangled_name: value.demangled_name.clone(),
|
||||
// address: value.address,
|
||||
// size: value.size,
|
||||
// flags: symbol_flags(value.flags),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// fn symbol_flags(value: ObjSymbolFlagSet) -> u32 {
|
||||
// let mut flags = 0u32;
|
||||
// if value.0.contains(ObjSymbolFlags::Global) {
|
||||
// flags |= SymbolFlag::SymbolGlobal as u32;
|
||||
// }
|
||||
// if value.0.contains(ObjSymbolFlags::Local) {
|
||||
// flags |= SymbolFlag::SymbolLocal as u32;
|
||||
// }
|
||||
// if value.0.contains(ObjSymbolFlags::Weak) {
|
||||
// flags |= SymbolFlag::SymbolWeak as u32;
|
||||
// }
|
||||
// if value.0.contains(ObjSymbolFlags::Common) {
|
||||
// flags |= SymbolFlag::SymbolCommon as u32;
|
||||
// }
|
||||
// if value.0.contains(ObjSymbolFlags::Hidden) {
|
||||
// flags |= SymbolFlag::SymbolHidden as u32;
|
||||
// }
|
||||
// flags
|
||||
// }
|
||||
//
|
||||
// impl Instruction {
|
||||
// pub fn new(object: &obj::Object, instruction: &ObjIns) -> Self {
|
||||
// Self {
|
||||
// address: instruction.address,
|
||||
// size: instruction.size as u32,
|
||||
// opcode: instruction.op as u32,
|
||||
// mnemonic: instruction.mnemonic.to_string(),
|
||||
// formatted: instruction.formatted.clone(),
|
||||
// arguments: instruction.args.iter().map(Argument::new).collect(),
|
||||
// relocation: instruction.reloc.as_ref().map(|reloc| Relocation::new(object, reloc)),
|
||||
// branch_dest: instruction.branch_dest,
|
||||
// line_number: instruction.line,
|
||||
// original: instruction.orig.clone(),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl Argument {
|
||||
// pub fn new(value: &ObjInsArg) -> Self {
|
||||
// Self {
|
||||
// value: Some(match value {
|
||||
// ObjInsArg::PlainText(s) => argument::Value::PlainText(s.to_string()),
|
||||
// ObjInsArg::Arg(v) => argument::Value::Argument(ArgumentValue::new(v)),
|
||||
// ObjInsArg::Reloc => argument::Value::Relocation(ArgumentRelocation {}),
|
||||
// ObjInsArg::BranchDest(dest) => argument::Value::BranchDest(*dest),
|
||||
// }),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl ArgumentValue {
|
||||
// pub fn new(value: &ObjInsArgValue) -> Self {
|
||||
// Self {
|
||||
// value: Some(match value {
|
||||
// ObjInsArgValue::Signed(v) => argument_value::Value::Signed(*v),
|
||||
// ObjInsArgValue::Unsigned(v) => argument_value::Value::Unsigned(*v),
|
||||
// ObjInsArgValue::Opaque(v) => argument_value::Value::Opaque(v.to_string()),
|
||||
// }),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl Relocation {
|
||||
// pub fn new(object: &obj::Object, reloc: &ObjReloc) -> Self {
|
||||
// Self {
|
||||
// r#type: match reloc.flags {
|
||||
// object::RelocationFlags::Elf { r_type } => r_type,
|
||||
// object::RelocationFlags::MachO { r_type, .. } => r_type as u32,
|
||||
// object::RelocationFlags::Coff { typ } => typ as u32,
|
||||
// object::RelocationFlags::Xcoff { r_rtype, .. } => r_rtype as u32,
|
||||
// _ => unreachable!(),
|
||||
// },
|
||||
// type_name: object.arch.display_reloc(reloc.flags).into_owned(),
|
||||
// target: Some(RelocationTarget {
|
||||
// symbol: Some(Symbol::new(&reloc.target)),
|
||||
// addend: reloc.addend,
|
||||
// }),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl InstructionDiff {
|
||||
// pub fn new(object: &obj::Object, instruction_diff: &ObjInsDiff) -> Self {
|
||||
// Self {
|
||||
// instruction: instruction_diff.ins.as_ref().map(|ins| Instruction::new(object, ins)),
|
||||
// diff_kind: DiffKind::from(instruction_diff.kind) as i32,
|
||||
// branch_from: instruction_diff.branch_from.as_ref().map(InstructionBranchFrom::new),
|
||||
// branch_to: instruction_diff.branch_to.as_ref().map(InstructionBranchTo::new),
|
||||
// arg_diff: instruction_diff.arg_diff.iter().map(ArgumentDiff::new).collect(),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl ArgumentDiff {
|
||||
// pub fn new(value: &Option<ObjInsArgDiff>) -> Self {
|
||||
// Self { diff_index: value.as_ref().map(|v| v.idx as u32) }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl From<ObjInsDiffKind> for DiffKind {
|
||||
// fn from(value: ObjInsDiffKind) -> Self {
|
||||
// match value {
|
||||
// ObjInsDiffKind::None => DiffKind::DiffNone,
|
||||
// ObjInsDiffKind::OpMismatch => DiffKind::DiffOpMismatch,
|
||||
// ObjInsDiffKind::ArgMismatch => DiffKind::DiffArgMismatch,
|
||||
// ObjInsDiffKind::Replace => DiffKind::DiffReplace,
|
||||
// ObjInsDiffKind::Delete => DiffKind::DiffDelete,
|
||||
// ObjInsDiffKind::Insert => DiffKind::DiffInsert,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl From<ObjDataDiffKind> for DiffKind {
|
||||
// fn from(value: ObjDataDiffKind) -> Self {
|
||||
// match value {
|
||||
// ObjDataDiffKind::None => DiffKind::DiffNone,
|
||||
// ObjDataDiffKind::Replace => DiffKind::DiffReplace,
|
||||
// ObjDataDiffKind::Delete => DiffKind::DiffDelete,
|
||||
// ObjDataDiffKind::Insert => DiffKind::DiffInsert,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl InstructionBranchFrom {
|
||||
// pub fn new(value: &ObjInsBranchFrom) -> Self {
|
||||
// Self {
|
||||
// instruction_index: value.ins_idx.iter().map(|&x| x as u32).collect(),
|
||||
// branch_index: value.branch_idx as u32,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl InstructionBranchTo {
|
||||
// pub fn new(value: &ObjInsBranchTo) -> Self {
|
||||
// Self { instruction_index: value.ins_idx as u32, branch_index: value.branch_idx as u32 }
|
||||
// }
|
||||
// }
|
||||
@@ -1,3 +1 @@
|
||||
#[cfg(feature = "any-arch")]
|
||||
pub mod diff;
|
||||
pub mod report;
|
||||
|
||||
@@ -49,6 +49,7 @@ pub fn run_make(config: &BuildConfig, arg: &Utf8UnixPath) -> BuildStatus {
|
||||
};
|
||||
#[cfg(windows)]
|
||||
let mut command = {
|
||||
use alloc::borrow::Cow;
|
||||
use std::os::windows::process::CommandExt;
|
||||
|
||||
let mut command = if config.selected_wsl_distro.is_some() {
|
||||
@@ -60,13 +61,17 @@ pub fn run_make(config: &BuildConfig, arg: &Utf8UnixPath) -> BuildStatus {
|
||||
// Strip distro root prefix \\wsl.localhost\{distro}
|
||||
let wsl_path_prefix = format!("\\\\wsl.localhost\\{}", distro);
|
||||
let cwd = match cwd.strip_prefix(wsl_path_prefix) {
|
||||
Ok(new_cwd) => Utf8UnixPath::new("/").join(new_cwd.with_unix_encoding()),
|
||||
Err(_) => cwd.with_unix_encoding(),
|
||||
// Convert to absolute Unix path
|
||||
Ok(new_cwd) => Cow::Owned(
|
||||
Utf8UnixPath::new("/").join(new_cwd.with_unix_encoding()).into_string(),
|
||||
),
|
||||
// Otherwise, use the Windows path as is
|
||||
Err(_) => Cow::Borrowed(cwd.as_str()),
|
||||
};
|
||||
|
||||
command
|
||||
.arg("--cd")
|
||||
.arg(cwd.as_str())
|
||||
.arg::<&str>(cwd.as_ref())
|
||||
.arg("-d")
|
||||
.arg(distro)
|
||||
.arg("--")
|
||||
|
||||
@@ -29,6 +29,7 @@ pub fn create_watcher(
|
||||
modified: Arc<AtomicBool>,
|
||||
project_dir: &Path,
|
||||
patterns: GlobSet,
|
||||
ignore_patterns: GlobSet,
|
||||
waker: Waker,
|
||||
) -> notify::Result<Watcher> {
|
||||
let base_dir = fs::canonicalize(project_dir)?;
|
||||
@@ -54,8 +55,8 @@ pub fn create_watcher(
|
||||
let Ok(path) = path.strip_prefix(&base_dir_clone) else {
|
||||
continue;
|
||||
};
|
||||
if patterns.is_match(path) {
|
||||
// log::info!("File modified: {}", path.display());
|
||||
if patterns.is_match(path) && !ignore_patterns.is_match(path) {
|
||||
log::debug!("File modified: {}", path.display());
|
||||
any_match = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ pub struct ProjectConfig {
|
||||
pub build_target: Option<bool>,
|
||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
||||
pub watch_patterns: Option<Vec<String>>,
|
||||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
|
||||
pub ignore_patterns: Option<Vec<String>>,
|
||||
#[cfg_attr(
|
||||
feature = "serde",
|
||||
serde(alias = "objects", skip_serializing_if = "Option::is_none")
|
||||
@@ -66,7 +68,18 @@ impl ProjectConfig {
|
||||
.map(|s| Glob::new(s))
|
||||
.collect::<Result<Vec<Glob>, globset::Error>>()?
|
||||
} else {
|
||||
DEFAULT_WATCH_PATTERNS.iter().map(|s| Glob::new(s).unwrap()).collect()
|
||||
default_watch_patterns()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn build_ignore_patterns(&self) -> Result<Vec<Glob>, globset::Error> {
|
||||
Ok(if let Some(ignore_patterns) = &self.ignore_patterns {
|
||||
ignore_patterns
|
||||
.iter()
|
||||
.map(|s| Glob::new(s))
|
||||
.collect::<Result<Vec<Glob>, globset::Error>>()?
|
||||
} else {
|
||||
default_ignore_patterns()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -191,14 +204,21 @@ pub struct ScratchConfig {
|
||||
pub const CONFIG_FILENAMES: [&str; 3] = ["objdiff.json", "objdiff.yml", "objdiff.yaml"];
|
||||
|
||||
pub const DEFAULT_WATCH_PATTERNS: &[&str] = &[
|
||||
"*.c", "*.cp", "*.cpp", "*.cxx", "*.h", "*.hp", "*.hpp", "*.hxx", "*.s", "*.S", "*.asm",
|
||||
"*.inc", "*.py", "*.yml", "*.txt", "*.json",
|
||||
"*.c", "*.cc", "*.cp", "*.cpp", "*.cxx", "*.c++", "*.h", "*.hh", "*.hp", "*.hpp", "*.hxx",
|
||||
"*.h++", "*.pch", "*.pch++", "*.inc", "*.s", "*.S", "*.asm", "*.py", "*.yml", "*.txt",
|
||||
"*.json",
|
||||
];
|
||||
|
||||
pub const DEFAULT_IGNORE_PATTERNS: &[&str] = &["build/**/*"];
|
||||
|
||||
pub fn default_watch_patterns() -> Vec<Glob> {
|
||||
DEFAULT_WATCH_PATTERNS.iter().map(|s| Glob::new(s).unwrap()).collect()
|
||||
}
|
||||
|
||||
pub fn default_ignore_patterns() -> Vec<Glob> {
|
||||
DEFAULT_IGNORE_PATTERNS.iter().map(|s| Glob::new(s).unwrap()).collect()
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
pub struct ProjectConfigInfo {
|
||||
|
||||
@@ -41,7 +41,13 @@ pub fn no_diff_code(
|
||||
instruction_rows.push(InstructionDiffRow { ins_ref: Some(*i), ..Default::default() });
|
||||
}
|
||||
resolve_branches(&ops, &mut instruction_rows);
|
||||
Ok(SymbolDiff { target_symbol: None, match_percent: None, diff_score: None, instruction_rows })
|
||||
Ok(SymbolDiff {
|
||||
target_symbol: None,
|
||||
match_percent: None,
|
||||
diff_score: None,
|
||||
instruction_rows,
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
|
||||
const PENALTY_IMM_DIFF: u64 = 1;
|
||||
@@ -147,12 +153,14 @@ pub fn diff_code(
|
||||
match_percent: Some(match_percent),
|
||||
diff_score: Some((diff_score, max_score)),
|
||||
instruction_rows: left_rows,
|
||||
..Default::default()
|
||||
},
|
||||
SymbolDiff {
|
||||
target_symbol: Some(left_symbol_idx),
|
||||
match_percent: Some(match_percent),
|
||||
diff_score: Some((diff_score, max_score)),
|
||||
instruction_rows: right_rows,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
}
|
||||
@@ -496,6 +504,14 @@ fn diff_instruction(
|
||||
result.right_args_diff.push(InstructionArgDiffIndex::new(b_diff));
|
||||
}
|
||||
}
|
||||
if result.kind == InstructionDiffKind::None
|
||||
&& left_resolved.code.len() != right_resolved.code.len()
|
||||
{
|
||||
// If everything else matches but the raw code length differs (e.g. x86 instructions
|
||||
// with same disassembly but different encoding), mark as op mismatch
|
||||
result.kind = InstructionDiffKind::OpMismatch;
|
||||
state.diff_score += PENALTY_REG_DIFF;
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,17 +24,31 @@ pub fn diff_bss_symbol(
|
||||
target_symbol: Some(right_symbol_ref),
|
||||
match_percent: Some(percent),
|
||||
diff_score: None,
|
||||
instruction_rows: vec![],
|
||||
..Default::default()
|
||||
},
|
||||
SymbolDiff {
|
||||
target_symbol: Some(left_symbol_ref),
|
||||
match_percent: Some(percent),
|
||||
diff_score: None,
|
||||
instruction_rows: vec![],
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
pub fn symbol_name_matches(left_name: &str, right_name: &str) -> bool {
|
||||
// Match Metrowerks symbol$1234 against symbol$2345
|
||||
if let Some((prefix, suffix)) = left_name.split_once('$') {
|
||||
if !suffix.chars().all(char::is_numeric) {
|
||||
return false;
|
||||
}
|
||||
right_name
|
||||
.split_once('$')
|
||||
.is_some_and(|(p, s)| p == prefix && s.chars().all(char::is_numeric))
|
||||
} else {
|
||||
left_name == right_name
|
||||
}
|
||||
}
|
||||
|
||||
fn reloc_eq(
|
||||
left_obj: &Object,
|
||||
right_obj: &Object,
|
||||
@@ -45,8 +59,8 @@ fn reloc_eq(
|
||||
return false;
|
||||
}
|
||||
|
||||
let symbol_name_addend_matches =
|
||||
left.symbol.name == right.symbol.name && left.relocation.addend == right.relocation.addend;
|
||||
let symbol_name_addend_matches = symbol_name_matches(&left.symbol.name, &right.symbol.name)
|
||||
&& left.relocation.addend == right.relocation.addend;
|
||||
match (left.symbol.section, right.symbol.section) {
|
||||
(Some(sl), Some(sr)) => {
|
||||
// Match if section and name+addend or address match
|
||||
@@ -70,7 +84,83 @@ pub fn resolve_relocation<'obj>(
|
||||
ResolvedRelocation { relocation: reloc, symbol }
|
||||
}
|
||||
|
||||
/// Compares relocations contained with a certain data range.
|
||||
/// Compares the bytes within a certain data range.
|
||||
fn diff_data_range(left_data: &[u8], right_data: &[u8]) -> (f32, Vec<DataDiff>, Vec<DataDiff>) {
|
||||
let ops = capture_diff_slices(Algorithm::Patience, left_data, right_data);
|
||||
let bytes_match_ratio = get_diff_ratio(&ops, left_data.len(), right_data.len());
|
||||
|
||||
let mut left_data_diff = Vec::<DataDiff>::new();
|
||||
let mut right_data_diff = Vec::<DataDiff>::new();
|
||||
for op in ops {
|
||||
let (tag, left_range, right_range) = op.as_tag_tuple();
|
||||
let left_len = left_range.len();
|
||||
let right_len = right_range.len();
|
||||
let mut len = left_len.max(right_len);
|
||||
let kind = match tag {
|
||||
similar::DiffTag::Equal => DataDiffKind::None,
|
||||
similar::DiffTag::Delete => DataDiffKind::Delete,
|
||||
similar::DiffTag::Insert => DataDiffKind::Insert,
|
||||
similar::DiffTag::Replace => {
|
||||
// Ensure replacements are equal length
|
||||
len = left_len.min(right_len);
|
||||
DataDiffKind::Replace
|
||||
}
|
||||
};
|
||||
let left_data = &left_data[left_range];
|
||||
let right_data = &right_data[right_range];
|
||||
left_data_diff.push(DataDiff {
|
||||
data: left_data[..len.min(left_data.len())].to_vec(),
|
||||
kind,
|
||||
len,
|
||||
..Default::default()
|
||||
});
|
||||
right_data_diff.push(DataDiff {
|
||||
data: right_data[..len.min(right_data.len())].to_vec(),
|
||||
kind,
|
||||
len,
|
||||
..Default::default()
|
||||
});
|
||||
if kind == DataDiffKind::Replace {
|
||||
match left_len.cmp(&right_len) {
|
||||
Ordering::Less => {
|
||||
let len = right_len - left_len;
|
||||
left_data_diff.push(DataDiff {
|
||||
data: vec![],
|
||||
kind: DataDiffKind::Insert,
|
||||
len,
|
||||
..Default::default()
|
||||
});
|
||||
right_data_diff.push(DataDiff {
|
||||
data: right_data[left_len..right_len].to_vec(),
|
||||
kind: DataDiffKind::Insert,
|
||||
len,
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
Ordering::Greater => {
|
||||
let len = left_len - right_len;
|
||||
left_data_diff.push(DataDiff {
|
||||
data: left_data[right_len..left_len].to_vec(),
|
||||
kind: DataDiffKind::Delete,
|
||||
len,
|
||||
..Default::default()
|
||||
});
|
||||
right_data_diff.push(DataDiff {
|
||||
data: vec![],
|
||||
kind: DataDiffKind::Delete,
|
||||
len,
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
Ordering::Equal => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(bytes_match_ratio, left_data_diff, right_data_diff)
|
||||
}
|
||||
|
||||
/// Compares relocations contained within a certain data range.
|
||||
fn diff_data_relocs_for_range<'left, 'right>(
|
||||
left_obj: &'left Object,
|
||||
right_obj: &'right Object,
|
||||
@@ -172,76 +262,10 @@ pub fn diff_data_section(
|
||||
.min(right_section.size);
|
||||
let left_data = &left_section.data[..left_max as usize];
|
||||
let right_data = &right_section.data[..right_max as usize];
|
||||
let ops = capture_diff_slices(Algorithm::Patience, left_data, right_data);
|
||||
let match_percent = get_diff_ratio(&ops, left_data.len(), right_data.len()) * 100.0;
|
||||
|
||||
let mut left_data_diff = Vec::<DataDiff>::new();
|
||||
let mut right_data_diff = Vec::<DataDiff>::new();
|
||||
for op in ops {
|
||||
let (tag, left_range, right_range) = op.as_tag_tuple();
|
||||
let left_len = left_range.len();
|
||||
let right_len = right_range.len();
|
||||
let mut len = left_len.max(right_len);
|
||||
let kind = match tag {
|
||||
similar::DiffTag::Equal => DataDiffKind::None,
|
||||
similar::DiffTag::Delete => DataDiffKind::Delete,
|
||||
similar::DiffTag::Insert => DataDiffKind::Insert,
|
||||
similar::DiffTag::Replace => {
|
||||
// Ensure replacements are equal length
|
||||
len = left_len.min(right_len);
|
||||
DataDiffKind::Replace
|
||||
}
|
||||
};
|
||||
let left_data = &left_section.data[left_range];
|
||||
let right_data = &right_section.data[right_range];
|
||||
left_data_diff.push(DataDiff {
|
||||
data: left_data[..len.min(left_data.len())].to_vec(),
|
||||
kind,
|
||||
len,
|
||||
..Default::default()
|
||||
});
|
||||
right_data_diff.push(DataDiff {
|
||||
data: right_data[..len.min(right_data.len())].to_vec(),
|
||||
kind,
|
||||
len,
|
||||
..Default::default()
|
||||
});
|
||||
if kind == DataDiffKind::Replace {
|
||||
match left_len.cmp(&right_len) {
|
||||
Ordering::Less => {
|
||||
let len = right_len - left_len;
|
||||
left_data_diff.push(DataDiff {
|
||||
data: vec![],
|
||||
kind: DataDiffKind::Insert,
|
||||
len,
|
||||
..Default::default()
|
||||
});
|
||||
right_data_diff.push(DataDiff {
|
||||
data: right_data[left_len..right_len].to_vec(),
|
||||
kind: DataDiffKind::Insert,
|
||||
len,
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
Ordering::Greater => {
|
||||
let len = left_len - right_len;
|
||||
left_data_diff.push(DataDiff {
|
||||
data: left_data[right_len..left_len].to_vec(),
|
||||
kind: DataDiffKind::Delete,
|
||||
len,
|
||||
..Default::default()
|
||||
});
|
||||
right_data_diff.push(DataDiff {
|
||||
data: vec![],
|
||||
kind: DataDiffKind::Delete,
|
||||
len,
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
Ordering::Equal => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
let (bytes_match_ratio, left_data_diff, right_data_diff) =
|
||||
diff_data_range(left_data, right_data);
|
||||
let match_percent = bytes_match_ratio * 100.0;
|
||||
|
||||
let mut left_reloc_diffs = Vec::new();
|
||||
let mut right_reloc_diffs = Vec::new();
|
||||
@@ -300,6 +324,55 @@ pub fn diff_data_section(
|
||||
Ok((left_section_diff, right_section_diff))
|
||||
}
|
||||
|
||||
pub fn no_diff_data_symbol(obj: &Object, symbol_index: usize) -> Result<SymbolDiff> {
|
||||
let symbol = &obj.symbols[symbol_index];
|
||||
let section_idx = symbol.section.ok_or_else(|| anyhow!("Data symbol section not found"))?;
|
||||
let section = &obj.sections[section_idx];
|
||||
|
||||
let start = symbol
|
||||
.address
|
||||
.checked_sub(section.address)
|
||||
.ok_or_else(|| anyhow!("Symbol address out of section bounds"))?;
|
||||
let end = start + symbol.size;
|
||||
if end > section.size {
|
||||
return Err(anyhow!(
|
||||
"Symbol {} size out of section bounds ({} > {})",
|
||||
symbol.name,
|
||||
end,
|
||||
section.size
|
||||
));
|
||||
}
|
||||
let range = start as usize..end as usize;
|
||||
let data = §ion.data[range.clone()];
|
||||
|
||||
let len = symbol.size as usize;
|
||||
let data_diff =
|
||||
vec![DataDiff { data: data.to_vec(), kind: DataDiffKind::None, len, ..Default::default() }];
|
||||
|
||||
let mut reloc_diffs = Vec::new();
|
||||
for reloc in section.relocations.iter() {
|
||||
if !range.contains(&(reloc.address as usize)) {
|
||||
continue;
|
||||
}
|
||||
let reloc_len = obj.arch.data_reloc_size(reloc.flags);
|
||||
let range = reloc.address as usize..reloc.address as usize + reloc_len;
|
||||
reloc_diffs.push(DataRelocationDiff {
|
||||
reloc: reloc.clone(),
|
||||
kind: DataDiffKind::None,
|
||||
range,
|
||||
});
|
||||
}
|
||||
|
||||
Ok(SymbolDiff {
|
||||
target_symbol: None,
|
||||
match_percent: None,
|
||||
diff_score: None,
|
||||
data_diff,
|
||||
data_reloc_diff: reloc_diffs,
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn diff_data_symbol(
|
||||
left_obj: &Object,
|
||||
right_obj: &Object,
|
||||
@@ -348,6 +421,9 @@ pub fn diff_data_symbol(
|
||||
let left_data = &left_section.data[left_range.clone()];
|
||||
let right_data = &right_section.data[right_range.clone()];
|
||||
|
||||
let (bytes_match_ratio, left_data_diff, right_data_diff) =
|
||||
diff_data_range(left_data, right_data);
|
||||
|
||||
let reloc_diffs = diff_data_relocs_for_range(
|
||||
left_obj,
|
||||
right_obj,
|
||||
@@ -357,10 +433,9 @@ pub fn diff_data_symbol(
|
||||
right_range,
|
||||
);
|
||||
|
||||
let ops = capture_diff_slices(Algorithm::Patience, left_data, right_data);
|
||||
let bytes_match_ratio = get_diff_ratio(&ops, left_data.len(), right_data.len());
|
||||
|
||||
let mut match_ratio = bytes_match_ratio;
|
||||
let mut left_reloc_diffs = Vec::new();
|
||||
let mut right_reloc_diffs = Vec::new();
|
||||
if !reloc_diffs.is_empty() {
|
||||
let mut total_reloc_bytes = 0;
|
||||
let mut matching_reloc_bytes = 0;
|
||||
@@ -376,6 +451,27 @@ pub fn diff_data_symbol(
|
||||
if diff_kind == DataDiffKind::None {
|
||||
matching_reloc_bytes += reloc_diff_len;
|
||||
}
|
||||
|
||||
if let Some(left_reloc) = left_reloc {
|
||||
let len = left_obj.arch.data_reloc_size(left_reloc.relocation.flags);
|
||||
let range = left_reloc.relocation.address as usize
|
||||
..left_reloc.relocation.address as usize + len;
|
||||
left_reloc_diffs.push(DataRelocationDiff {
|
||||
reloc: left_reloc.relocation.clone(),
|
||||
kind: diff_kind,
|
||||
range,
|
||||
});
|
||||
}
|
||||
if let Some(right_reloc) = right_reloc {
|
||||
let len = right_obj.arch.data_reloc_size(right_reloc.relocation.flags);
|
||||
let range = right_reloc.relocation.address as usize
|
||||
..right_reloc.relocation.address as usize + len;
|
||||
right_reloc_diffs.push(DataRelocationDiff {
|
||||
reloc: right_reloc.relocation.clone(),
|
||||
kind: diff_kind,
|
||||
range,
|
||||
});
|
||||
}
|
||||
}
|
||||
if total_reloc_bytes > 0 {
|
||||
let relocs_match_ratio = matching_reloc_bytes as f32 / total_reloc_bytes as f32;
|
||||
@@ -397,13 +493,17 @@ pub fn diff_data_symbol(
|
||||
target_symbol: Some(right_symbol_idx),
|
||||
match_percent: Some(match_percent),
|
||||
diff_score: None,
|
||||
instruction_rows: vec![],
|
||||
data_diff: left_data_diff,
|
||||
data_reloc_diff: left_reloc_diffs,
|
||||
..Default::default()
|
||||
},
|
||||
SymbolDiff {
|
||||
target_symbol: Some(left_symbol_idx),
|
||||
match_percent: Some(match_percent),
|
||||
diff_score: None,
|
||||
instruction_rows: vec![],
|
||||
data_diff: right_data_diff,
|
||||
data_reloc_diff: right_reloc_diffs,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
@@ -379,7 +379,9 @@ pub enum HoverItem {
|
||||
}
|
||||
|
||||
pub fn symbol_context(obj: &Object, symbol_index: usize) -> Vec<ContextItem> {
|
||||
let symbol = &obj.symbols[symbol_index];
|
||||
let Some(symbol) = obj.symbols.get(symbol_index) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let mut out = Vec::new();
|
||||
out.push(ContextItem::Copy { value: symbol.name.clone(), label: None });
|
||||
if let Some(name) = &symbol.demangled_name {
|
||||
@@ -403,7 +405,9 @@ pub fn symbol_hover(
|
||||
addend: i64,
|
||||
override_color: Option<HoverItemColor>,
|
||||
) -> Vec<HoverItem> {
|
||||
let symbol = &obj.symbols[symbol_index];
|
||||
let Some(symbol) = obj.symbols.get(symbol_index) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let addend_str = match addend.cmp(&0i64) {
|
||||
Ordering::Greater => format!("+{addend:x}"),
|
||||
Ordering::Less => format!("-{:x}", -addend),
|
||||
|
||||
@@ -13,7 +13,8 @@ use crate::{
|
||||
code::{diff_code, no_diff_code},
|
||||
data::{
|
||||
diff_bss_section, diff_bss_symbol, diff_data_section, diff_data_symbol,
|
||||
diff_generic_section, no_diff_bss_section, no_diff_data_section,
|
||||
diff_generic_section, no_diff_bss_section, no_diff_data_section, no_diff_data_symbol,
|
||||
symbol_name_matches,
|
||||
},
|
||||
},
|
||||
obj::{InstructionRef, Object, Relocation, SectionKind, Symbol, SymbolFlag},
|
||||
@@ -44,6 +45,8 @@ pub struct SymbolDiff {
|
||||
pub match_percent: Option<f32>,
|
||||
pub diff_score: Option<(u64, u64)>,
|
||||
pub instruction_rows: Vec<InstructionDiffRow>,
|
||||
pub data_diff: Vec<DataDiff>,
|
||||
pub data_reloc_diff: Vec<DataRelocationDiff>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
@@ -163,7 +166,7 @@ impl ObjectDiff {
|
||||
target_symbol: None,
|
||||
match_percent: None,
|
||||
diff_score: None,
|
||||
instruction_rows: vec![],
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
for _ in obj.sections.iter() {
|
||||
@@ -262,7 +265,11 @@ pub fn diff_objs(
|
||||
left_out.symbols[left_symbol_ref] =
|
||||
no_diff_code(left_obj, left_symbol_ref, diff_config)?;
|
||||
}
|
||||
SectionKind::Data | SectionKind::Bss | SectionKind::Common => {
|
||||
SectionKind::Data => {
|
||||
left_out.symbols[left_symbol_ref] =
|
||||
no_diff_data_symbol(left_obj, left_symbol_ref)?;
|
||||
}
|
||||
SectionKind::Bss | SectionKind::Common => {
|
||||
// Nothing needs to be done
|
||||
}
|
||||
SectionKind::Unknown => unreachable!(),
|
||||
@@ -275,7 +282,11 @@ pub fn diff_objs(
|
||||
right_out.symbols[right_symbol_ref] =
|
||||
no_diff_code(right_obj, right_symbol_ref, diff_config)?;
|
||||
}
|
||||
SectionKind::Data | SectionKind::Bss | SectionKind::Common => {
|
||||
SectionKind::Data => {
|
||||
right_out.symbols[right_symbol_ref] =
|
||||
no_diff_data_symbol(right_obj, right_symbol_ref)?;
|
||||
}
|
||||
SectionKind::Bss | SectionKind::Common => {
|
||||
// Nothing needs to be done
|
||||
}
|
||||
SectionKind::Unknown => unreachable!(),
|
||||
@@ -575,47 +586,60 @@ fn matching_symbols(
|
||||
&mut matches,
|
||||
)?;
|
||||
}
|
||||
for (symbol_idx, symbol) in left.symbols.iter().enumerate() {
|
||||
if symbol.size == 0 || symbol.flags.contains(SymbolFlag::Ignored) {
|
||||
continue;
|
||||
}
|
||||
let section_kind = symbol_section_kind(left, symbol);
|
||||
if section_kind == SectionKind::Unknown {
|
||||
continue;
|
||||
}
|
||||
if left_used.contains(&symbol_idx) {
|
||||
continue;
|
||||
}
|
||||
let symbol_match = SymbolMatch {
|
||||
left: Some(symbol_idx),
|
||||
right: find_symbol(right, left, symbol, Some(&right_used)),
|
||||
prev: find_symbol(prev, left, symbol, None),
|
||||
section_kind,
|
||||
};
|
||||
matches.push(symbol_match);
|
||||
if let Some(right) = symbol_match.right {
|
||||
right_used.insert(right);
|
||||
// Do two passes for nameless literals. The first only pairs up perfect matches to ensure
|
||||
// those are correct first, while the second pass catches near matches.
|
||||
for fuzzy_literals in [false, true] {
|
||||
for (symbol_idx, symbol) in left.symbols.iter().enumerate() {
|
||||
if symbol.size == 0 || symbol.flags.contains(SymbolFlag::Ignored) {
|
||||
continue;
|
||||
}
|
||||
let section_kind = symbol_section_kind(left, symbol);
|
||||
if section_kind == SectionKind::Unknown {
|
||||
continue;
|
||||
}
|
||||
if left_used.contains(&symbol_idx) {
|
||||
continue;
|
||||
}
|
||||
let symbol_match = SymbolMatch {
|
||||
left: Some(symbol_idx),
|
||||
right: find_symbol(right, left, symbol_idx, Some(&right_used), fuzzy_literals),
|
||||
prev: find_symbol(prev, left, symbol_idx, None, fuzzy_literals),
|
||||
section_kind,
|
||||
};
|
||||
matches.push(symbol_match);
|
||||
if let Some(right) = symbol_match.right {
|
||||
left_used.insert(symbol_idx);
|
||||
right_used.insert(right);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(right) = right {
|
||||
for (symbol_idx, symbol) in right.symbols.iter().enumerate() {
|
||||
if symbol.size == 0 || symbol.flags.contains(SymbolFlag::Ignored) {
|
||||
continue;
|
||||
// Do two passes for nameless literals. The first only pairs up perfect matches to ensure
|
||||
// those are correct first, while the second pass catches near matches.
|
||||
for fuzzy_literals in [false, true] {
|
||||
for (symbol_idx, symbol) in right.symbols.iter().enumerate() {
|
||||
if symbol.size == 0 || symbol.flags.contains(SymbolFlag::Ignored) {
|
||||
continue;
|
||||
}
|
||||
let section_kind = symbol_section_kind(right, symbol);
|
||||
if section_kind == SectionKind::Unknown {
|
||||
continue;
|
||||
}
|
||||
if right_used.contains(&symbol_idx) {
|
||||
continue;
|
||||
}
|
||||
let symbol_match = SymbolMatch {
|
||||
left: None,
|
||||
right: Some(symbol_idx),
|
||||
prev: find_symbol(prev, right, symbol_idx, None, fuzzy_literals),
|
||||
section_kind,
|
||||
};
|
||||
matches.push(symbol_match);
|
||||
if symbol_match.prev.is_some() {
|
||||
right_used.insert(symbol_idx);
|
||||
}
|
||||
}
|
||||
let section_kind = symbol_section_kind(right, symbol);
|
||||
if section_kind == SectionKind::Unknown {
|
||||
continue;
|
||||
}
|
||||
if right_used.contains(&symbol_idx) {
|
||||
continue;
|
||||
}
|
||||
matches.push(SymbolMatch {
|
||||
left: None,
|
||||
right: Some(symbol_idx),
|
||||
prev: find_symbol(prev, right, symbol, None),
|
||||
section_kind,
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(matches)
|
||||
@@ -637,7 +661,10 @@ where
|
||||
|
||||
fn symbol_section<'obj>(obj: &'obj Object, symbol: &Symbol) -> Option<(&'obj str, SectionKind)> {
|
||||
if let Some(section) = symbol.section.and_then(|section_idx| obj.sections.get(section_idx)) {
|
||||
Some((section.name.as_str(), section.kind))
|
||||
// Match x86 .rdata$r against .rdata$rs
|
||||
let section_name =
|
||||
section.name.split_once('$').map_or(section.name.as_str(), |(prefix, _)| prefix);
|
||||
Some((section_name, section.kind))
|
||||
} else if symbol.flags.contains(SymbolFlag::Common) {
|
||||
Some((".comm", SectionKind::Common))
|
||||
} else {
|
||||
@@ -653,52 +680,94 @@ fn symbol_section_kind(obj: &Object, symbol: &Symbol) -> SectionKind {
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if a symbol is a compiler-generated literal like @1234.
|
||||
fn is_symbol_compiler_generated_literal(symbol: &Symbol) -> bool {
|
||||
if !symbol.name.starts_with('@') {
|
||||
return false;
|
||||
}
|
||||
if !symbol.name[1..].chars().all(char::is_numeric) {
|
||||
// Exclude @stringBase0, @GUARD@, etc.
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn find_symbol(
|
||||
obj: Option<&Object>,
|
||||
in_obj: &Object,
|
||||
in_symbol: &Symbol,
|
||||
in_symbol_idx: usize,
|
||||
used: Option<&BTreeSet<usize>>,
|
||||
fuzzy_literals: bool,
|
||||
) -> Option<usize> {
|
||||
let in_symbol = &in_obj.symbols[in_symbol_idx];
|
||||
let obj = obj?;
|
||||
let (section_name, section_kind) = symbol_section(in_obj, in_symbol)?;
|
||||
|
||||
// Match compiler-generated symbols against each other (e.g. @251 -> @60)
|
||||
// If they are in the same section and have the same value
|
||||
if is_symbol_compiler_generated_literal(in_symbol)
|
||||
&& matches!(section_kind, SectionKind::Data | SectionKind::Bss)
|
||||
{
|
||||
let mut closest_match_symbol_idx = None;
|
||||
let mut closest_match_percent = 0.0;
|
||||
for (symbol_idx, symbol) in unmatched_symbols(obj, used) {
|
||||
let Some(section_index) = symbol.section else {
|
||||
continue;
|
||||
};
|
||||
if obj.sections[section_index].name != section_name {
|
||||
continue;
|
||||
}
|
||||
if !is_symbol_compiler_generated_literal(symbol) {
|
||||
continue;
|
||||
}
|
||||
match section_kind {
|
||||
SectionKind::Data => {
|
||||
// For data, pick the first symbol with exactly matching bytes and relocations.
|
||||
// If no symbols match exactly, and `fuzzy_literals` is true, pick the closest
|
||||
// plausible match instead.
|
||||
if let Ok((left_diff, _right_diff)) =
|
||||
diff_data_symbol(in_obj, obj, in_symbol_idx, symbol_idx)
|
||||
&& let Some(match_percent) = left_diff.match_percent
|
||||
&& (match_percent == 100.0
|
||||
|| (fuzzy_literals
|
||||
&& match_percent >= 50.0
|
||||
&& match_percent > closest_match_percent))
|
||||
{
|
||||
closest_match_symbol_idx = Some(symbol_idx);
|
||||
closest_match_percent = match_percent;
|
||||
if match_percent == 100.0 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SectionKind::Bss => {
|
||||
// For BSS, pick the first symbol that has the exact matching size.
|
||||
if in_symbol.size == symbol.size {
|
||||
closest_match_symbol_idx = Some(symbol_idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
return closest_match_symbol_idx;
|
||||
}
|
||||
|
||||
// Try to find an exact name match
|
||||
if let Some((symbol_idx, _)) = unmatched_symbols(obj, used).find(|(_, symbol)| {
|
||||
symbol.name == in_symbol.name && symbol_section_kind(obj, symbol) == section_kind
|
||||
}) {
|
||||
return Some(symbol_idx);
|
||||
}
|
||||
// Match compiler-generated symbols against each other (e.g. @251 -> @60)
|
||||
// If they are at the same address in the same section
|
||||
if in_symbol.name.starts_with('@')
|
||||
&& matches!(section_kind, SectionKind::Data | SectionKind::Bss)
|
||||
&& let Some((symbol_idx, _)) = unmatched_symbols(obj, used).find(|(_, symbol)| {
|
||||
let Some(section_index) = symbol.section else {
|
||||
return false;
|
||||
};
|
||||
symbol.name.starts_with('@')
|
||||
&& symbol.address == in_symbol.address
|
||||
&& obj.sections[section_index].name == section_name
|
||||
})
|
||||
{
|
||||
|
||||
if let Some((symbol_idx, _)) = unmatched_symbols(obj, used).find(|&(_, symbol)| {
|
||||
symbol_name_matches(&in_symbol.name, &symbol.name)
|
||||
&& symbol_section_kind(obj, symbol) == section_kind
|
||||
&& symbol_section(obj, symbol).is_some_and(|(name, _)| name == section_name)
|
||||
}) {
|
||||
return Some(symbol_idx);
|
||||
}
|
||||
// Match Metrowerks symbol$1234 against symbol$2345
|
||||
if let Some((prefix, suffix)) = in_symbol.name.split_once('$') {
|
||||
if !suffix.chars().all(char::is_numeric) {
|
||||
return None;
|
||||
}
|
||||
if let Some((symbol_idx, _)) = unmatched_symbols(obj, used).find(|&(_, symbol)| {
|
||||
if let Some((p, s)) = symbol.name.split_once('$') {
|
||||
prefix == p
|
||||
&& s.chars().all(char::is_numeric)
|
||||
&& symbol_section_kind(obj, symbol) == section_kind
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}) {
|
||||
return Some(symbol_idx);
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
@@ -749,3 +818,11 @@ fn find_section(
|
||||
s.kind == section_kind && s.name == name && !matches.iter().any(|m| m.right == Some(i))
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub enum DiffSide {
|
||||
/// The target/expected side of the diff.
|
||||
Target,
|
||||
/// The base side of the diff.
|
||||
Base,
|
||||
}
|
||||
|
||||
@@ -170,13 +170,6 @@ pub enum JobResult {
|
||||
CreateScratch(Option<Box<CreateScratchResult>>),
|
||||
}
|
||||
|
||||
fn should_cancel(rx: &Receiver<()>) -> bool {
|
||||
match rx.try_recv() {
|
||||
Ok(_) | Err(TryRecvError::Disconnected) => true,
|
||||
Err(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn start_job(
|
||||
waker: Waker,
|
||||
title: &str,
|
||||
@@ -203,7 +196,6 @@ fn start_job(
|
||||
}
|
||||
});
|
||||
let id = JOB_ID.fetch_add(1, Ordering::Relaxed);
|
||||
// log::info!("Started job {}", id); TODO
|
||||
JobState { id, kind, handle: Some(handle), context, cancel: tx }
|
||||
}
|
||||
|
||||
@@ -228,3 +220,10 @@ fn update_status(
|
||||
context.waker.wake_by_ref();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn should_cancel(rx: &Receiver<()>) -> bool {
|
||||
match rx.try_recv() {
|
||||
Ok(_) | Err(TryRecvError::Disconnected) => true,
|
||||
Err(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use typed_path::Utf8PlatformPathBuf;
|
||||
|
||||
use crate::{
|
||||
build::{BuildConfig, BuildStatus, run_make},
|
||||
diff::{DiffObjConfig, MappingConfig, ObjectDiff, diff_objs},
|
||||
diff::{DiffObjConfig, DiffSide, MappingConfig, ObjectDiff, diff_objs},
|
||||
jobs::{Job, JobContext, JobResult, JobState, start_job, update_status},
|
||||
obj::{Object, read},
|
||||
};
|
||||
@@ -117,7 +117,7 @@ fn run_build(
|
||||
&cancel,
|
||||
)?;
|
||||
step_idx += 1;
|
||||
match read::read(target_path.as_ref(), &config.diff_obj_config) {
|
||||
match read::read(target_path.as_ref(), &config.diff_obj_config, DiffSide::Target) {
|
||||
Ok(obj) => Some(obj),
|
||||
Err(e) => {
|
||||
first_status = BuildStatus {
|
||||
@@ -141,7 +141,7 @@ fn run_build(
|
||||
Some(base_path) if second_status.success => {
|
||||
update_status(context, format!("Loading base {base_path}"), step_idx, total, &cancel)?;
|
||||
step_idx += 1;
|
||||
match read::read(base_path.as_ref(), &config.diff_obj_config) {
|
||||
match read::read(base_path.as_ref(), &config.diff_obj_config, DiffSide::Base) {
|
||||
Ok(obj) => Some(obj),
|
||||
Err(e) => {
|
||||
second_status = BuildStatus {
|
||||
|
||||
@@ -12,10 +12,10 @@ use object::{Object as _, ObjectSection as _, ObjectSymbol as _};
|
||||
|
||||
use crate::{
|
||||
arch::{Arch, RelocationOverride, RelocationOverrideTarget, new_arch},
|
||||
diff::DiffObjConfig,
|
||||
diff::{DiffObjConfig, DiffSide},
|
||||
obj::{
|
||||
FlowAnalysisResult, Object, Relocation, RelocationFlags, Section, SectionData, SectionFlag,
|
||||
SectionKind, Symbol, SymbolFlag, SymbolKind,
|
||||
SectionKind, Symbol, SymbolFlag, SymbolFlagSet, SymbolKind,
|
||||
split_meta::{SPLITMETA_SECTION, SplitMeta},
|
||||
},
|
||||
util::{align_data_slice_to, align_u64_to, read_u16, read_u32},
|
||||
@@ -74,6 +74,14 @@ fn map_symbol(
|
||||
{
|
||||
flags |= SymbolFlag::Hidden;
|
||||
}
|
||||
if file.format() == object::BinaryFormat::Coff
|
||||
&& let Ok(name) = symbol.name()
|
||||
&& (name.starts_with("except_data_")
|
||||
|| name.starts_with("__unwind")
|
||||
|| name.starts_with("__catch"))
|
||||
{
|
||||
flags |= SymbolFlag::Hidden;
|
||||
}
|
||||
|
||||
let kind = match symbol.kind() {
|
||||
object::SymbolKind::Text => SymbolKind::Function,
|
||||
@@ -110,7 +118,7 @@ fn map_symbols(
|
||||
split_meta: Option<&SplitMeta>,
|
||||
) -> Result<(Vec<Symbol>, Vec<usize>)> {
|
||||
let symbol_count = obj_file.symbols().count();
|
||||
let mut symbols = Vec::<Symbol>::with_capacity(symbol_count);
|
||||
let mut symbols = Vec::<Symbol>::with_capacity(symbol_count + obj_file.sections().count());
|
||||
let mut symbol_indices = Vec::<usize>::with_capacity(symbol_count + 1);
|
||||
for obj_symbol in obj_file.symbols() {
|
||||
if symbol_indices.len() <= obj_symbol.index().0 {
|
||||
@@ -127,10 +135,56 @@ fn map_symbols(
|
||||
Ok((symbols, symbol_indices))
|
||||
}
|
||||
|
||||
/// Add an extra fake symbol to the start of each data section in order to allow the user to diff
|
||||
/// all of the data in the section at once by clicking on this fake symbol at the top of the list.
|
||||
fn add_section_symbols(sections: &[Section], symbols: &mut Vec<Symbol>) {
|
||||
for (section_idx, section) in sections.iter().enumerate() {
|
||||
if section.kind != SectionKind::Data {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Instead of naming the fake section symbol after `section.name` (e.g. ".data") we use
|
||||
// `section.id` (e.g. ".data-0") so that it is unique when multiple sections with the same
|
||||
// name exist and it also doesn't conflict with any real section symbols from the object.
|
||||
let name = if section.flags.contains(SectionFlag::Combined) {
|
||||
// For combined sections, `section.id` (e.g. ".data-combined") is inconsistent with
|
||||
// uncombined section IDs, so we add the "-0" suffix to the name to enable proper
|
||||
// pairing when one side had multiple sections combined and the other only had one
|
||||
// section to begin with.
|
||||
format!("[{}-0]", section.name)
|
||||
} else {
|
||||
format!("[{}]", section.id)
|
||||
};
|
||||
|
||||
// `section.size` can include extra padding, so instead prefer using the address that the
|
||||
// last symbol ends at when there are any symbols in the section.
|
||||
let size = symbols
|
||||
.iter()
|
||||
.filter(|s| {
|
||||
s.section == Some(section_idx) && s.kind == SymbolKind::Object && s.size > 0
|
||||
})
|
||||
.map(|s| s.address + s.size)
|
||||
.max()
|
||||
.unwrap_or(section.size);
|
||||
|
||||
symbols.push(Symbol {
|
||||
name,
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size,
|
||||
kind: SymbolKind::Section,
|
||||
section: Some(section_idx),
|
||||
flags: SymbolFlagSet::default() | SymbolFlag::Local,
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// When inferring a symbol's size, we ignore symbols that start with specific prefixes. They are
|
||||
/// usually emitted as branch targets and do not represent the start of a function or object.
|
||||
fn is_local_label(symbol: &Symbol) -> bool {
|
||||
const LABEL_PREFIXES: &[&str] = &[".L", "LAB_"];
|
||||
const LABEL_PREFIXES: &[&str] = &[".L", "LAB_", "switchD_"];
|
||||
symbol.size == 0
|
||||
&& symbol.flags.contains(SymbolFlag::Local)
|
||||
&& LABEL_PREFIXES.iter().any(|p| symbol.name.starts_with(p))
|
||||
@@ -208,7 +262,11 @@ fn infer_symbol_sizes(arch: &dyn Arch, symbols: &mut [Symbol], sections: &[Secti
|
||||
let section = §ions[section_idx];
|
||||
let next_address =
|
||||
next_symbol.map(|s| s.address).unwrap_or_else(|| section.address + section.size);
|
||||
let new_size = if section.kind == SectionKind::Code {
|
||||
let new_size = if symbol.kind == SymbolKind::Section && section.kind == SectionKind::Data {
|
||||
// Data sections already have always-visible section symbols created by objdiff to allow
|
||||
// diffing them, so no need to unhide these.
|
||||
0
|
||||
} else if section.kind == SectionKind::Code {
|
||||
arch.infer_function_size(symbol, section, next_address)?
|
||||
} else {
|
||||
next_address.saturating_sub(symbol.address)
|
||||
@@ -917,21 +975,25 @@ fn do_combine_sections(
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub fn read(obj_path: &std::path::Path, config: &DiffObjConfig) -> Result<Object> {
|
||||
pub fn read(
|
||||
obj_path: &std::path::Path,
|
||||
config: &DiffObjConfig,
|
||||
diff_side: DiffSide,
|
||||
) -> Result<Object> {
|
||||
let (data, timestamp) = {
|
||||
let file = std::fs::File::open(obj_path)?;
|
||||
let timestamp = filetime::FileTime::from_last_modification_time(&file.metadata()?);
|
||||
(unsafe { memmap2::Mmap::map(&file) }?, timestamp)
|
||||
};
|
||||
let mut obj = parse(&data, config)?;
|
||||
let mut obj = parse(&data, config, diff_side)?;
|
||||
obj.path = Some(obj_path.to_path_buf());
|
||||
obj.timestamp = Some(timestamp);
|
||||
Ok(obj)
|
||||
}
|
||||
|
||||
pub fn parse(data: &[u8], config: &DiffObjConfig) -> Result<Object> {
|
||||
pub fn parse(data: &[u8], config: &DiffObjConfig, diff_side: DiffSide) -> Result<Object> {
|
||||
let obj_file = object::File::parse(data)?;
|
||||
let mut arch = new_arch(&obj_file)?;
|
||||
let mut arch = new_arch(&obj_file, diff_side)?;
|
||||
let split_meta = parse_split_meta(&obj_file)?;
|
||||
let (mut sections, section_indices) =
|
||||
map_sections(arch.as_ref(), &obj_file, split_meta.as_ref())?;
|
||||
@@ -942,6 +1004,7 @@ pub fn parse(data: &[u8], config: &DiffObjConfig) -> Result<Object> {
|
||||
if config.combine_data_sections || config.combine_text_sections {
|
||||
combine_sections(&mut sections, &mut symbols, config)?;
|
||||
}
|
||||
add_section_symbols(§ions, &mut symbols);
|
||||
arch.post_init(§ions, &symbols);
|
||||
let mut obj = Object {
|
||||
arch,
|
||||
|
||||
@@ -6,7 +6,12 @@ mod common;
|
||||
#[cfg(feature = "arm")]
|
||||
fn read_arm() {
|
||||
let diff_config = diff::DiffObjConfig { ..Default::default() };
|
||||
let obj = obj::read::parse(include_object!("data/arm/LinkStateItem.o"), &diff_config).unwrap();
|
||||
let obj = obj::read::parse(
|
||||
include_object!("data/arm/LinkStateItem.o"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(obj);
|
||||
let symbol_idx =
|
||||
obj.symbols.iter().position(|s| s.name == "_ZN13LinkStateItem12OnStateLeaveEi").unwrap();
|
||||
@@ -20,7 +25,9 @@ fn read_arm() {
|
||||
#[cfg(feature = "arm")]
|
||||
fn read_thumb() {
|
||||
let diff_config = diff::DiffObjConfig { ..Default::default() };
|
||||
let obj = obj::read::parse(include_object!("data/arm/thumb.o"), &diff_config).unwrap();
|
||||
let obj =
|
||||
obj::read::parse(include_object!("data/arm/thumb.o"), &diff_config, diff::DiffSide::Base)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(obj);
|
||||
let symbol_idx = obj
|
||||
.symbols
|
||||
@@ -37,7 +44,12 @@ fn read_thumb() {
|
||||
#[cfg(feature = "arm")]
|
||||
fn combine_text_sections() {
|
||||
let diff_config = diff::DiffObjConfig { combine_text_sections: true, ..Default::default() };
|
||||
let obj = obj::read::parse(include_object!("data/arm/enemy300.o"), &diff_config).unwrap();
|
||||
let obj = obj::read::parse(
|
||||
include_object!("data/arm/enemy300.o"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
let symbol_idx = obj.symbols.iter().position(|s| s.name == "Enemy300Draw").unwrap();
|
||||
let diff = diff::code::no_diff_code(&obj, symbol_idx, &diff_config).unwrap();
|
||||
insta::assert_debug_snapshot!(diff.instruction_rows);
|
||||
|
||||
@@ -6,7 +6,9 @@ mod common;
|
||||
#[cfg(feature = "mips")]
|
||||
fn read_mips() {
|
||||
let diff_config = diff::DiffObjConfig { mips_register_prefix: true, ..Default::default() };
|
||||
let obj = obj::read::parse(include_object!("data/mips/main.c.o"), &diff_config).unwrap();
|
||||
let obj =
|
||||
obj::read::parse(include_object!("data/mips/main.c.o"), &diff_config, diff::DiffSide::Base)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(obj);
|
||||
let symbol_idx = obj.symbols.iter().position(|s| s.name == "ControlEntry").unwrap();
|
||||
let diff = diff::code::no_diff_code(&obj, symbol_idx, &diff_config).unwrap();
|
||||
@@ -19,9 +21,19 @@ fn read_mips() {
|
||||
#[cfg(feature = "mips")]
|
||||
fn cross_endian_diff() {
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let obj_be = obj::read::parse(include_object!("data/mips/code_be.o"), &diff_config).unwrap();
|
||||
let obj_be = obj::read::parse(
|
||||
include_object!("data/mips/code_be.o"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(obj_be.endianness, object::Endianness::Big);
|
||||
let obj_le = obj::read::parse(include_object!("data/mips/code_le.o"), &diff_config).unwrap();
|
||||
let obj_le = obj::read::parse(
|
||||
include_object!("data/mips/code_le.o"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(obj_le.endianness, object::Endianness::Little);
|
||||
let left_symbol_idx = obj_be.symbols.iter().position(|s| s.name == "func_00000000").unwrap();
|
||||
let right_symbol_idx =
|
||||
@@ -42,6 +54,11 @@ fn cross_endian_diff() {
|
||||
#[cfg(feature = "mips")]
|
||||
fn filter_non_matching() {
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let obj = obj::read::parse(include_object!("data/mips/vw_main.c.o"), &diff_config).unwrap();
|
||||
let obj = obj::read::parse(
|
||||
include_object!("data/mips/vw_main.c.o"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(obj.symbols);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ mod common;
|
||||
#[cfg(feature = "ppc")]
|
||||
fn read_ppc() {
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let obj = obj::read::parse(include_object!("data/ppc/IObj.o"), &diff_config).unwrap();
|
||||
let obj =
|
||||
obj::read::parse(include_object!("data/ppc/IObj.o"), &diff_config, diff::DiffSide::Base)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(obj);
|
||||
let symbol_idx =
|
||||
obj.symbols.iter().position(|s| s.name == "Type2Text__10SObjectTagFUi").unwrap();
|
||||
@@ -24,7 +26,12 @@ fn read_ppc() {
|
||||
#[cfg(feature = "ppc")]
|
||||
fn read_dwarf1_line_info() {
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let obj = obj::read::parse(include_object!("data/ppc/m_Do_hostIO.o"), &diff_config).unwrap();
|
||||
let obj = obj::read::parse(
|
||||
include_object!("data/ppc/m_Do_hostIO.o"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
let line_infos = obj
|
||||
.sections
|
||||
.iter()
|
||||
@@ -38,7 +45,12 @@ fn read_dwarf1_line_info() {
|
||||
#[cfg(feature = "ppc")]
|
||||
fn read_extab() {
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let obj = obj::read::parse(include_object!("data/ppc/NMWException.o"), &diff_config).unwrap();
|
||||
let obj = obj::read::parse(
|
||||
include_object!("data/ppc/NMWException.o"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(obj);
|
||||
}
|
||||
|
||||
@@ -47,12 +59,18 @@ fn read_extab() {
|
||||
fn diff_ppc() {
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let mapping_config = diff::MappingConfig::default();
|
||||
let target_obj =
|
||||
obj::read::parse(include_object!("data/ppc/CDamageVulnerability_target.o"), &diff_config)
|
||||
.unwrap();
|
||||
let base_obj =
|
||||
obj::read::parse(include_object!("data/ppc/CDamageVulnerability_base.o"), &diff_config)
|
||||
.unwrap();
|
||||
let target_obj = obj::read::parse(
|
||||
include_object!("data/ppc/CDamageVulnerability_target.o"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Target,
|
||||
)
|
||||
.unwrap();
|
||||
let base_obj = obj::read::parse(
|
||||
include_object!("data/ppc/CDamageVulnerability_base.o"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
let diff =
|
||||
diff::diff_objs(Some(&target_obj), Some(&base_obj), None, &diff_config, &mapping_config)
|
||||
.unwrap();
|
||||
@@ -90,7 +108,12 @@ fn diff_ppc() {
|
||||
#[cfg(feature = "ppc")]
|
||||
fn read_vmx128_coff() {
|
||||
let diff_config = diff::DiffObjConfig { combine_data_sections: true, ..Default::default() };
|
||||
let obj = obj::read::parse(include_object!("data/ppc/vmx128.obj"), &diff_config).unwrap();
|
||||
let obj = obj::read::parse(
|
||||
include_object!("data/ppc/vmx128.obj"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(obj);
|
||||
let symbol_idx =
|
||||
obj.symbols.iter().position(|s| s.name == "?FloatingPointExample@@YAXXZ").unwrap();
|
||||
|
||||
@@ -6,7 +6,12 @@ mod common;
|
||||
#[cfg(feature = "x86")]
|
||||
fn read_x86() {
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let obj = obj::read::parse(include_object!("data/x86/staticdebug.obj"), &diff_config).unwrap();
|
||||
let obj = obj::read::parse(
|
||||
include_object!("data/x86/staticdebug.obj"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(obj);
|
||||
let symbol_idx = obj.symbols.iter().position(|s| s.name == "?PrintThing@@YAXXZ").unwrap();
|
||||
let diff = diff::code::no_diff_code(&obj, symbol_idx, &diff_config).unwrap();
|
||||
@@ -23,7 +28,9 @@ fn read_x86_combine_sections() {
|
||||
combine_text_sections: true,
|
||||
..Default::default()
|
||||
};
|
||||
let obj = obj::read::parse(include_object!("data/x86/rtest.obj"), &diff_config).unwrap();
|
||||
let obj =
|
||||
obj::read::parse(include_object!("data/x86/rtest.obj"), &diff_config, diff::DiffSide::Base)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(obj.sections);
|
||||
}
|
||||
|
||||
@@ -31,7 +38,12 @@ fn read_x86_combine_sections() {
|
||||
#[cfg(feature = "x86")]
|
||||
fn read_x86_64() {
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let obj = obj::read::parse(include_object!("data/x86_64/vs2022.o"), &diff_config).unwrap();
|
||||
let obj = obj::read::parse(
|
||||
include_object!("data/x86_64/vs2022.o"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(obj);
|
||||
let symbol_idx =
|
||||
obj.symbols.iter().position(|s| s.name == "?Dot@Vector@@QEAAMPEAU1@@Z").unwrap();
|
||||
@@ -45,7 +57,12 @@ fn read_x86_64() {
|
||||
#[cfg(feature = "x86")]
|
||||
fn display_section_ordering() {
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let obj = obj::read::parse(include_object!("data/x86/basenode.obj"), &diff_config).unwrap();
|
||||
let obj = obj::read::parse(
|
||||
include_object!("data/x86/basenode.obj"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
let obj_diff =
|
||||
diff::diff_objs(Some(&obj), None, None, &diff_config, &diff::MappingConfig::default())
|
||||
.unwrap()
|
||||
@@ -60,7 +77,12 @@ fn display_section_ordering() {
|
||||
#[cfg(feature = "x86")]
|
||||
fn read_x86_jumptable() {
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let obj = obj::read::parse(include_object!("data/x86/jumptable.o"), &diff_config).unwrap();
|
||||
let obj = obj::read::parse(
|
||||
include_object!("data/x86/jumptable.o"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(obj);
|
||||
let symbol_idx = obj.symbols.iter().position(|s| s.name == "?test@@YAHH@Z").unwrap();
|
||||
let diff = diff::code::no_diff_code(&obj, symbol_idx, &diff_config).unwrap();
|
||||
@@ -74,6 +96,11 @@ fn read_x86_jumptable() {
|
||||
#[cfg(feature = "x86")]
|
||||
fn read_x86_local_labels() {
|
||||
let diff_config = diff::DiffObjConfig::default();
|
||||
let obj = obj::read::parse(include_object!("data/x86/local_labels.obj"), &diff_config).unwrap();
|
||||
let obj = obj::read::parse(
|
||||
include_object!("data/x86/local_labels.obj"),
|
||||
&diff_config,
|
||||
diff::DiffSide::Base,
|
||||
)
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(obj);
|
||||
}
|
||||
|
||||
@@ -1507,6 +1507,19 @@ Object {
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.data-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 76,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
2,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
],
|
||||
sections: [
|
||||
Section {
|
||||
|
||||
@@ -449,4 +449,17 @@ expression: obj.symbols
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.data-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 0,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
2,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -10,10 +10,10 @@ expression: output
|
||||
[(Address(20), Normal, 5), (Spacing(4), Normal, 0), (Opcode("jal", 2), Normal, 10), (Symbol(Symbol { name: "xglSleep", demangled_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: None }), Bright, 0), (Eol, Normal, 0)]
|
||||
[(Address(24), Normal, 5), (Spacing(4), Normal, 0), (Opcode("nop", 113), Normal, 10), (Eol, Normal, 0)]
|
||||
[(Address(28), Normal, 5), (Spacing(4), Normal, 0), (Opcode("lw", 26), Normal, 10), (Argument(Opaque("$a1")), Normal, 0), (Basic(", "), Normal, 0), (Basic("%gp_rel("), Normal, 0), (Symbol(Symbol { name: "WorkEnd", demangled_name: None, address: 64, size: 4, kind: Object, section: Some(8), flags: FlagSet(Global), align: None, virtual_address: None }), Bright, 0), (Basic(")"), Normal, 0), (Basic("("), Normal, 0), (Argument(Opaque("$gp")), Normal, 0), (Basic(")"), Normal, 0), (Eol, Normal, 0)]
|
||||
[(Address(32), Normal, 5), (Spacing(4), Normal, 0), (Opcode("lui", 20), Normal, 10), (Argument(Opaque("$a0")), Normal, 0), (Basic(", "), Normal, 0), (Basic("%hi("), Normal, 0), (Symbol(Symbol { name: "[.sdata]", demangled_name: None, address: 0, size: 64, kind: Section, section: Some(8), flags: FlagSet(Local), align: None, virtual_address: None }), Bright, 0), (Basic(")"), Normal, 0), (Eol, Normal, 0)]
|
||||
[(Address(32), Normal, 5), (Spacing(4), Normal, 0), (Opcode("lui", 20), Normal, 10), (Argument(Opaque("$a0")), Normal, 0), (Basic(", "), Normal, 0), (Basic("%hi("), Normal, 0), (Symbol(Symbol { name: "[.sdata]", demangled_name: None, address: 0, size: 0, kind: Section, section: Some(8), flags: FlagSet(Local), align: None, virtual_address: None }), Bright, 0), (Basic(")"), Normal, 0), (Eol, Normal, 0)]
|
||||
[(Address(36), Normal, 5), (Spacing(4), Normal, 0), (Opcode("daddu", 97), Normal, 10), (Argument(Opaque("$a2")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("$zero")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("$zero")), Normal, 0), (Eol, Normal, 0)]
|
||||
[(Address(40), Normal, 5), (Spacing(4), Normal, 0), (Opcode("jal", 2), Normal, 10), (Symbol(Symbol { name: "xglSoundLoadEffect", demangled_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: None }), Bright, 0), (Eol, Normal, 0)]
|
||||
[(Address(44), Normal, 5), (Spacing(4), Normal, 0), (Opcode("addiu", 12), Normal, 10), (Argument(Opaque("$a0")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("$a0")), Normal, 0), (Basic(", "), Normal, 0), (Basic("%lo("), Normal, 0), (Symbol(Symbol { name: "[.sdata]", demangled_name: None, address: 0, size: 64, kind: Section, section: Some(8), flags: FlagSet(Local), align: None, virtual_address: None }), Bright, 0), (Basic(")"), Normal, 0), (Eol, Normal, 0)]
|
||||
[(Address(44), Normal, 5), (Spacing(4), Normal, 0), (Opcode("addiu", 12), Normal, 10), (Argument(Opaque("$a0")), Normal, 0), (Basic(", "), Normal, 0), (Argument(Opaque("$a0")), Normal, 0), (Basic(", "), Normal, 0), (Basic("%lo("), Normal, 0), (Symbol(Symbol { name: "[.sdata]", demangled_name: None, address: 0, size: 0, kind: Section, section: Some(8), flags: FlagSet(Local), align: None, virtual_address: None }), Bright, 0), (Basic(")"), Normal, 0), (Eol, Normal, 0)]
|
||||
[(Address(48), Normal, 5), (Spacing(4), Normal, 0), (Opcode("lui", 20), Normal, 10), (Argument(Opaque("$a0")), Normal, 0), (Basic(", "), Normal, 0), (Basic("%hi("), Normal, 0), (Symbol(Symbol { name: "PacketBottomNewVu1DropMicroCode", demangled_name: None, address: 0, size: 12, kind: Object, section: Some(7), flags: FlagSet(Global), align: None, virtual_address: None }), Bright, 0), (Basic(")"), Normal, 0), (Eol, Normal, 0)]
|
||||
[(Address(52), Normal, 5), (Spacing(4), Normal, 0), (Opcode("lw", 26), Normal, 10), (Argument(Opaque("$a1")), Normal, 0), (Basic(", "), Normal, 0), (Basic("%gp_rel("), Normal, 0), (Symbol(Symbol { name: "WorkEnd", demangled_name: None, address: 64, size: 4, kind: Object, section: Some(8), flags: FlagSet(Global), align: None, virtual_address: None }), Bright, 0), (Basic(")"), Normal, 0), (Basic("("), Normal, 0), (Argument(Opaque("$gp")), Normal, 0), (Basic(")"), Normal, 0), (Eol, Normal, 0)]
|
||||
[(Address(56), Normal, 5), (Spacing(4), Normal, 0), (Opcode("jal", 2), Normal, 10), (Symbol(Symbol { name: "xglSoundLoadSwd", demangled_name: None, address: 0, size: 0, kind: Unknown, section: None, flags: FlagSet(Global), align: None, virtual_address: None }), Bright, 0), (Eol, Normal, 0)]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
source: objdiff-core/tests/arch_mips.rs
|
||||
assertion_line: 10
|
||||
expression: obj
|
||||
---
|
||||
Object {
|
||||
@@ -51,6 +52,7 @@ Object {
|
||||
{},
|
||||
],
|
||||
ignored_symbols: {},
|
||||
diff_side: Base,
|
||||
},
|
||||
endianness: Little,
|
||||
symbols: [
|
||||
@@ -110,7 +112,7 @@ Object {
|
||||
name: "[.sdata]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 64,
|
||||
size: 0,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
8,
|
||||
@@ -671,6 +673,45 @@ Object {
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.data-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 0,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
2,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.rodata-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 12,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
7,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.sdata-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 76,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
8,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
],
|
||||
sections: [
|
||||
Section {
|
||||
|
||||
@@ -2645,6 +2645,8 @@ expression: "(target_symbol_diff, base_symbol_diff)"
|
||||
arg_diff: [],
|
||||
},
|
||||
],
|
||||
data_diff: [],
|
||||
data_reloc_diff: [],
|
||||
},
|
||||
SymbolDiff {
|
||||
target_symbol: Some(
|
||||
@@ -5288,5 +5290,7 @@ expression: "(target_symbol_diff, base_symbol_diff)"
|
||||
arg_diff: [],
|
||||
},
|
||||
],
|
||||
data_diff: [],
|
||||
data_reloc_diff: [],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
---
|
||||
source: objdiff-core/tests/arch_ppc.rs
|
||||
assertion_line: 70
|
||||
expression: sections_display
|
||||
---
|
||||
[
|
||||
@@ -37,7 +36,7 @@ expression: sections_display
|
||||
),
|
||||
symbols: [
|
||||
SectionDisplaySymbol {
|
||||
symbol: 2,
|
||||
symbol: 16,
|
||||
is_mapping_symbol: false,
|
||||
},
|
||||
],
|
||||
|
||||
@@ -308,6 +308,32 @@ Object {
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[extab-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 40,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
1,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[extabindex-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 36,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
2,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
],
|
||||
sections: [
|
||||
Section {
|
||||
|
||||
@@ -43,7 +43,7 @@ Object {
|
||||
name: "[.ctors]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 4,
|
||||
size: 0,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
1,
|
||||
@@ -157,6 +157,19 @@ Object {
|
||||
0,
|
||||
),
|
||||
},
|
||||
Symbol {
|
||||
name: "[.ctors-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 4,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
1,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
],
|
||||
sections: [
|
||||
Section {
|
||||
|
||||
@@ -1101,6 +1101,45 @@ Object {
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.XBLD$W-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 16,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
2,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.rdata-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 416,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
4,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.pdata-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 40,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
6,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
],
|
||||
sections: [
|
||||
Section {
|
||||
|
||||
@@ -124,6 +124,19 @@ Object {
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.data-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 10,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
1,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
],
|
||||
sections: [
|
||||
Section {
|
||||
|
||||
@@ -854,6 +854,201 @@ Object {
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.xdata-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 8,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
7,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.pdata-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 12,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
8,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.xdata-1]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 8,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
9,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.pdata-1]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 12,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
10,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.xdata-2]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 8,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
11,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.pdata-2]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 12,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
12,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.xdata-3]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 8,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
13,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.pdata-3]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 12,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
14,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.rdata-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 256,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
15,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.xdata-4]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 20,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
16,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.pdata-4]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 12,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
17,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.rtc$IMZ-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 8,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
19,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.rtc$TMZ-0]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 8,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
20,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.rdata-1]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 4,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
21,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
Symbol {
|
||||
name: "[.rdata-2]",
|
||||
demangled_name: None,
|
||||
address: 0,
|
||||
size: 4,
|
||||
kind: Section,
|
||||
section: Some(
|
||||
22,
|
||||
),
|
||||
flags: FlagSet(Local),
|
||||
align: None,
|
||||
virtual_address: None,
|
||||
},
|
||||
],
|
||||
sections: [
|
||||
Section {
|
||||
|
||||
@@ -25,6 +25,7 @@ wsl = []
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
argp = "0.4"
|
||||
cfg-if = "1.0"
|
||||
const_format = "0.2"
|
||||
cwdemangle = "1.0"
|
||||
|
||||
@@ -16,8 +16,8 @@ use globset::Glob;
|
||||
use objdiff_core::{
|
||||
build::watcher::{Watcher, create_watcher},
|
||||
config::{
|
||||
DEFAULT_WATCH_PATTERNS, ProjectConfig, ProjectConfigInfo, ProjectObject, ScratchConfig,
|
||||
build_globset, default_watch_patterns, path::platform_path_serde_option,
|
||||
ProjectConfig, ProjectConfigInfo, ProjectObject, ScratchConfig, build_globset,
|
||||
default_ignore_patterns, default_watch_patterns, path::platform_path_serde_option,
|
||||
save_project_config,
|
||||
},
|
||||
diff::DiffObjConfig,
|
||||
@@ -219,6 +219,8 @@ pub struct AppConfig {
|
||||
#[serde(default = "default_watch_patterns")]
|
||||
pub watch_patterns: Vec<Glob>,
|
||||
#[serde(default)]
|
||||
pub ignore_patterns: Vec<Glob>,
|
||||
#[serde(default)]
|
||||
pub recent_projects: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub diff_obj_config: DiffObjConfig,
|
||||
@@ -239,7 +241,8 @@ impl Default for AppConfig {
|
||||
build_target: false,
|
||||
rebuild_on_changes: true,
|
||||
auto_update_check: true,
|
||||
watch_patterns: DEFAULT_WATCH_PATTERNS.iter().map(|s| Glob::new(s).unwrap()).collect(),
|
||||
watch_patterns: default_watch_patterns(),
|
||||
ignore_patterns: default_ignore_patterns(),
|
||||
recent_projects: vec![],
|
||||
diff_obj_config: Default::default(),
|
||||
}
|
||||
@@ -431,6 +434,7 @@ impl App {
|
||||
app_path: Option<PathBuf>,
|
||||
graphics_config: GraphicsConfig,
|
||||
graphics_config_path: Option<PathBuf>,
|
||||
project_dir: Option<Utf8PlatformPathBuf>,
|
||||
) -> Self {
|
||||
// Load previous app state (if any).
|
||||
// Note that you must enable the `persistence` feature for this to work.
|
||||
@@ -440,18 +444,26 @@ impl App {
|
||||
app.appearance = appearance;
|
||||
}
|
||||
if let Some(config) = deserialize_config(storage) {
|
||||
let mut state = AppState { config, ..Default::default() };
|
||||
if state.config.project_dir.is_some() {
|
||||
state.config_change = true;
|
||||
state.watcher_change = true;
|
||||
}
|
||||
if state.config.selected_obj.is_some() {
|
||||
state.queue_build = true;
|
||||
}
|
||||
app.view_state.config_state.queue_check_update = state.config.auto_update_check;
|
||||
let state = AppState { config, ..Default::default() };
|
||||
app.state = Arc::new(RwLock::new(state));
|
||||
}
|
||||
}
|
||||
{
|
||||
let mut state = app.state.write().unwrap();
|
||||
if let Some(project_dir) = project_dir
|
||||
&& state.config.project_dir.as_ref().is_none_or(|p| *p != project_dir)
|
||||
{
|
||||
state.set_project_dir(project_dir);
|
||||
}
|
||||
if state.config.project_dir.is_some() {
|
||||
state.config_change = true;
|
||||
state.watcher_change = true;
|
||||
}
|
||||
if state.config.selected_obj.is_some() {
|
||||
state.queue_build = true;
|
||||
}
|
||||
app.view_state.config_state.queue_check_update = state.config.auto_update_check;
|
||||
}
|
||||
app.appearance.init_fonts(&cc.egui_ctx);
|
||||
app.appearance.utc_offset = utc_offset;
|
||||
app.app_path = app_path;
|
||||
@@ -551,11 +563,17 @@ impl App {
|
||||
if let Some(project_dir) = &state.config.project_dir {
|
||||
match build_globset(&state.config.watch_patterns)
|
||||
.map_err(anyhow::Error::new)
|
||||
.and_then(|globset| {
|
||||
.and_then(|patterns| {
|
||||
build_globset(&state.config.ignore_patterns)
|
||||
.map(|ignore_patterns| (patterns, ignore_patterns))
|
||||
.map_err(anyhow::Error::new)
|
||||
})
|
||||
.and_then(|(patterns, ignore_patterns)| {
|
||||
create_watcher(
|
||||
self.modified.clone(),
|
||||
project_dir.as_ref(),
|
||||
globset,
|
||||
patterns,
|
||||
ignore_patterns,
|
||||
egui_waker(ctx),
|
||||
)
|
||||
.map_err(anyhow::Error::new)
|
||||
|
||||
63
objdiff-gui/src/argp_version.rs
Normal file
63
objdiff-gui/src/argp_version.rs
Normal file
@@ -0,0 +1,63 @@
|
||||
// Originally from https://gist.github.com/suluke/e0c672492126be0a4f3b4f0e1115d77c
|
||||
//! Extend `argp` to be better integrated with the `cargo` ecosystem
|
||||
//!
|
||||
//! For now, this only adds a --version/-V option which causes early-exit.
|
||||
use std::ffi::OsStr;
|
||||
|
||||
use argp::{EarlyExit, FromArgs, TopLevelCommand, parser::ParseGlobalOptions};
|
||||
|
||||
struct ArgsOrVersion<T>(T)
|
||||
where T: FromArgs;
|
||||
|
||||
impl<T> TopLevelCommand for ArgsOrVersion<T> where T: FromArgs {}
|
||||
|
||||
impl<T> FromArgs for ArgsOrVersion<T>
|
||||
where T: FromArgs
|
||||
{
|
||||
fn _from_args(
|
||||
command_name: &[&str],
|
||||
args: &[&OsStr],
|
||||
parent: Option<&mut dyn ParseGlobalOptions>,
|
||||
) -> Result<Self, EarlyExit> {
|
||||
/// Also use argp for catching `--version`-only invocations
|
||||
#[derive(FromArgs)]
|
||||
struct Version {
|
||||
/// Print version information and exit.
|
||||
#[argp(switch, short = 'V')]
|
||||
pub version: bool,
|
||||
}
|
||||
|
||||
match Version::from_args(command_name, args) {
|
||||
Ok(v) => {
|
||||
if v.version {
|
||||
println!(
|
||||
"{} {}",
|
||||
command_name.first().unwrap_or(&""),
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
);
|
||||
std::process::exit(0);
|
||||
} else {
|
||||
// Pass through empty arguments
|
||||
T::_from_args(command_name, args, parent).map(Self)
|
||||
}
|
||||
}
|
||||
Err(exit) => match exit {
|
||||
EarlyExit::Help(_help) => {
|
||||
// TODO: Chain help info from Version
|
||||
// For now, we just put the switch on T as well
|
||||
T::from_args(command_name, &["--help"]).map(Self)
|
||||
}
|
||||
EarlyExit::Err(_) => T::_from_args(command_name, args, parent).map(Self),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a `FromArgs` type from the current process’s `env::args`.
|
||||
///
|
||||
/// This function will exit early from the current process if argument parsing was unsuccessful or if information like `--help` was requested.
|
||||
/// Error messages will be printed to stderr, and `--help` output to stdout.
|
||||
pub fn from_env<T>() -> T
|
||||
where T: TopLevelCommand {
|
||||
argp::parse_args_or_exit::<ArgsOrVersion<T>>(argp::DEFAULT).0
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
use anyhow::Result;
|
||||
use globset::Glob;
|
||||
use objdiff_core::config::{DEFAULT_WATCH_PATTERNS, try_project_config};
|
||||
use objdiff_core::config::{default_ignore_patterns, default_watch_patterns, try_project_config};
|
||||
use typed_path::{Utf8UnixComponent, Utf8UnixPath};
|
||||
|
||||
use crate::app::{AppState, ObjectConfig};
|
||||
@@ -96,8 +96,15 @@ pub fn load_project_config(state: &mut AppState) -> Result<()> {
|
||||
.map(|s| Glob::new(s))
|
||||
.collect::<Result<Vec<Glob>, globset::Error>>()?;
|
||||
} else {
|
||||
state.config.watch_patterns =
|
||||
DEFAULT_WATCH_PATTERNS.iter().map(|s| Glob::new(s).unwrap()).collect();
|
||||
state.config.watch_patterns = default_watch_patterns();
|
||||
}
|
||||
if let Some(ignore_patterns) = &project_config.ignore_patterns {
|
||||
state.config.ignore_patterns = ignore_patterns
|
||||
.iter()
|
||||
.map(|s| Glob::new(s))
|
||||
.collect::<Result<Vec<Glob>, globset::Error>>()?;
|
||||
} else {
|
||||
state.config.ignore_patterns = default_ignore_patterns();
|
||||
}
|
||||
state.watcher_change = true;
|
||||
state.objects = project_config
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
mod app;
|
||||
mod app_config;
|
||||
mod argp_version;
|
||||
mod config;
|
||||
mod fonts;
|
||||
mod hotkeys;
|
||||
@@ -11,19 +12,83 @@ mod update;
|
||||
mod views;
|
||||
|
||||
use std::{
|
||||
ffi::OsStr,
|
||||
fmt::Display,
|
||||
path::PathBuf,
|
||||
process::ExitCode,
|
||||
rc::Rc,
|
||||
str::FromStr,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use anyhow::{Result, ensure};
|
||||
use argp::{FromArgValue, FromArgs};
|
||||
use cfg_if::cfg_if;
|
||||
use objdiff_core::config::path::check_path_buf;
|
||||
use time::UtcOffset;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use tracing_subscriber::{EnvFilter, filter::LevelFilter};
|
||||
use typed_path::Utf8PlatformPathBuf;
|
||||
|
||||
use crate::views::graphics::{GraphicsBackend, GraphicsConfig, load_graphics_config};
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
||||
enum LogLevel {
|
||||
Error,
|
||||
Warn,
|
||||
Info,
|
||||
Debug,
|
||||
Trace,
|
||||
}
|
||||
|
||||
impl FromStr for LogLevel {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
Ok(match s {
|
||||
"error" => Self::Error,
|
||||
"warn" => Self::Warn,
|
||||
"info" => Self::Info,
|
||||
"debug" => Self::Debug,
|
||||
"trace" => Self::Trace,
|
||||
_ => return Err(()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for LogLevel {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(match self {
|
||||
LogLevel::Error => "error",
|
||||
LogLevel::Warn => "warn",
|
||||
LogLevel::Info => "info",
|
||||
LogLevel::Debug => "debug",
|
||||
LogLevel::Trace => "trace",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl FromArgValue for LogLevel {
|
||||
fn from_arg_value(value: &OsStr) -> Result<Self, String> {
|
||||
String::from_arg_value(value)
|
||||
.and_then(|s| Self::from_str(&s).map_err(|_| "Invalid log level".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(FromArgs, PartialEq, Debug)]
|
||||
/// A local diffing tool for decompilation projects.
|
||||
struct TopLevel {
|
||||
#[argp(option, short = 'L')]
|
||||
/// Minimum logging level. (Default: info)
|
||||
/// Possible values: error, warn, info, debug, trace
|
||||
log_level: Option<LogLevel>,
|
||||
#[argp(option, short = 'p')]
|
||||
/// Path to the project directory.
|
||||
project_dir: Option<PathBuf>,
|
||||
/// Print version information and exit.
|
||||
#[argp(switch, short = 'V')]
|
||||
version: bool,
|
||||
}
|
||||
|
||||
fn load_icon() -> Result<egui::IconData> {
|
||||
let decoder = png::Decoder::new(include_bytes!("../assets/icon_64.png").as_ref());
|
||||
let mut reader = decoder.read_info()?;
|
||||
@@ -38,23 +103,63 @@ fn load_icon() -> Result<egui::IconData> {
|
||||
const APP_NAME: &str = "objdiff";
|
||||
|
||||
fn main() -> ExitCode {
|
||||
// Log to stdout (if you run with `RUST_LOG=debug`).
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
EnvFilter::builder()
|
||||
// Default to info level
|
||||
.with_default_directive(tracing_subscriber::filter::LevelFilter::INFO.into())
|
||||
.from_env_lossy()
|
||||
// This module is noisy at info level
|
||||
.add_directive("wgpu_core::device::resource=warn".parse().unwrap()),
|
||||
)
|
||||
.init();
|
||||
let args: TopLevel = argp_version::from_env();
|
||||
let builder = tracing_subscriber::fmt();
|
||||
if let Some(level) = args.log_level {
|
||||
builder
|
||||
.with_max_level(match level {
|
||||
LogLevel::Error => LevelFilter::ERROR,
|
||||
LogLevel::Warn => LevelFilter::WARN,
|
||||
LogLevel::Info => LevelFilter::INFO,
|
||||
LogLevel::Debug => LevelFilter::DEBUG,
|
||||
LogLevel::Trace => LevelFilter::TRACE,
|
||||
})
|
||||
.init();
|
||||
} else {
|
||||
builder
|
||||
.with_env_filter(
|
||||
EnvFilter::builder()
|
||||
// Default to info level
|
||||
.with_default_directive(LevelFilter::INFO.into())
|
||||
.from_env_lossy()
|
||||
// This module is noisy at info level
|
||||
.add_directive("wgpu_core::device::resource=warn".parse().unwrap()),
|
||||
)
|
||||
.init();
|
||||
}
|
||||
|
||||
// Because localtime_r is unsound in multithreaded apps,
|
||||
// we must call this before initializing eframe.
|
||||
// https://github.com/time-rs/time/issues/293
|
||||
let utc_offset = UtcOffset::current_local_offset().unwrap_or(UtcOffset::UTC);
|
||||
|
||||
// Resolve project directory if provided
|
||||
let project_dir = if let Some(path) = args.project_dir {
|
||||
match path.canonicalize() {
|
||||
Ok(path) => {
|
||||
// Ensure the path is a directory
|
||||
if path.is_dir() {
|
||||
match check_path_buf(path) {
|
||||
Ok(path) => Some(path),
|
||||
Err(e) => {
|
||||
log::error!("Failed to convert project directory to UTF-8 path: {}", e);
|
||||
None
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log::error!("Project directory is not a directory: {}", path.display());
|
||||
None
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to canonicalize project directory: {}", e);
|
||||
None
|
||||
}
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let app_path = std::env::current_exe().ok();
|
||||
let exec_path: Rc<Mutex<Option<PathBuf>>> = Rc::new(Mutex::new(None));
|
||||
let mut native_options = eframe::NativeOptions {
|
||||
@@ -113,6 +218,7 @@ fn main() -> ExitCode {
|
||||
app_path.clone(),
|
||||
graphics_config.clone(),
|
||||
graphics_config_path.clone(),
|
||||
project_dir.clone(),
|
||||
) {
|
||||
eframe_error = Some(e);
|
||||
}
|
||||
@@ -139,6 +245,7 @@ fn main() -> ExitCode {
|
||||
app_path.clone(),
|
||||
graphics_config.clone(),
|
||||
graphics_config_path.clone(),
|
||||
project_dir.clone(),
|
||||
) {
|
||||
eframe_error = Some(e);
|
||||
} else {
|
||||
@@ -161,6 +268,7 @@ fn main() -> ExitCode {
|
||||
app_path,
|
||||
graphics_config,
|
||||
graphics_config_path,
|
||||
project_dir,
|
||||
) {
|
||||
eframe_error = Some(e);
|
||||
} else {
|
||||
@@ -204,6 +312,7 @@ fn run_eframe(
|
||||
app_path: Option<PathBuf>,
|
||||
graphics_config: GraphicsConfig,
|
||||
graphics_config_path: Option<PathBuf>,
|
||||
project_dir: Option<Utf8PlatformPathBuf>,
|
||||
) -> Result<(), eframe::Error> {
|
||||
eframe::run_native(
|
||||
APP_NAME,
|
||||
@@ -216,6 +325,7 @@ fn run_eframe(
|
||||
app_path,
|
||||
graphics_config,
|
||||
graphics_config_path,
|
||||
project_dir,
|
||||
)))
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -11,6 +11,7 @@ pub struct Appearance {
|
||||
pub ui_font: FontId,
|
||||
pub code_font: FontId,
|
||||
pub diff_colors: Vec<Color32>,
|
||||
pub diff_bg_color: Option<Color32>,
|
||||
pub theme: egui::Theme,
|
||||
|
||||
// Applied by theme
|
||||
@@ -67,6 +68,7 @@ impl Default for Appearance {
|
||||
replace_color: Color32::LIGHT_BLUE,
|
||||
insert_color: Color32::GREEN,
|
||||
delete_color: Color32::from_rgb(200, 40, 41),
|
||||
diff_bg_color: None,
|
||||
utc_offset: UtcOffset::UTC,
|
||||
fonts: FontState::default(),
|
||||
next_ui_font: None,
|
||||
@@ -103,6 +105,9 @@ impl Appearance {
|
||||
match self.theme {
|
||||
egui::Theme::Dark => {
|
||||
style.visuals = egui::Visuals::dark();
|
||||
if let Some(diff_bg_color) = self.diff_bg_color {
|
||||
style.visuals.faint_bg_color = diff_bg_color;
|
||||
}
|
||||
self.text_color = Color32::GRAY;
|
||||
self.emphasized_text_color = Color32::LIGHT_GRAY;
|
||||
self.deemphasized_text_color = Color32::DARK_GRAY;
|
||||
@@ -114,6 +119,9 @@ impl Appearance {
|
||||
}
|
||||
egui::Theme::Light => {
|
||||
style.visuals = egui::Visuals::light();
|
||||
if let Some(diff_bg_color) = self.diff_bg_color {
|
||||
style.visuals.faint_bg_color = diff_bg_color;
|
||||
}
|
||||
self.text_color = Color32::GRAY;
|
||||
self.emphasized_text_color = Color32::DARK_GRAY;
|
||||
self.deemphasized_text_color = Color32::LIGHT_GRAY;
|
||||
@@ -294,6 +302,21 @@ pub fn appearance_window(ctx: &egui::Context, show: &mut bool, appearance: &mut
|
||||
appearance,
|
||||
);
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Diff fill color:");
|
||||
let mut diff_bg_color =
|
||||
appearance.diff_bg_color.unwrap_or_else(|| match appearance.theme {
|
||||
egui::Theme::Dark => egui::Visuals::dark().faint_bg_color,
|
||||
egui::Theme::Light => egui::Visuals::light().faint_bg_color,
|
||||
});
|
||||
if ui.color_edit_button_srgba(&mut diff_bg_color).changed() {
|
||||
appearance.diff_bg_color = Some(diff_bg_color);
|
||||
}
|
||||
if ui.button("Reset").clicked() {
|
||||
appearance.diff_bg_color = None;
|
||||
}
|
||||
});
|
||||
ui.separator();
|
||||
ui.label("Diff colors:");
|
||||
if ui.button("Reset").clicked() {
|
||||
appearance.diff_colors = DEFAULT_COLOR_ROTATION.to_vec();
|
||||
|
||||
@@ -10,7 +10,7 @@ use egui::{
|
||||
};
|
||||
use globset::Glob;
|
||||
use objdiff_core::{
|
||||
config::{DEFAULT_WATCH_PATTERNS, path::check_path_buf},
|
||||
config::{default_ignore_patterns, default_watch_patterns, path::check_path_buf},
|
||||
diff::{
|
||||
CONFIG_GROUPS, ConfigEnum, ConfigEnumVariantInfo, ConfigPropertyId, ConfigPropertyKind,
|
||||
ConfigPropertyValue,
|
||||
@@ -41,6 +41,7 @@ pub struct ConfigViewState {
|
||||
pub build_running: bool,
|
||||
pub queue_build: bool,
|
||||
pub watch_pattern_text: String,
|
||||
pub ignore_pattern_text: String,
|
||||
pub object_search: String,
|
||||
pub filter_diffable: bool,
|
||||
pub filter_incomplete: bool,
|
||||
@@ -790,20 +791,49 @@ fn split_obj_config_ui(
|
||||
state.watcher_change = true;
|
||||
};
|
||||
|
||||
state.watcher_change |= patterns_ui(
|
||||
ui,
|
||||
"File patterns",
|
||||
&mut state.config.watch_patterns,
|
||||
&mut config_state.watch_pattern_text,
|
||||
appearance,
|
||||
state.project_config_info.is_some(),
|
||||
default_watch_patterns,
|
||||
);
|
||||
state.watcher_change |= patterns_ui(
|
||||
ui,
|
||||
"Ignore patterns",
|
||||
&mut state.config.ignore_patterns,
|
||||
&mut config_state.ignore_pattern_text,
|
||||
appearance,
|
||||
state.project_config_info.is_some(),
|
||||
default_ignore_patterns,
|
||||
);
|
||||
}
|
||||
|
||||
fn patterns_ui(
|
||||
ui: &mut egui::Ui,
|
||||
text: &str,
|
||||
patterns: &mut Vec<Glob>,
|
||||
pattern_text: &mut String,
|
||||
appearance: &Appearance,
|
||||
has_project_config: bool,
|
||||
on_reset: impl FnOnce() -> Vec<Glob>,
|
||||
) -> bool {
|
||||
let mut change = false;
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(RichText::new("File patterns").color(appearance.text_color));
|
||||
ui.label(RichText::new(text).color(appearance.text_color));
|
||||
if ui
|
||||
.add_enabled(state.project_config_info.is_none(), egui::Button::new("Reset"))
|
||||
.add_enabled(!has_project_config, egui::Button::new("Reset"))
|
||||
.on_disabled_hover_text(CONFIG_DISABLED_TEXT)
|
||||
.clicked()
|
||||
{
|
||||
state.config.watch_patterns =
|
||||
DEFAULT_WATCH_PATTERNS.iter().map(|s| Glob::new(s).unwrap()).collect();
|
||||
state.watcher_change = true;
|
||||
*patterns = on_reset();
|
||||
change = true;
|
||||
}
|
||||
});
|
||||
let mut remove_at: Option<usize> = None;
|
||||
for (idx, glob) in state.config.watch_patterns.iter().enumerate() {
|
||||
for (idx, glob) in patterns.iter().enumerate() {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(
|
||||
RichText::new(glob.to_string())
|
||||
@@ -811,7 +841,7 @@ fn split_obj_config_ui(
|
||||
.family(FontFamily::Monospace),
|
||||
);
|
||||
if ui
|
||||
.add_enabled(state.project_config_info.is_none(), egui::Button::new("-").small())
|
||||
.add_enabled(!has_project_config, egui::Button::new("-").small())
|
||||
.on_disabled_hover_text(CONFIG_DISABLED_TEXT)
|
||||
.clicked()
|
||||
{
|
||||
@@ -820,26 +850,27 @@ fn split_obj_config_ui(
|
||||
});
|
||||
}
|
||||
if let Some(idx) = remove_at {
|
||||
state.config.watch_patterns.remove(idx);
|
||||
state.watcher_change = true;
|
||||
patterns.remove(idx);
|
||||
change = true;
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_enabled(
|
||||
state.project_config_info.is_none(),
|
||||
egui::TextEdit::singleline(&mut config_state.watch_pattern_text).desired_width(100.0),
|
||||
!has_project_config,
|
||||
egui::TextEdit::singleline(pattern_text).desired_width(100.0),
|
||||
)
|
||||
.on_disabled_hover_text(CONFIG_DISABLED_TEXT);
|
||||
if ui
|
||||
.add_enabled(state.project_config_info.is_none(), egui::Button::new("+").small())
|
||||
.add_enabled(!has_project_config, egui::Button::new("+").small())
|
||||
.on_disabled_hover_text(CONFIG_DISABLED_TEXT)
|
||||
.clicked()
|
||||
&& let Ok(glob) = Glob::new(&config_state.watch_pattern_text)
|
||||
&& let Ok(glob) = Glob::new(pattern_text)
|
||||
{
|
||||
state.config.watch_patterns.push(glob);
|
||||
state.watcher_change = true;
|
||||
config_state.watch_pattern_text.clear();
|
||||
patterns.push(glob);
|
||||
change = true;
|
||||
pattern_text.clear();
|
||||
}
|
||||
});
|
||||
change
|
||||
}
|
||||
|
||||
pub fn arch_config_window(
|
||||
|
||||
@@ -115,7 +115,8 @@ fn get_hover_item_color_for_diff_kind(diff_kind: DataDiffKind) -> HoverItemColor
|
||||
pub(crate) fn data_row_ui(
|
||||
ui: &mut egui::Ui,
|
||||
obj: Option<&Object>,
|
||||
address: usize,
|
||||
base_address: usize,
|
||||
row_address: usize,
|
||||
diffs: &[(DataDiff, Vec<DataRelocationDiff>)],
|
||||
appearance: &Appearance,
|
||||
column: usize,
|
||||
@@ -127,7 +128,7 @@ pub(crate) fn data_row_ui(
|
||||
}
|
||||
let mut job = LayoutJob::default();
|
||||
write_text(
|
||||
format!("{address:08x}: ").as_str(),
|
||||
format!("{row_address:08x}: ").as_str(),
|
||||
appearance.text_color,
|
||||
&mut job,
|
||||
appearance.code_font.clone(),
|
||||
@@ -135,7 +136,7 @@ pub(crate) fn data_row_ui(
|
||||
// The offset shown on the side of the GUI, shifted by insertions/deletions.
|
||||
let mut cur_addr = 0usize;
|
||||
// The offset into the actual bytes of the section on this side, ignoring differences.
|
||||
let mut cur_addr_actual = address;
|
||||
let mut cur_addr_actual = base_address + row_address;
|
||||
for (diff, reloc_diffs) in diffs {
|
||||
let base_color = get_color_for_diff_kind(diff.kind, appearance);
|
||||
if diff.data.is_empty() {
|
||||
@@ -211,13 +212,14 @@ pub(crate) fn data_row_ui(
|
||||
pub(crate) fn split_diffs(
|
||||
diffs: &[DataDiff],
|
||||
reloc_diffs: &[DataRelocationDiff],
|
||||
symbol_offset_in_section: usize,
|
||||
) -> Vec<Vec<(DataDiff, Vec<DataRelocationDiff>)>> {
|
||||
let mut split_diffs = Vec::<Vec<(DataDiff, Vec<DataRelocationDiff>)>>::new();
|
||||
let mut row_diffs = Vec::<(DataDiff, Vec<DataRelocationDiff>)>::new();
|
||||
// The offset shown on the side of the GUI, shifted by insertions/deletions.
|
||||
let mut cur_addr = 0usize;
|
||||
// The offset into the actual bytes of the section on this side, ignoring differences.
|
||||
let mut cur_addr_actual = 0usize;
|
||||
let mut cur_addr_actual = symbol_offset_in_section;
|
||||
for diff in diffs {
|
||||
let mut cur_len = 0usize;
|
||||
while cur_len < diff.len {
|
||||
|
||||
@@ -2,10 +2,10 @@ use egui::{Id, Layout, RichText, ScrollArea, TextEdit, Ui, Widget, text::LayoutJ
|
||||
use objdiff_core::{
|
||||
build::BuildStatus,
|
||||
diff::{
|
||||
DiffObjConfig, ObjectDiff, SectionDiff, SymbolDiff,
|
||||
DiffObjConfig, ObjectDiff, SymbolDiff,
|
||||
display::{ContextItem, HoverItem, HoverItemColor, SymbolFilter, SymbolNavigationKind},
|
||||
},
|
||||
obj::{Object, Section, Symbol},
|
||||
obj::{Object, Symbol},
|
||||
};
|
||||
use time::format_description;
|
||||
|
||||
@@ -25,17 +25,10 @@ use crate::{
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum SelectedSymbol {
|
||||
Symbol(usize),
|
||||
Section(usize),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct DiffColumnContext<'a> {
|
||||
status: &'a BuildStatus,
|
||||
obj: Option<&'a (Object, ObjectDiff)>,
|
||||
section: Option<(&'a Section, &'a SectionDiff, usize)>,
|
||||
symbol: Option<(&'a Symbol, &'a SymbolDiff, usize)>,
|
||||
}
|
||||
|
||||
@@ -46,49 +39,28 @@ impl<'a> DiffColumnContext<'a> {
|
||||
obj: Option<&'a (Object, ObjectDiff)>,
|
||||
selected_symbol: Option<&SymbolRefByName>,
|
||||
) -> Self {
|
||||
let selected_symbol = match view {
|
||||
let selected_symbol_idx = match view {
|
||||
View::SymbolDiff => None,
|
||||
View::FunctionDiff | View::ExtabDiff => match (obj, selected_symbol) {
|
||||
(Some(obj), Some(s)) => {
|
||||
obj.0.symbol_by_name(&s.symbol_name).map(SelectedSymbol::Symbol)
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
View::DataDiff => match (obj, selected_symbol) {
|
||||
(Some(obj), Some(SymbolRefByName { section_name: Some(section_name), .. })) => {
|
||||
find_section(&obj.0, section_name).map(SelectedSymbol::Section)
|
||||
}
|
||||
View::FunctionDiff | View::DataDiff | View::ExtabDiff => match (obj, selected_symbol) {
|
||||
(Some(obj), Some(s)) => obj.0.symbol_by_name(&s.symbol_name),
|
||||
_ => None,
|
||||
},
|
||||
};
|
||||
let (section, symbol) = match (obj, selected_symbol) {
|
||||
(Some((obj, obj_diff)), Some(SelectedSymbol::Symbol(symbol_ref))) => {
|
||||
let symbol = match (obj, selected_symbol_idx) {
|
||||
(Some((obj, obj_diff)), Some(symbol_ref)) => {
|
||||
let symbol = &obj.symbols[symbol_ref];
|
||||
(
|
||||
symbol.section.map(|section_idx| {
|
||||
(&obj.sections[section_idx], &obj_diff.sections[section_idx], section_idx)
|
||||
}),
|
||||
Some((symbol, &obj_diff.symbols[symbol_ref], symbol_ref)),
|
||||
)
|
||||
Some((symbol, &obj_diff.symbols[symbol_ref], symbol_ref))
|
||||
}
|
||||
(Some((obj, obj_diff)), Some(SelectedSymbol::Section(section_idx))) => (
|
||||
Some((&obj.sections[section_idx], &obj_diff.sections[section_idx], section_idx)),
|
||||
None,
|
||||
),
|
||||
_ => (None, None),
|
||||
_ => None,
|
||||
};
|
||||
Self { status, obj, section, symbol }
|
||||
Self { status, obj, symbol }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_symbol(&self) -> bool { self.section.is_some() || self.symbol.is_some() }
|
||||
pub fn has_symbol(&self) -> bool { self.symbol.is_some() }
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> Option<&str> {
|
||||
self.symbol
|
||||
.map(|(symbol, _, _)| symbol.name.as_str())
|
||||
.or_else(|| self.section.map(|(section, _, _)| section.name.as_str()))
|
||||
}
|
||||
pub fn id(&self) -> Option<&str> { self.symbol.map(|(symbol, _, _)| symbol.name.as_str()) }
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
@@ -133,10 +105,7 @@ pub fn diff_view_ui(
|
||||
{
|
||||
navigation.right_symbol = Some(target_symbol_ref);
|
||||
}
|
||||
} else if navigation.left_symbol.is_some()
|
||||
&& left_ctx.obj.is_some()
|
||||
&& left_ctx.section.is_none()
|
||||
{
|
||||
} else if navigation.left_symbol.is_some() && left_ctx.obj.is_some() {
|
||||
// Clear selection if symbol goes missing
|
||||
navigation.left_symbol = None;
|
||||
}
|
||||
@@ -147,10 +116,7 @@ pub fn diff_view_ui(
|
||||
{
|
||||
navigation.left_symbol = Some(target_symbol_ref);
|
||||
}
|
||||
} else if navigation.right_symbol.is_some()
|
||||
&& right_ctx.obj.is_some()
|
||||
&& right_ctx.section.is_none()
|
||||
{
|
||||
} else if navigation.right_symbol.is_some() && right_ctx.obj.is_some() {
|
||||
// Clear selection if symbol goes missing
|
||||
navigation.right_symbol = None;
|
||||
}
|
||||
@@ -225,12 +191,6 @@ pub fn diff_view_ui(
|
||||
{
|
||||
ret = Some(action);
|
||||
}
|
||||
} else if let Some((section, _, _)) = left_ctx.section {
|
||||
ui.label(
|
||||
RichText::new(section.name.clone())
|
||||
.font(appearance.code_font.clone())
|
||||
.color(appearance.highlight_color),
|
||||
);
|
||||
} else if right_ctx.has_symbol() {
|
||||
ui.label(
|
||||
RichText::new("Choose target symbol")
|
||||
@@ -363,12 +323,6 @@ pub fn diff_view_ui(
|
||||
{
|
||||
ret = Some(action);
|
||||
}
|
||||
} else if let Some((section, _, _)) = right_ctx.section {
|
||||
ui.label(
|
||||
RichText::new(section.name.clone())
|
||||
.font(appearance.code_font.clone())
|
||||
.color(appearance.highlight_color),
|
||||
);
|
||||
} else if left_ctx.has_symbol() {
|
||||
ui.label(
|
||||
RichText::new("Choose base symbol")
|
||||
@@ -509,17 +463,17 @@ pub fn diff_view_ui(
|
||||
View::DataDiff,
|
||||
Some((left_obj, _left_diff)),
|
||||
Some((right_obj, _right_diff)),
|
||||
Some((_left_section, left_section_diff, _left_symbol_idx)),
|
||||
Some((_right_section, right_section_diff, _right_symbol_idx)),
|
||||
Some((left_symbol, left_symbol_diff, _left_symbol_idx)),
|
||||
Some((right_symbol, right_symbol_diff, _right_symbol_idx)),
|
||||
) =
|
||||
(state.current_view, left_ctx.obj, right_ctx.obj, left_ctx.section, right_ctx.section)
|
||||
(state.current_view, left_ctx.obj, right_ctx.obj, left_ctx.symbol, right_ctx.symbol)
|
||||
{
|
||||
// Joint diff view
|
||||
hotkeys::check_scroll_hotkeys(ui, true);
|
||||
let left_total_bytes =
|
||||
left_section_diff.data_diff.iter().fold(0usize, |accum, item| accum + item.len);
|
||||
left_symbol_diff.data_diff.iter().fold(0usize, |accum, item| accum + item.len);
|
||||
let right_total_bytes =
|
||||
right_section_diff.data_diff.iter().fold(0usize, |accum, item| accum + item.len);
|
||||
right_symbol_diff.data_diff.iter().fold(0usize, |accum, item| accum + item.len);
|
||||
if left_total_bytes != right_total_bytes {
|
||||
ui.label("Data size mismatch");
|
||||
return;
|
||||
@@ -528,10 +482,16 @@ pub fn diff_view_ui(
|
||||
return;
|
||||
}
|
||||
let total_rows = (left_total_bytes - 1) / BYTES_PER_ROW + 1;
|
||||
let left_diffs =
|
||||
split_diffs(&left_section_diff.data_diff, &left_section_diff.reloc_diff);
|
||||
let right_diffs =
|
||||
split_diffs(&right_section_diff.data_diff, &right_section_diff.reloc_diff);
|
||||
let left_diffs = split_diffs(
|
||||
&left_symbol_diff.data_diff,
|
||||
&left_symbol_diff.data_reloc_diff,
|
||||
left_symbol.address as usize,
|
||||
);
|
||||
let right_diffs = split_diffs(
|
||||
&right_symbol_diff.data_diff,
|
||||
&right_symbol_diff.data_reloc_diff,
|
||||
right_symbol.address as usize,
|
||||
);
|
||||
render_table(
|
||||
ui,
|
||||
available_width,
|
||||
@@ -540,13 +500,14 @@ pub fn diff_view_ui(
|
||||
total_rows,
|
||||
|row, column| {
|
||||
let i = row.index();
|
||||
let address = i * BYTES_PER_ROW;
|
||||
let row_offset = i * BYTES_PER_ROW;
|
||||
row.col(|ui| {
|
||||
if column == 0 {
|
||||
data_row_ui(
|
||||
ui,
|
||||
Some(left_obj),
|
||||
address,
|
||||
left_symbol.address as usize,
|
||||
row_offset,
|
||||
&left_diffs[i],
|
||||
appearance,
|
||||
column,
|
||||
@@ -555,7 +516,8 @@ pub fn diff_view_ui(
|
||||
data_row_ui(
|
||||
ui,
|
||||
Some(right_obj),
|
||||
address,
|
||||
right_symbol.address as usize,
|
||||
row_offset,
|
||||
&right_diffs[i],
|
||||
appearance,
|
||||
column,
|
||||
@@ -649,11 +611,46 @@ fn diff_col_ui(
|
||||
if !ctx.status.success {
|
||||
build_log_ui(ui, ctx.status, appearance);
|
||||
} else if let Some((obj, diff)) = ctx.obj {
|
||||
if let Some((_symbol, symbol_diff, symbol_idx)) = ctx.symbol {
|
||||
if let Some((symbol, symbol_diff, symbol_idx)) = ctx.symbol {
|
||||
hotkeys::check_scroll_hotkeys(ui, false);
|
||||
let ctx = FunctionDiffContext { obj, diff, symbol_ref: Some(symbol_idx) };
|
||||
if state.current_view == View::ExtabDiff {
|
||||
extab_ui(ui, ctx, appearance, column);
|
||||
} else if state.current_view == View::DataDiff {
|
||||
hotkeys::check_scroll_hotkeys(ui, false);
|
||||
let total_bytes =
|
||||
symbol_diff.data_diff.iter().fold(0usize, |accum, item| accum + item.len);
|
||||
if total_bytes == 0 {
|
||||
return ret;
|
||||
}
|
||||
let total_rows = (total_bytes - 1) / BYTES_PER_ROW + 1;
|
||||
let diffs = split_diffs(
|
||||
&symbol_diff.data_diff,
|
||||
&symbol_diff.data_reloc_diff,
|
||||
symbol.address as usize,
|
||||
);
|
||||
render_table(
|
||||
ui,
|
||||
available_width / 2.0,
|
||||
1,
|
||||
appearance.code_font.size,
|
||||
total_rows,
|
||||
|row, _column| {
|
||||
let i = row.index();
|
||||
let row_offset = i * BYTES_PER_ROW;
|
||||
row.col(|ui| {
|
||||
data_row_ui(
|
||||
ui,
|
||||
Some(obj),
|
||||
symbol.address as usize,
|
||||
row_offset,
|
||||
&diffs[i],
|
||||
appearance,
|
||||
column,
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
} else {
|
||||
render_table(
|
||||
ui,
|
||||
@@ -678,29 +675,6 @@ fn diff_col_ui(
|
||||
},
|
||||
);
|
||||
}
|
||||
} else if let Some((_section, section_diff, _section_idx)) = ctx.section {
|
||||
hotkeys::check_scroll_hotkeys(ui, false);
|
||||
let total_bytes =
|
||||
section_diff.data_diff.iter().fold(0usize, |accum, item| accum + item.len);
|
||||
if total_bytes == 0 {
|
||||
return ret;
|
||||
}
|
||||
let total_rows = (total_bytes - 1) / BYTES_PER_ROW + 1;
|
||||
let diffs = split_diffs(§ion_diff.data_diff, §ion_diff.reloc_diff);
|
||||
render_table(
|
||||
ui,
|
||||
available_width / 2.0,
|
||||
1,
|
||||
appearance.code_font.size,
|
||||
total_rows,
|
||||
|row, _column| {
|
||||
let i = row.index();
|
||||
let address = i * BYTES_PER_ROW;
|
||||
row.col(|ui| {
|
||||
data_row_ui(ui, Some(obj), address, &diffs[i], appearance, column);
|
||||
});
|
||||
},
|
||||
);
|
||||
} else if let Some((_other_symbol, _other_symbol_diff, other_symbol_idx)) = other_ctx.symbol
|
||||
{
|
||||
if let Some(action) = symbol_list_ui(
|
||||
@@ -796,10 +770,6 @@ fn missing_obj_ui(ui: &mut Ui, appearance: &Appearance) {
|
||||
});
|
||||
}
|
||||
|
||||
fn find_section(obj: &Object, section_name: &str) -> Option<usize> {
|
||||
obj.sections.iter().position(|section| section.name == section_name)
|
||||
}
|
||||
|
||||
pub fn hover_items_ui(ui: &mut Ui, items: Vec<HoverItem>, appearance: &Appearance) {
|
||||
for item in items {
|
||||
match item {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use core::any::Any;
|
||||
|
||||
use egui::ScrollArea;
|
||||
use objdiff_core::{
|
||||
arch::ppc::ExceptionInfo,
|
||||
obj::{Object, Symbol},
|
||||
};
|
||||
use objdiff_core::{arch::ppc::ExceptionInfo, obj::Object};
|
||||
|
||||
use crate::views::{appearance::Appearance, function_diff::FunctionDiffContext};
|
||||
|
||||
@@ -26,19 +25,19 @@ fn decode_extab(extab: &ExceptionInfo) -> String {
|
||||
text
|
||||
}
|
||||
|
||||
fn find_extab_entry<'a>(_obj: &'a Object, _symbol: &Symbol) -> Option<&'a ExceptionInfo> {
|
||||
// TODO
|
||||
// obj.arch.ppc().and_then(|ppc| ppc.extab_for_symbol(symbol))
|
||||
None
|
||||
fn find_extab_entry(obj: &Object, symbol_index: usize) -> Option<&ExceptionInfo> {
|
||||
(obj.arch.as_ref() as &dyn Any)
|
||||
.downcast_ref::<objdiff_core::arch::ppc::ArchPpc>()
|
||||
.and_then(|ppc| ppc.extab_for_symbol(symbol_index))
|
||||
}
|
||||
|
||||
fn extab_text_ui(
|
||||
ui: &mut egui::Ui,
|
||||
ctx: FunctionDiffContext<'_>,
|
||||
symbol: &Symbol,
|
||||
symbol_index: usize,
|
||||
appearance: &Appearance,
|
||||
) -> Option<()> {
|
||||
if let Some(extab_entry) = find_extab_entry(ctx.obj, symbol) {
|
||||
if let Some(extab_entry) = find_extab_entry(ctx.obj, symbol_index) {
|
||||
let text = decode_extab(extab_entry);
|
||||
ui.colored_label(appearance.replace_color, &text);
|
||||
return Some(());
|
||||
@@ -58,10 +57,8 @@ pub(crate) fn extab_ui(
|
||||
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
|
||||
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);
|
||||
|
||||
if let Some(symbol) =
|
||||
ctx.symbol_ref.and_then(|symbol_ref| ctx.obj.symbols.get(symbol_ref))
|
||||
{
|
||||
extab_text_ui(ui, ctx, symbol, appearance);
|
||||
if let Some(symbol_index) = ctx.symbol_ref {
|
||||
extab_text_ui(ui, ctx, symbol_index, appearance);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -142,6 +142,11 @@ impl DiffViewState {
|
||||
JobResult::ObjDiff(result) => {
|
||||
self.build = take(result);
|
||||
|
||||
// Clear reload flag so that we don't reload the view immediately
|
||||
if let Ok(mut state) = state.write() {
|
||||
state.queue_reload = false;
|
||||
}
|
||||
|
||||
// TODO: where should this go?
|
||||
if let Some(result) = self.post_build_nav.take() {
|
||||
self.current_view = result.view;
|
||||
@@ -228,7 +233,6 @@ impl DiffViewState {
|
||||
let resolved_nav = resolve_navigation(nav.kind, resolved_left, resolved_right);
|
||||
if (resolved_nav.left_symbol.is_some() && resolved_nav.right_symbol.is_some())
|
||||
|| (resolved_nav.left_symbol.is_none() && resolved_nav.right_symbol.is_none())
|
||||
|| resolved_nav.view != View::FunctionDiff
|
||||
{
|
||||
// Regular navigation
|
||||
if state.is_selecting_symbol() {
|
||||
@@ -411,14 +415,8 @@ fn resolve_navigation(
|
||||
},
|
||||
(SectionKind::Data, SectionKind::Data) => ResolvedNavigation {
|
||||
view: View::DataDiff,
|
||||
left_symbol: Some(SymbolRefByName {
|
||||
symbol_name: "".to_string(),
|
||||
section_name: Some(left.section.name.clone()),
|
||||
}),
|
||||
right_symbol: Some(SymbolRefByName {
|
||||
symbol_name: "".to_string(),
|
||||
section_name: Some(right.section.name.clone()),
|
||||
}),
|
||||
left_symbol: Some(left.symbol_ref),
|
||||
right_symbol: Some(right.symbol_ref),
|
||||
},
|
||||
_ => ResolvedNavigation::default(),
|
||||
},
|
||||
@@ -433,14 +431,8 @@ fn resolve_navigation(
|
||||
},
|
||||
SectionKind::Data => ResolvedNavigation {
|
||||
view: View::DataDiff,
|
||||
left_symbol: Some(SymbolRefByName {
|
||||
symbol_name: "".to_string(),
|
||||
section_name: Some(left.section.name.clone()),
|
||||
}),
|
||||
right_symbol: Some(SymbolRefByName {
|
||||
symbol_name: "".to_string(),
|
||||
section_name: Some(left.section.name.clone()),
|
||||
}),
|
||||
left_symbol: Some(left.symbol_ref),
|
||||
right_symbol: None,
|
||||
},
|
||||
_ => ResolvedNavigation::default(),
|
||||
},
|
||||
@@ -455,14 +447,8 @@ fn resolve_navigation(
|
||||
},
|
||||
SectionKind::Data => ResolvedNavigation {
|
||||
view: View::DataDiff,
|
||||
left_symbol: Some(SymbolRefByName {
|
||||
symbol_name: "".to_string(),
|
||||
section_name: Some(right.section.name.clone()),
|
||||
}),
|
||||
right_symbol: Some(SymbolRefByName {
|
||||
symbol_name: "".to_string(),
|
||||
section_name: Some(right.section.name.clone()),
|
||||
}),
|
||||
left_symbol: None,
|
||||
right_symbol: Some(right.symbol_ref),
|
||||
},
|
||||
_ => ResolvedNavigation::default(),
|
||||
},
|
||||
|
||||
6
objdiff-wasm/.cargo/config.toml
Normal file
6
objdiff-wasm/.cargo/config.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[build]
|
||||
target = "wasm32-wasip2"
|
||||
|
||||
[unstable]
|
||||
build-std = ["panic_abort", "core", "alloc"]
|
||||
build-std-features = ["compiler-builtins-mem"]
|
||||
@@ -17,12 +17,13 @@ build = "build.rs"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
default = []
|
||||
std = ["objdiff-core/std"]
|
||||
|
||||
[dependencies]
|
||||
log = { version = "0.4", default-features = false }
|
||||
regex = { version = "1.11", default-features = false, features = ["unicode-case"] }
|
||||
wit-bindgen = { version = "0.44", default-features = false, features = ["macros"] }
|
||||
xxhash-rust = { version = "0.8", default-features = false, features = ["xxh3"] }
|
||||
|
||||
[dependencies.objdiff-core]
|
||||
@@ -33,8 +34,5 @@ features = ["arm", "arm64", "mips", "ppc", "superh", "x86", "dwarf"]
|
||||
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||
talc = { version = "4.4", default-features = false, features = ["lock_api"] }
|
||||
|
||||
[target.'cfg(target_os = "wasi")'.dependencies]
|
||||
wit-bindgen = { version = "0.43", default-features = false, features = ["macros"] }
|
||||
|
||||
[build-dependencies]
|
||||
wit-deps = "0.5"
|
||||
|
||||
4
objdiff-wasm/package-lock.json
generated
4
objdiff-wasm/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "objdiff-wasm",
|
||||
"version": "3.0.0-beta.14",
|
||||
"version": "3.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "objdiff-wasm",
|
||||
"version": "3.0.0-beta.14",
|
||||
"version": "3.1.0",
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^1.9.3",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "objdiff-wasm",
|
||||
"version": "3.0.0-beta.14",
|
||||
"version": "3.1.0",
|
||||
"description": "A local diffing tool for decompilation projects.",
|
||||
"author": {
|
||||
"name": "Luke Street",
|
||||
@@ -19,8 +19,8 @@
|
||||
"types": "dist/objdiff.d.ts",
|
||||
"scripts": {
|
||||
"build": "npm run build:wasm && npm run build:transpile && npm run build:lib",
|
||||
"build:wasm": "cargo +nightly -Zbuild-std=panic_abort,core,alloc -Zbuild-std-features=compiler-builtins-mem build --target wasm32-wasip2 --release --no-default-features",
|
||||
"build:transpile": "jco transpile ../target/wasm32-wasip2/release/objdiff_wasm.wasm --no-nodejs-compat --no-wasi-shim --no-namespaced-exports --map wasi:logging/logging=./wasi-logging.js --optimize -o pkg --name objdiff",
|
||||
"build:wasm": "cargo build --profile release-min --no-default-features",
|
||||
"build:transpile": "jco transpile ../target/wasm32-wasip2/release-min/objdiff_wasm.wasm --no-nodejs-compat --no-wasi-shim --no-namespaced-exports --map wasi:logging/logging=./wasi-logging.js --optimize -o pkg --name objdiff",
|
||||
"build:lib": "rslib build"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
4
objdiff-wasm/rust-toolchain.toml
Normal file
4
objdiff-wasm/rust-toolchain.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[toolchain]
|
||||
channel = "nightly"
|
||||
components = ["rust-src"]
|
||||
targets = ["wasm32-wasip2"]
|
||||
@@ -1,3 +1,4 @@
|
||||
#![allow(clippy::derivable_impls)]
|
||||
use alloc::{
|
||||
format,
|
||||
rc::{Rc, Weak},
|
||||
@@ -23,7 +24,7 @@ wit_bindgen::generate!({
|
||||
|
||||
use exports::objdiff::core::{
|
||||
diff::{
|
||||
DiffConfigBorrow, DiffResult, Guest as GuestDiff, GuestDiffConfig, GuestObject,
|
||||
DiffConfigBorrow, DiffResult, DiffSide, Guest as GuestDiff, GuestDiffConfig, GuestObject,
|
||||
GuestObjectDiff, MappingConfig, Object, ObjectBorrow, ObjectDiff, ObjectDiffBorrow,
|
||||
SymbolFlags, SymbolInfo, SymbolKind, SymbolRef,
|
||||
},
|
||||
@@ -223,7 +224,7 @@ impl GuestDisplay for Component {
|
||||
let symbol_display = from_symbol_ref(symbol_ref);
|
||||
diff::display::symbol_context(obj, symbol_display.symbol as usize)
|
||||
.into_iter()
|
||||
.map(|item| ContextItem::from(item))
|
||||
.map(ContextItem::from)
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -235,7 +236,7 @@ impl GuestDisplay for Component {
|
||||
let symbol_display = from_symbol_ref(symbol_ref);
|
||||
diff::display::symbol_hover(obj, symbol_display.symbol as usize, addend, override_color)
|
||||
.into_iter()
|
||||
.map(|item| HoverItem::from(item))
|
||||
.map(HoverItem::from)
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -282,7 +283,7 @@ impl GuestDisplay for Component {
|
||||
};
|
||||
diff::display::instruction_context(obj, resolved, &ins)
|
||||
.into_iter()
|
||||
.map(|item| ContextItem::from(item))
|
||||
.map(ContextItem::from)
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -331,7 +332,7 @@ impl GuestDisplay for Component {
|
||||
};
|
||||
diff::display::instruction_hover(obj, resolved, &ins)
|
||||
.into_iter()
|
||||
.map(|item| HoverItem::from(item))
|
||||
.map(HoverItem::from)
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
@@ -469,8 +470,21 @@ unsafe impl Sync for ObjectCache {}
|
||||
|
||||
static OBJECT_CACHE: ObjectCache = ObjectCache::new();
|
||||
|
||||
impl From<DiffSide> for objdiff_core::diff::DiffSide {
|
||||
fn from(value: DiffSide) -> Self {
|
||||
match value {
|
||||
DiffSide::Target => Self::Target,
|
||||
DiffSide::Base => Self::Base,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GuestObject for ResourceObject {
|
||||
fn parse(data: Vec<u8>, diff_config: DiffConfigBorrow) -> Result<Object, String> {
|
||||
fn parse(
|
||||
data: Vec<u8>,
|
||||
diff_config: DiffConfigBorrow,
|
||||
diff_side: DiffSide,
|
||||
) -> Result<Object, String> {
|
||||
let hash = xxh3_64(&data);
|
||||
let mut cached = None;
|
||||
OBJECT_CACHE.borrow_mut().retain(|c| {
|
||||
@@ -486,7 +500,9 @@ impl GuestObject for ResourceObject {
|
||||
return Ok(Object::new(ResourceObject(obj, hash)));
|
||||
}
|
||||
let diff_config = diff_config.get::<ResourceDiffConfig>().0.borrow();
|
||||
let obj = Rc::new(obj::read::parse(&data, &diff_config).map_err(|e| e.to_string())?);
|
||||
let obj = Rc::new(
|
||||
obj::read::parse(&data, &diff_config, diff_side.into()).map_err(|e| e.to_string())?,
|
||||
);
|
||||
OBJECT_CACHE.borrow_mut().push(CachedObject(Rc::downgrade(&obj), hash));
|
||||
Ok(Object::new(ResourceObject(obj, hash)))
|
||||
}
|
||||
@@ -527,9 +543,7 @@ impl GuestObjectDiff for ResourceObjectDiff {
|
||||
fn get_symbol(&self, symbol_ref: SymbolRef) -> Option<SymbolInfo> {
|
||||
let obj = self.0.as_ref();
|
||||
let symbol_display = from_symbol_ref(symbol_ref);
|
||||
let Some(symbol) = obj.symbols.get(symbol_display.symbol) else {
|
||||
return None;
|
||||
};
|
||||
let symbol = obj.symbols.get(symbol_display.symbol)?;
|
||||
Some(SymbolInfo {
|
||||
id: to_symbol_ref(symbol_display),
|
||||
name: symbol.name.clone(),
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
extern crate alloc;
|
||||
|
||||
#[cfg(target_os = "wasi")]
|
||||
mod api;
|
||||
#[cfg(target_os = "wasi")]
|
||||
mod logging;
|
||||
|
||||
#[cfg(all(target_os = "wasi", not(feature = "std")))]
|
||||
|
||||
@@ -19,6 +19,7 @@ interface diff {
|
||||
parse: static func(
|
||||
data: list<u8>,
|
||||
config: borrow<diff-config>,
|
||||
side: diff-side,
|
||||
) -> result<object, string>;
|
||||
|
||||
hash: func() -> u64;
|
||||
@@ -80,6 +81,11 @@ interface diff {
|
||||
config: borrow<diff-config>,
|
||||
mapping: mapping-config,
|
||||
) -> result<diff-result, string>;
|
||||
|
||||
enum diff-side {
|
||||
target,
|
||||
base,
|
||||
}
|
||||
}
|
||||
|
||||
interface display {
|
||||
|
||||
Reference in New Issue
Block a user