mirror of
https://github.com/encounter/objdiff.git
synced 2025-12-20 10:25:26 +00:00
Compare commits
6 Commits
v2.0.0-alp
...
v2.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
| fc598af329 | |||
| 871407622d | |||
| e3fff7b0dc | |||
|
|
75b0e7d9e5 | ||
|
|
9f71ce9fea | ||
|
|
d9fb48853e |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -22,3 +22,4 @@ android.keystore
|
|||||||
*.frag
|
*.frag
|
||||||
*.vert
|
*.vert
|
||||||
*.metal
|
*.metal
|
||||||
|
.vscode/launch.json
|
||||||
|
|||||||
60
Cargo.lock
generated
60
Cargo.lock
generated
@@ -110,9 +110,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.82"
|
version = "1.0.86"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519"
|
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arboard"
|
name = "arboard"
|
||||||
@@ -524,9 +524,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.6.0"
|
version = "1.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
|
checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "calloop"
|
name = "calloop"
|
||||||
@@ -970,6 +970,15 @@ version = "1.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c2e06f9bce634a3c898eb1e5cb949ff63133cbb218af93cc9b38b31d6f3ea285"
|
checksum = "c2e06f9bce634a3c898eb1e5cb949ff63133cbb218af93cc9b38b31d6f3ea285"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cwextab"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a92e840be31d11ead5f357b8fc503133d3657845d0ccf539afcc7d1212fad226"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "d3d12"
|
name = "d3d12"
|
||||||
version = "0.19.0"
|
version = "0.19.0"
|
||||||
@@ -2274,9 +2283,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.154"
|
version = "0.2.155"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
|
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
@@ -2789,7 +2798,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objdiff-cli"
|
name = "objdiff-cli"
|
||||||
version = "2.0.0-alpha.5"
|
version = "2.0.0-beta.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"argp",
|
"argp",
|
||||||
@@ -2808,13 +2817,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objdiff-core"
|
name = "objdiff-core"
|
||||||
version = "2.0.0-alpha.5"
|
version = "2.0.0-beta.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"arm-attr",
|
"arm-attr",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"cpp_demangle",
|
"cpp_demangle",
|
||||||
"cwdemangle",
|
"cwdemangle",
|
||||||
|
"cwextab",
|
||||||
"filetime",
|
"filetime",
|
||||||
"flagset",
|
"flagset",
|
||||||
"gimli 0.29.0",
|
"gimli 0.29.0",
|
||||||
@@ -2838,7 +2848,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objdiff-gui"
|
name = "objdiff-gui"
|
||||||
version = "2.0.0-alpha.5"
|
version = "2.0.0-beta.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -2846,6 +2856,7 @@ dependencies = [
|
|||||||
"console_error_panic_hook",
|
"console_error_panic_hook",
|
||||||
"const_format",
|
"const_format",
|
||||||
"cwdemangle",
|
"cwdemangle",
|
||||||
|
"cwextab",
|
||||||
"dirs",
|
"dirs",
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui",
|
"egui",
|
||||||
@@ -2861,8 +2872,10 @@ dependencies = [
|
|||||||
"path-slash",
|
"path-slash",
|
||||||
"png",
|
"png",
|
||||||
"pollster",
|
"pollster",
|
||||||
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rfd",
|
"rfd",
|
||||||
|
"rlwinmdec",
|
||||||
"ron",
|
"ron",
|
||||||
"self_update",
|
"self_update",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -2905,9 +2918,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl"
|
name = "openssl"
|
||||||
version = "0.10.64"
|
version = "0.10.66"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f"
|
checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.5.0",
|
"bitflags 2.5.0",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
@@ -2937,9 +2950,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-sys"
|
name = "openssl-sys"
|
||||||
version = "0.9.102"
|
version = "0.9.103"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2"
|
checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -3377,9 +3390,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.10.4"
|
version = "1.10.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
|
checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -3509,6 +3522,15 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rlwinmdec"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2076dbc187938f3db71c03c85d143febf01026631189dc8ca85f8c886d90ea12"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ron"
|
name = "ron"
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
@@ -4330,9 +4352,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unarm"
|
name = "unarm"
|
||||||
version = "1.3.0"
|
version = "1.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c6bff109f0171a299559d82a7236e056093fc0dcd2a7da86aa745f82281e2d31"
|
checksum = "379762d9433a2e6e498cde97801fb238318b024a513d0843eeac98b9056b9f3c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicase"
|
name = "unicase"
|
||||||
@@ -4743,9 +4765,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-hal"
|
name = "wgpu-hal"
|
||||||
version = "0.19.4"
|
version = "0.19.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc1a4924366df7ab41a5d8546d6534f1f33231aa5b3f72b9930e300f254e39c3"
|
checksum = "bfabcfc55fd86611a855816326b2d54c3b2fd7972c27ce414291562650552703"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_system_properties",
|
"android_system_properties",
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "objdiff-cli"
|
name = "objdiff-cli"
|
||||||
version = "2.0.0-alpha.5"
|
version = "2.0.0-beta.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.70"
|
rust-version = "1.70"
|
||||||
authors = ["Luke Street <luke@street.dev>"]
|
authors = ["Luke Street <luke@street.dev>"]
|
||||||
|
|||||||
@@ -817,6 +817,12 @@ impl FunctionDiffUi {
|
|||||||
mips_abi: Default::default(), // TODO
|
mips_abi: Default::default(), // TODO
|
||||||
mips_instr_category: Default::default(), // TODO
|
mips_instr_category: Default::default(), // TODO
|
||||||
arm_arch_version: Default::default(), // TODO
|
arm_arch_version: Default::default(), // TODO
|
||||||
|
arm_unified_syntax: true, // TODO
|
||||||
|
arm_av_registers: false, // TODO
|
||||||
|
arm_r9_usage: Default::default(), // TODO
|
||||||
|
arm_sl_usage: false, // TODO
|
||||||
|
arm_fp_usage: false, // TODO
|
||||||
|
arm_ip_usage: false, // TODO
|
||||||
};
|
};
|
||||||
let target = self
|
let target = self
|
||||||
.target_path
|
.target_path
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "objdiff-core"
|
name = "objdiff-core"
|
||||||
version = "2.0.0-alpha.5"
|
version = "2.0.0-beta.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.70"
|
rust-version = "1.70"
|
||||||
authors = ["Luke Street <luke@street.dev>"]
|
authors = ["Luke Street <luke@street.dev>"]
|
||||||
@@ -17,7 +17,7 @@ any-arch = [] # Implicit, used to check if any arch is enabled
|
|||||||
config = ["globset", "semver", "serde_json", "serde_yaml"]
|
config = ["globset", "semver", "serde_json", "serde_yaml"]
|
||||||
dwarf = ["gimli"]
|
dwarf = ["gimli"]
|
||||||
mips = ["any-arch", "rabbitizer"]
|
mips = ["any-arch", "rabbitizer"]
|
||||||
ppc = ["any-arch", "cwdemangle", "ppc750cl"]
|
ppc = ["any-arch", "cwdemangle", "cwextab", "ppc750cl"]
|
||||||
x86 = ["any-arch", "cpp_demangle", "iced-x86", "msvc-demangler"]
|
x86 = ["any-arch", "cpp_demangle", "iced-x86", "msvc-demangler"]
|
||||||
arm = ["any-arch", "cpp_demangle", "unarm", "arm-attr"]
|
arm = ["any-arch", "cpp_demangle", "unarm", "arm-attr"]
|
||||||
|
|
||||||
@@ -45,6 +45,7 @@ gimli = { version = "0.29.0", default-features = false, features = ["read-all"],
|
|||||||
|
|
||||||
# ppc
|
# ppc
|
||||||
cwdemangle = { version = "1.0.0", optional = true }
|
cwdemangle = { version = "1.0.0", optional = true }
|
||||||
|
cwextab = { version = "0.2.3", optional = true }
|
||||||
ppc750cl = { git = "https://github.com/encounter/ppc750cl", rev = "6cbd7d888c7082c2c860f66cbb9848d633f753ed", optional = true }
|
ppc750cl = { git = "https://github.com/encounter/ppc750cl", rev = "6cbd7d888c7082c2c860f66cbb9848d633f753ed", optional = true }
|
||||||
|
|
||||||
# mips
|
# mips
|
||||||
@@ -56,5 +57,5 @@ iced-x86 = { version = "1.21.0", default-features = false, features = ["std", "d
|
|||||||
msvc-demangler = { version = "0.10.0", optional = true }
|
msvc-demangler = { version = "0.10.0", optional = true }
|
||||||
|
|
||||||
# arm
|
# arm
|
||||||
unarm = { version = "1.3.0", optional = true }
|
unarm = { version = "1.4.0", optional = true }
|
||||||
arm-attr = { version = "0.1.1", optional = true }
|
arm-attr = { version = "0.1.1", optional = true }
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ use object::{
|
|||||||
use unarm::{
|
use unarm::{
|
||||||
args::{Argument, OffsetImm, OffsetReg, Register},
|
args::{Argument, OffsetImm, OffsetReg, Register},
|
||||||
parse::{ArmVersion, ParseMode, Parser},
|
parse::{ArmVersion, ParseMode, Parser},
|
||||||
ParsedIns,
|
DisplayOptions, ParseFlags, ParsedIns, RegNames,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
arch::{ObjArch, ProcessCodeResult},
|
arch::{ObjArch, ProcessCodeResult},
|
||||||
diff::{ArmArchVersion, DiffObjConfig},
|
diff::{ArmArchVersion, ArmR9Usage, DiffObjConfig},
|
||||||
obj::{ObjIns, ObjInsArg, ObjInsArgValue, ObjReloc, ObjSection},
|
obj::{ObjIns, ObjInsArg, ObjInsArgValue, ObjReloc, ObjSection},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -149,7 +149,24 @@ impl ObjArch for ObjArchArm {
|
|||||||
object::Endianness::Little => unarm::Endian::Little,
|
object::Endianness::Little => unarm::Endian::Little,
|
||||||
object::Endianness::Big => unarm::Endian::Big,
|
object::Endianness::Big => unarm::Endian::Big,
|
||||||
};
|
};
|
||||||
let mut parser = Parser::new(version, first_mapping, start_addr, endian, code);
|
|
||||||
|
let parse_flags = ParseFlags { ual: config.arm_unified_syntax };
|
||||||
|
|
||||||
|
let mut parser = Parser::new(version, first_mapping, start_addr, endian, parse_flags, code);
|
||||||
|
|
||||||
|
let display_options = DisplayOptions {
|
||||||
|
reg_names: RegNames {
|
||||||
|
av_registers: config.arm_av_registers,
|
||||||
|
r9_use: match config.arm_r9_usage {
|
||||||
|
ArmR9Usage::GeneralPurpose => unarm::R9Use::GeneralPurpose,
|
||||||
|
ArmR9Usage::Sb => unarm::R9Use::Pid,
|
||||||
|
ArmR9Usage::Tr => unarm::R9Use::Tls,
|
||||||
|
},
|
||||||
|
explicit_stack_limit: config.arm_sl_usage,
|
||||||
|
frame_pointer: config.arm_fp_usage,
|
||||||
|
ip: config.arm_ip_usage,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
while let Some((address, op, ins)) = parser.next() {
|
while let Some((address, op, ins)) = parser.next() {
|
||||||
if let Some(next) = next_mapping {
|
if let Some(next) = next_mapping {
|
||||||
@@ -187,7 +204,7 @@ impl ObjArch for ObjArchArm {
|
|||||||
let (args, branch_dest) = if reloc.is_some() && parser.mode == ParseMode::Data {
|
let (args, branch_dest) = if reloc.is_some() && parser.mode == ParseMode::Data {
|
||||||
(vec![ObjInsArg::Reloc], None)
|
(vec![ObjInsArg::Reloc], None)
|
||||||
} else {
|
} else {
|
||||||
push_args(&ins, config, reloc_arg, address)?
|
push_args(&ins, config, reloc_arg, address, display_options)?
|
||||||
};
|
};
|
||||||
|
|
||||||
ops.push(op.id());
|
ops.push(op.id());
|
||||||
@@ -200,7 +217,7 @@ impl ObjArch for ObjArchArm {
|
|||||||
reloc,
|
reloc,
|
||||||
branch_dest,
|
branch_dest,
|
||||||
line,
|
line,
|
||||||
formatted: ins.to_string(),
|
formatted: ins.display(display_options).to_string(),
|
||||||
orig: None,
|
orig: None,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -281,6 +298,7 @@ fn push_args(
|
|||||||
config: &DiffObjConfig,
|
config: &DiffObjConfig,
|
||||||
reloc_arg: Option<usize>,
|
reloc_arg: Option<usize>,
|
||||||
cur_addr: u32,
|
cur_addr: u32,
|
||||||
|
display_options: DisplayOptions,
|
||||||
) -> Result<(Vec<ObjInsArg>, Option<u64>)> {
|
) -> Result<(Vec<ObjInsArg>, Option<u64>)> {
|
||||||
let mut args = vec![];
|
let mut args = vec![];
|
||||||
let mut branch_dest = None;
|
let mut branch_dest = None;
|
||||||
@@ -318,7 +336,9 @@ fn push_args(
|
|||||||
deref = true;
|
deref = true;
|
||||||
args.push(ObjInsArg::PlainText("[".into()));
|
args.push(ObjInsArg::PlainText("[".into()));
|
||||||
}
|
}
|
||||||
args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(reg.reg.to_string().into())));
|
args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(
|
||||||
|
reg.reg.display(display_options.reg_names).to_string().into(),
|
||||||
|
)));
|
||||||
if reg.writeback {
|
if reg.writeback {
|
||||||
if reg.deref {
|
if reg.deref {
|
||||||
writeback = true;
|
writeback = true;
|
||||||
@@ -336,7 +356,10 @@ fn push_args(
|
|||||||
args.push(ObjInsArg::PlainText(config.separator().into()));
|
args.push(ObjInsArg::PlainText(config.separator().into()));
|
||||||
}
|
}
|
||||||
args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(
|
args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(
|
||||||
Register::parse(i).to_string().into(),
|
Register::parse(i)
|
||||||
|
.display(display_options.reg_names)
|
||||||
|
.to_string()
|
||||||
|
.into(),
|
||||||
)));
|
)));
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
@@ -376,14 +399,16 @@ fn push_args(
|
|||||||
Argument::ShiftReg(shift) => {
|
Argument::ShiftReg(shift) => {
|
||||||
args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(shift.op.to_string().into())));
|
args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(shift.op.to_string().into())));
|
||||||
args.push(ObjInsArg::PlainText(" ".into()));
|
args.push(ObjInsArg::PlainText(" ".into()));
|
||||||
args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(shift.reg.to_string().into())));
|
args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(
|
||||||
|
shift.reg.display(display_options.reg_names).to_string().into(),
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
Argument::OffsetReg(offset) => {
|
Argument::OffsetReg(offset) => {
|
||||||
if !offset.add {
|
if !offset.add {
|
||||||
args.push(ObjInsArg::PlainText("-".into()));
|
args.push(ObjInsArg::PlainText("-".into()));
|
||||||
}
|
}
|
||||||
args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(
|
args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(
|
||||||
offset.reg.to_string().into(),
|
offset.reg.display(display_options.reg_names).to_string().into(),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
Argument::CpsrMode(mode) => {
|
Argument::CpsrMode(mode) => {
|
||||||
@@ -398,9 +423,9 @@ fn push_args(
|
|||||||
| Argument::StatusMask(_)
|
| Argument::StatusMask(_)
|
||||||
| Argument::Shift(_)
|
| Argument::Shift(_)
|
||||||
| Argument::CpsrFlags(_)
|
| Argument::CpsrFlags(_)
|
||||||
| Argument::Endian(_) => {
|
| Argument::Endian(_) => args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(
|
||||||
args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(arg.to_string().into())))
|
arg.display(display_options).to_string().into(),
|
||||||
}
|
))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,27 +11,6 @@ use crate::{
|
|||||||
obj::{ObjInfo, ObjSection, SymbolRef},
|
obj::{ObjInfo, ObjSection, SymbolRef},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Compare the addresses and sizes of each symbol in the BSS sections.
|
|
||||||
pub fn diff_bss_section(
|
|
||||||
left: &ObjSection,
|
|
||||||
right: &ObjSection,
|
|
||||||
) -> Result<(ObjSectionDiff, ObjSectionDiff)> {
|
|
||||||
let deadline = Instant::now() + Duration::from_secs(5);
|
|
||||||
let left_sizes = left.symbols.iter().map(|s| (s.section_address, s.size)).collect::<Vec<_>>();
|
|
||||||
let right_sizes = right.symbols.iter().map(|s| (s.section_address, s.size)).collect::<Vec<_>>();
|
|
||||||
let ops = capture_diff_slices_deadline(
|
|
||||||
Algorithm::Patience,
|
|
||||||
&left_sizes,
|
|
||||||
&right_sizes,
|
|
||||||
Some(deadline),
|
|
||||||
);
|
|
||||||
let match_percent = get_diff_ratio(&ops, left_sizes.len(), right_sizes.len()) * 100.0;
|
|
||||||
Ok((
|
|
||||||
ObjSectionDiff { symbols: vec![], data_diff: vec![], match_percent: Some(match_percent) },
|
|
||||||
ObjSectionDiff { symbols: vec![], data_diff: vec![], match_percent: Some(match_percent) },
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn diff_bss_symbol(
|
pub fn diff_bss_symbol(
|
||||||
left_obj: &ObjInfo,
|
left_obj: &ObjInfo,
|
||||||
right_obj: &ObjInfo,
|
right_obj: &ObjInfo,
|
||||||
@@ -65,6 +44,8 @@ pub fn no_diff_symbol(_obj: &ObjInfo, symbol_ref: SymbolRef) -> ObjSymbolDiff {
|
|||||||
pub fn diff_data_section(
|
pub fn diff_data_section(
|
||||||
left: &ObjSection,
|
left: &ObjSection,
|
||||||
right: &ObjSection,
|
right: &ObjSection,
|
||||||
|
left_section_diff: &ObjSectionDiff,
|
||||||
|
right_section_diff: &ObjSectionDiff,
|
||||||
) -> Result<(ObjSectionDiff, ObjSectionDiff)> {
|
) -> Result<(ObjSectionDiff, ObjSectionDiff)> {
|
||||||
let deadline = Instant::now() + Duration::from_secs(5);
|
let deadline = Instant::now() + Duration::from_secs(5);
|
||||||
let left_max = left.symbols.iter().map(|s| s.section_address + s.size).max().unwrap_or(0);
|
let left_max = left.symbols.iter().map(|s| s.section_address + s.size).max().unwrap_or(0);
|
||||||
@@ -73,7 +54,6 @@ pub fn diff_data_section(
|
|||||||
let right_data = &right.data[..right_max as usize];
|
let right_data = &right.data[..right_max as usize];
|
||||||
let ops =
|
let ops =
|
||||||
capture_diff_slices_deadline(Algorithm::Patience, left_data, right_data, Some(deadline));
|
capture_diff_slices_deadline(Algorithm::Patience, left_data, right_data, Some(deadline));
|
||||||
let match_percent = get_diff_ratio(&ops, left_data.len(), right_data.len()) * 100.0;
|
|
||||||
|
|
||||||
let mut left_diff = Vec::<ObjDataDiff>::new();
|
let mut left_diff = Vec::<ObjDataDiff>::new();
|
||||||
let mut right_diff = Vec::<ObjDataDiff>::new();
|
let mut right_diff = Vec::<ObjDataDiff>::new();
|
||||||
@@ -143,18 +123,11 @@ pub fn diff_data_section(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((
|
let (mut left_section_diff, mut right_section_diff) =
|
||||||
ObjSectionDiff {
|
diff_generic_section(left, right, left_section_diff, right_section_diff)?;
|
||||||
symbols: vec![],
|
left_section_diff.data_diff = left_diff;
|
||||||
data_diff: left_diff,
|
right_section_diff.data_diff = right_diff;
|
||||||
match_percent: Some(match_percent),
|
Ok((left_section_diff, right_section_diff))
|
||||||
},
|
|
||||||
ObjSectionDiff {
|
|
||||||
symbols: vec![],
|
|
||||||
data_diff: right_diff,
|
|
||||||
match_percent: Some(match_percent),
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn diff_data_symbol(
|
pub fn diff_data_symbol(
|
||||||
@@ -195,21 +168,24 @@ pub fn diff_data_symbol(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compare the text sections of two object files.
|
/// Compares a section of two object files.
|
||||||
/// This essentially adds up the match percentage of each symbol in the text section.
|
/// This essentially adds up the match percentage of each symbol in the section.
|
||||||
pub fn diff_text_section(
|
pub fn diff_generic_section(
|
||||||
left: &ObjSection,
|
left: &ObjSection,
|
||||||
_right: &ObjSection,
|
_right: &ObjSection,
|
||||||
left_diff: &ObjSectionDiff,
|
left_diff: &ObjSectionDiff,
|
||||||
_right_diff: &ObjSectionDiff,
|
_right_diff: &ObjSectionDiff,
|
||||||
) -> Result<(ObjSectionDiff, ObjSectionDiff)> {
|
) -> Result<(ObjSectionDiff, ObjSectionDiff)> {
|
||||||
let match_percent = left
|
let match_percent = if left_diff.symbols.iter().all(|d| d.match_percent == Some(100.0)) {
|
||||||
.symbols
|
100.0 // Avoid fp precision issues
|
||||||
|
} else {
|
||||||
|
left.symbols
|
||||||
.iter()
|
.iter()
|
||||||
.zip(left_diff.symbols.iter())
|
.zip(left_diff.symbols.iter())
|
||||||
.map(|(s, d)| d.match_percent.unwrap_or(0.0) * s.size as f32)
|
.map(|(s, d)| d.match_percent.unwrap_or(0.0) * s.size as f32)
|
||||||
.sum::<f32>()
|
.sum::<f32>()
|
||||||
/ left.size as f32;
|
/ left.size as f32
|
||||||
|
};
|
||||||
Ok((
|
Ok((
|
||||||
ObjSectionDiff { symbols: vec![], data_diff: vec![], match_percent: Some(match_percent) },
|
ObjSectionDiff { symbols: vec![], data_diff: vec![], match_percent: Some(match_percent) },
|
||||||
ObjSectionDiff { symbols: vec![], data_diff: vec![], match_percent: Some(match_percent) },
|
ObjSectionDiff { symbols: vec![], data_diff: vec![], match_percent: Some(match_percent) },
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ use crate::{
|
|||||||
diff::{
|
diff::{
|
||||||
code::{diff_code, no_diff_code, process_code_symbol},
|
code::{diff_code, no_diff_code, process_code_symbol},
|
||||||
data::{
|
data::{
|
||||||
diff_bss_section, diff_bss_symbol, diff_data_section, diff_data_symbol,
|
diff_bss_symbol, diff_data_section, diff_data_symbol, diff_generic_section,
|
||||||
diff_text_section, no_diff_symbol,
|
no_diff_symbol,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
obj::{ObjInfo, ObjIns, ObjSection, ObjSectionKind, ObjSymbol, SymbolRef},
|
obj::{ObjInfo, ObjIns, ObjSection, ObjSectionKind, ObjSymbol, SymbolRef},
|
||||||
@@ -117,6 +117,34 @@ pub enum ArmArchVersion {
|
|||||||
V6K,
|
V6K,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Debug,
|
||||||
|
Copy,
|
||||||
|
Clone,
|
||||||
|
Default,
|
||||||
|
Eq,
|
||||||
|
PartialEq,
|
||||||
|
serde::Deserialize,
|
||||||
|
serde::Serialize,
|
||||||
|
strum::VariantArray,
|
||||||
|
strum::EnumMessage,
|
||||||
|
)]
|
||||||
|
pub enum ArmR9Usage {
|
||||||
|
#[default]
|
||||||
|
#[strum(
|
||||||
|
message = "R9 or V6 (default)",
|
||||||
|
detailed_message = "Use R9 as a general-purpose register."
|
||||||
|
)]
|
||||||
|
GeneralPurpose,
|
||||||
|
#[strum(
|
||||||
|
message = "SB (static base)",
|
||||||
|
detailed_message = "Used for position-independent data (PID)."
|
||||||
|
)]
|
||||||
|
Sb,
|
||||||
|
#[strum(message = "TR (TLS register)", detailed_message = "Used for thread-local storage.")]
|
||||||
|
Tr,
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
const fn default_true() -> bool { true }
|
const fn default_true() -> bool { true }
|
||||||
|
|
||||||
@@ -134,6 +162,12 @@ pub struct DiffObjConfig {
|
|||||||
pub mips_instr_category: MipsInstrCategory,
|
pub mips_instr_category: MipsInstrCategory,
|
||||||
// ARM
|
// ARM
|
||||||
pub arm_arch_version: ArmArchVersion,
|
pub arm_arch_version: ArmArchVersion,
|
||||||
|
pub arm_unified_syntax: bool,
|
||||||
|
pub arm_av_registers: bool,
|
||||||
|
pub arm_r9_usage: ArmR9Usage,
|
||||||
|
pub arm_sl_usage: bool,
|
||||||
|
pub arm_fp_usage: bool,
|
||||||
|
pub arm_ip_usage: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for DiffObjConfig {
|
impl Default for DiffObjConfig {
|
||||||
@@ -146,6 +180,12 @@ impl Default for DiffObjConfig {
|
|||||||
mips_abi: Default::default(),
|
mips_abi: Default::default(),
|
||||||
mips_instr_category: Default::default(),
|
mips_instr_category: Default::default(),
|
||||||
arm_arch_version: Default::default(),
|
arm_arch_version: Default::default(),
|
||||||
|
arm_unified_syntax: true,
|
||||||
|
arm_av_registers: false,
|
||||||
|
arm_r9_usage: Default::default(),
|
||||||
|
arm_sl_usage: false,
|
||||||
|
arm_fp_usage: false,
|
||||||
|
arm_ip_usage: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -443,10 +483,10 @@ pub fn diff_objs(
|
|||||||
let left_section = &left_obj.sections[left_section_idx];
|
let left_section = &left_obj.sections[left_section_idx];
|
||||||
let right_section = &right_obj.sections[right_section_idx];
|
let right_section = &right_obj.sections[right_section_idx];
|
||||||
match section_kind {
|
match section_kind {
|
||||||
ObjSectionKind::Code => {
|
ObjSectionKind::Code | ObjSectionKind::Bss => {
|
||||||
let left_section_diff = left_out.section_diff(left_section_idx);
|
let left_section_diff = left_out.section_diff(left_section_idx);
|
||||||
let right_section_diff = right_out.section_diff(right_section_idx);
|
let right_section_diff = right_out.section_diff(right_section_idx);
|
||||||
let (left_diff, right_diff) = diff_text_section(
|
let (left_diff, right_diff) = diff_generic_section(
|
||||||
left_section,
|
left_section,
|
||||||
right_section,
|
right_section,
|
||||||
left_section_diff,
|
left_section_diff,
|
||||||
@@ -456,12 +496,14 @@ pub fn diff_objs(
|
|||||||
right_out.section_diff_mut(right_section_idx).merge(right_diff);
|
right_out.section_diff_mut(right_section_idx).merge(right_diff);
|
||||||
}
|
}
|
||||||
ObjSectionKind::Data => {
|
ObjSectionKind::Data => {
|
||||||
let (left_diff, right_diff) = diff_data_section(left_section, right_section)?;
|
let left_section_diff = left_out.section_diff(left_section_idx);
|
||||||
left_out.section_diff_mut(left_section_idx).merge(left_diff);
|
let right_section_diff = right_out.section_diff(right_section_idx);
|
||||||
right_out.section_diff_mut(right_section_idx).merge(right_diff);
|
let (left_diff, right_diff) = diff_data_section(
|
||||||
}
|
left_section,
|
||||||
ObjSectionKind::Bss => {
|
right_section,
|
||||||
let (left_diff, right_diff) = diff_bss_section(left_section, right_section)?;
|
left_section_diff,
|
||||||
|
right_section_diff,
|
||||||
|
)?;
|
||||||
left_out.section_diff_mut(left_section_idx).merge(left_diff);
|
left_out.section_diff_mut(left_section_idx).merge(left_diff);
|
||||||
right_out.section_diff_mut(right_section_idx).merge(right_diff);
|
right_out.section_diff_mut(right_section_idx).merge(right_diff);
|
||||||
}
|
}
|
||||||
@@ -590,6 +632,26 @@ fn find_symbol(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
for (section_idx, section) in obj.sections.iter().enumerate() {
|
||||||
|
if section.kind != in_section.kind {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if let Some(symbol_idx) = section.symbols.iter().position(|symbol| {
|
||||||
|
if let Some((p, s)) = symbol.name.split_once('$') {
|
||||||
|
prefix == p && s.chars().all(char::is_numeric)
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
return Some(SymbolRef { section_idx, symbol_idx });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ pub mod split_meta;
|
|||||||
|
|
||||||
use std::{borrow::Cow, collections::BTreeMap, fmt, path::PathBuf};
|
use std::{borrow::Cow, collections::BTreeMap, fmt, path::PathBuf};
|
||||||
|
|
||||||
|
use cwextab::*;
|
||||||
use filetime::FileTime;
|
use filetime::FileTime;
|
||||||
use flagset::{flags, FlagSet};
|
use flagset::{flags, FlagSet};
|
||||||
use object::RelocationFlags;
|
use object::RelocationFlags;
|
||||||
@@ -113,6 +114,9 @@ pub struct ObjIns {
|
|||||||
pub struct ObjSymbol {
|
pub struct ObjSymbol {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub demangled_name: Option<String>,
|
pub demangled_name: Option<String>,
|
||||||
|
pub has_extab: bool,
|
||||||
|
pub extab_name: Option<String>,
|
||||||
|
pub extabindex_name: Option<String>,
|
||||||
pub address: u64,
|
pub address: u64,
|
||||||
pub section_address: u64,
|
pub section_address: u64,
|
||||||
pub size: u64,
|
pub size: u64,
|
||||||
@@ -123,6 +127,13 @@ pub struct ObjSymbol {
|
|||||||
pub virtual_address: Option<u64>,
|
pub virtual_address: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct ObjExtab {
|
||||||
|
pub func: ObjSymbol,
|
||||||
|
pub data: ExceptionTableData,
|
||||||
|
pub dtors: Vec<ObjSymbol>,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct ObjInfo {
|
pub struct ObjInfo {
|
||||||
pub arch: Box<dyn ObjArch>,
|
pub arch: Box<dyn ObjArch>,
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
@@ -130,6 +141,8 @@ pub struct ObjInfo {
|
|||||||
pub sections: Vec<ObjSection>,
|
pub sections: Vec<ObjSection>,
|
||||||
/// Common BSS symbols
|
/// Common BSS symbols
|
||||||
pub common: Vec<ObjSymbol>,
|
pub common: Vec<ObjSymbol>,
|
||||||
|
/// Exception tables
|
||||||
|
pub extab: Option<Vec<ObjExtab>>,
|
||||||
/// Split object metadata (.note.split section)
|
/// Split object metadata (.note.split section)
|
||||||
pub split_meta: Option<SplitMeta>,
|
pub split_meta: Option<SplitMeta>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ use std::{collections::HashSet, fs, io::Cursor, path::Path};
|
|||||||
|
|
||||||
use anyhow::{anyhow, bail, ensure, Context, Result};
|
use anyhow::{anyhow, bail, ensure, Context, Result};
|
||||||
use byteorder::{BigEndian, ReadBytesExt};
|
use byteorder::{BigEndian, ReadBytesExt};
|
||||||
|
use cwextab::decode_extab;
|
||||||
use filetime::FileTime;
|
use filetime::FileTime;
|
||||||
use flagset::Flags;
|
use flagset::Flags;
|
||||||
use object::{
|
use object::{
|
||||||
BinaryFormat, File, Object, ObjectSection, ObjectSymbol, RelocationTarget, SectionIndex,
|
Architecture, BinaryFormat, File, Object, ObjectSection, ObjectSymbol, RelocationTarget,
|
||||||
SectionKind, Symbol, SymbolKind, SymbolScope, SymbolSection,
|
SectionIndex, SectionKind, Symbol, SymbolKind, SymbolScope, SymbolSection,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -14,7 +15,8 @@ use crate::{
|
|||||||
diff::DiffObjConfig,
|
diff::DiffObjConfig,
|
||||||
obj::{
|
obj::{
|
||||||
split_meta::{SplitMeta, SPLITMETA_SECTION},
|
split_meta::{SplitMeta, SPLITMETA_SECTION},
|
||||||
ObjInfo, ObjReloc, ObjSection, ObjSectionKind, ObjSymbol, ObjSymbolFlagSet, ObjSymbolFlags,
|
ObjExtab, ObjInfo, ObjReloc, ObjSection, ObjSectionKind, ObjSymbol, ObjSymbolFlagSet,
|
||||||
|
ObjSymbolFlags,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,6 +73,9 @@ fn to_obj_symbol(
|
|||||||
Ok(ObjSymbol {
|
Ok(ObjSymbol {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
demangled_name,
|
demangled_name,
|
||||||
|
has_extab: false,
|
||||||
|
extab_name: None,
|
||||||
|
extabindex_name: None,
|
||||||
address,
|
address,
|
||||||
section_address,
|
section_address,
|
||||||
size: symbol.size(),
|
size: symbol.size(),
|
||||||
@@ -170,6 +175,111 @@ fn common_symbols(
|
|||||||
.collect::<Result<Vec<ObjSymbol>>>()
|
.collect::<Result<Vec<ObjSymbol>>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn section_by_name<'a>(sections: &'a mut [ObjSection], name: &str) -> Option<&'a mut ObjSection> {
|
||||||
|
sections.iter_mut().find(|section| section.name == name)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn exception_tables(
|
||||||
|
sections: &mut [ObjSection],
|
||||||
|
obj_file: &File<'_>,
|
||||||
|
) -> Result<Option<Vec<ObjExtab>>> {
|
||||||
|
//PowerPC only
|
||||||
|
if obj_file.architecture() != Architecture::PowerPc {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Find the extab/extabindex sections
|
||||||
|
let extab_section = match section_by_name(sections, "extab") {
|
||||||
|
Some(section) => section.clone(),
|
||||||
|
None => {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let extabindex_section = match section_by_name(sections, "extabindex") {
|
||||||
|
Some(section) => section.clone(),
|
||||||
|
None => {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let text_section = match section_by_name(sections, ".text") {
|
||||||
|
Some(section) => section,
|
||||||
|
None => bail!(".text section is somehow missing, this should not happen"),
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut result: Vec<ObjExtab> = vec![];
|
||||||
|
let extab_symbol_count = extab_section.symbols.len();
|
||||||
|
let extabindex_symbol_count = extabindex_section.symbols.len();
|
||||||
|
let extab_reloc_count = extab_section.relocations.len();
|
||||||
|
let table_count = extab_symbol_count;
|
||||||
|
let mut extab_reloc_index: usize = 0;
|
||||||
|
|
||||||
|
//Make sure that the number of symbols in the extab/extabindex section matches. If not, exit early
|
||||||
|
if extab_symbol_count != extabindex_symbol_count {
|
||||||
|
bail!("Extab/Extabindex symbol counts do not match");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Convert the extab/extabindex section data
|
||||||
|
|
||||||
|
//Go through each extabindex entry
|
||||||
|
for i in 0..table_count {
|
||||||
|
let extabindex = &extabindex_section.symbols[i];
|
||||||
|
|
||||||
|
/* Get the function symbol and extab symbol from the extabindex relocations array. Each extabindex
|
||||||
|
entry has two relocations (the first for the function, the second for the extab entry) */
|
||||||
|
let extab_func = extabindex_section.relocations[i * 2].target.clone();
|
||||||
|
let extab = &extabindex_section.relocations[(i * 2) + 1].target;
|
||||||
|
|
||||||
|
let extab_start_addr = extab.address;
|
||||||
|
let extab_end_addr = extab_start_addr + extab.size;
|
||||||
|
|
||||||
|
//Find the function in the text section, and set the has extab flag
|
||||||
|
for i in 0..text_section.symbols.len() {
|
||||||
|
let func = &mut text_section.symbols[i];
|
||||||
|
if func.name == extab_func.name {
|
||||||
|
func.has_extab = true;
|
||||||
|
func.extab_name = Some(extab.name.clone());
|
||||||
|
func.extabindex_name = Some(extabindex.name.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Iterate through the list of extab relocations, continuing until we hit a relocation
|
||||||
|
that isn't within the current extab symbol. Get the target dtor function symbol from
|
||||||
|
each relocation used, and add them to the list. */
|
||||||
|
let mut dtors: Vec<ObjSymbol> = vec![];
|
||||||
|
|
||||||
|
while extab_reloc_index < extab_reloc_count {
|
||||||
|
let extab_reloc = &extab_section.relocations[extab_reloc_index];
|
||||||
|
//If the current entry is past the current extab table, stop here
|
||||||
|
if extab_reloc.address >= extab_end_addr {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Otherwise, the current relocation is used by the current table
|
||||||
|
dtors.push(extab_reloc.target.clone());
|
||||||
|
//Go to the next entry
|
||||||
|
extab_reloc_index += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Decode the extab data
|
||||||
|
let start_index = extab_start_addr as usize;
|
||||||
|
let end_index = extab_end_addr as usize;
|
||||||
|
let extab_data = extab_section.data[start_index..end_index].try_into().unwrap();
|
||||||
|
let data = match decode_extab(extab_data) {
|
||||||
|
Some(decoded_data) => decoded_data,
|
||||||
|
None => {
|
||||||
|
log::warn!("Exception table decoding failed for function {}", extab_func.name);
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//Add the new entry to the list
|
||||||
|
let entry = ObjExtab { func: extab_func, data, dtors };
|
||||||
|
result.push(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Some(result))
|
||||||
|
}
|
||||||
|
|
||||||
fn find_section_symbol(
|
fn find_section_symbol(
|
||||||
arch: &dyn ObjArch,
|
arch: &dyn ObjArch,
|
||||||
obj_file: &File<'_>,
|
obj_file: &File<'_>,
|
||||||
@@ -205,6 +315,9 @@ fn find_section_symbol(
|
|||||||
Ok(ObjSymbol {
|
Ok(ObjSymbol {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
demangled_name: None,
|
demangled_name: None,
|
||||||
|
has_extab: false,
|
||||||
|
extab_name: None,
|
||||||
|
extabindex_name: None,
|
||||||
address: offset,
|
address: offset,
|
||||||
section_address: address - section.address(),
|
section_address: address - section.address(),
|
||||||
size: 0,
|
size: 0,
|
||||||
@@ -367,6 +480,9 @@ fn update_combined_symbol(symbol: ObjSymbol, address_change: i64) -> Result<ObjS
|
|||||||
Ok(ObjSymbol {
|
Ok(ObjSymbol {
|
||||||
name: symbol.name,
|
name: symbol.name,
|
||||||
demangled_name: symbol.demangled_name,
|
demangled_name: symbol.demangled_name,
|
||||||
|
has_extab: symbol.has_extab,
|
||||||
|
extab_name: symbol.extab_name,
|
||||||
|
extabindex_name: symbol.extabindex_name,
|
||||||
address: (symbol.address as i64 + address_change).try_into()?,
|
address: (symbol.address as i64 + address_change).try_into()?,
|
||||||
section_address: (symbol.section_address as i64 + address_change).try_into()?,
|
section_address: (symbol.section_address as i64 + address_change).try_into()?,
|
||||||
size: symbol.size,
|
size: symbol.size,
|
||||||
@@ -482,7 +598,8 @@ pub fn read(obj_path: &Path, config: &DiffObjConfig) -> Result<ObjInfo> {
|
|||||||
}
|
}
|
||||||
line_info(&obj_file, &mut sections)?;
|
line_info(&obj_file, &mut sections)?;
|
||||||
let common = common_symbols(arch.as_ref(), &obj_file, split_meta.as_ref())?;
|
let common = common_symbols(arch.as_ref(), &obj_file, split_meta.as_ref())?;
|
||||||
Ok(ObjInfo { arch, path: obj_path.to_owned(), timestamp, sections, common, split_meta })
|
let extab = exception_tables(&mut sections, &obj_file)?;
|
||||||
|
Ok(ObjInfo { arch, path: obj_path.to_owned(), timestamp, sections, common, extab, split_meta })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_function(obj_path: &Path, symbol_name: &str) -> Result<bool> {
|
pub fn has_function(obj_path: &Path, symbol_name: &str) -> Result<bool> {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "objdiff-gui"
|
name = "objdiff-gui"
|
||||||
version = "2.0.0-alpha.5"
|
version = "2.0.0-beta.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.70"
|
rust-version = "1.70"
|
||||||
authors = ["Luke Street <luke@street.dev>"]
|
authors = ["Luke Street <luke@street.dev>"]
|
||||||
@@ -29,6 +29,7 @@ bytes = "1.6.0"
|
|||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
const_format = "0.2.32"
|
const_format = "0.2.32"
|
||||||
cwdemangle = "1.0.0"
|
cwdemangle = "1.0.0"
|
||||||
|
cwextab = "0.2.3"
|
||||||
dirs = "5.0.1"
|
dirs = "5.0.1"
|
||||||
egui = "0.27.2"
|
egui = "0.27.2"
|
||||||
egui_extras = "0.27.2"
|
egui_extras = "0.27.2"
|
||||||
@@ -41,7 +42,9 @@ notify = { git = "https://github.com/encounter/notify", rev = "4c1783e8e041b5f69
|
|||||||
objdiff-core = { path = "../objdiff-core", features = ["all"] }
|
objdiff-core = { path = "../objdiff-core", features = ["all"] }
|
||||||
png = "0.17.13"
|
png = "0.17.13"
|
||||||
pollster = "0.3.0"
|
pollster = "0.3.0"
|
||||||
|
regex = "1.10.5"
|
||||||
rfd = { version = "0.14.1" } #, default-features = false, features = ['xdg-portal']
|
rfd = { version = "0.14.1" } #, default-features = false, features = ['xdg-portal']
|
||||||
|
rlwinmdec = "1.0.1"
|
||||||
ron = "0.8.1"
|
ron = "0.8.1"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1.0.116"
|
serde_json = "1.0.116"
|
||||||
|
|||||||
@@ -35,10 +35,12 @@ use crate::{
|
|||||||
data_diff::data_diff_ui,
|
data_diff::data_diff_ui,
|
||||||
debug::debug_window,
|
debug::debug_window,
|
||||||
demangle::{demangle_window, DemangleViewState},
|
demangle::{demangle_window, DemangleViewState},
|
||||||
|
extab_diff::extab_diff_ui,
|
||||||
frame_history::FrameHistory,
|
frame_history::FrameHistory,
|
||||||
function_diff::function_diff_ui,
|
function_diff::function_diff_ui,
|
||||||
graphics::{graphics_window, GraphicsConfig, GraphicsViewState},
|
graphics::{graphics_window, GraphicsConfig, GraphicsViewState},
|
||||||
jobs::jobs_ui,
|
jobs::jobs_ui,
|
||||||
|
rlwinm::{rlwinm_decode_window, RlwinmDecodeViewState},
|
||||||
symbol_diff::{symbol_diff_ui, DiffViewState, View},
|
symbol_diff::{symbol_diff_ui, DiffViewState, View},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -48,11 +50,13 @@ pub struct ViewState {
|
|||||||
pub jobs: JobQueue,
|
pub jobs: JobQueue,
|
||||||
pub config_state: ConfigViewState,
|
pub config_state: ConfigViewState,
|
||||||
pub demangle_state: DemangleViewState,
|
pub demangle_state: DemangleViewState,
|
||||||
|
pub rlwinm_decode_state: RlwinmDecodeViewState,
|
||||||
pub diff_state: DiffViewState,
|
pub diff_state: DiffViewState,
|
||||||
pub graphics_state: GraphicsViewState,
|
pub graphics_state: GraphicsViewState,
|
||||||
pub frame_history: FrameHistory,
|
pub frame_history: FrameHistory,
|
||||||
pub show_appearance_config: bool,
|
pub show_appearance_config: bool,
|
||||||
pub show_demangle: bool,
|
pub show_demangle: bool,
|
||||||
|
pub show_rlwinm_decode: bool,
|
||||||
pub show_project_config: bool,
|
pub show_project_config: bool,
|
||||||
pub show_arch_config: bool,
|
pub show_arch_config: bool,
|
||||||
pub show_debug: bool,
|
pub show_debug: bool,
|
||||||
@@ -450,11 +454,13 @@ impl eframe::App for App {
|
|||||||
jobs,
|
jobs,
|
||||||
config_state,
|
config_state,
|
||||||
demangle_state,
|
demangle_state,
|
||||||
|
rlwinm_decode_state,
|
||||||
diff_state,
|
diff_state,
|
||||||
graphics_state,
|
graphics_state,
|
||||||
frame_history,
|
frame_history,
|
||||||
show_appearance_config,
|
show_appearance_config,
|
||||||
show_demangle,
|
show_demangle,
|
||||||
|
show_rlwinm_decode,
|
||||||
show_project_config,
|
show_project_config,
|
||||||
show_arch_config,
|
show_arch_config,
|
||||||
show_debug,
|
show_debug,
|
||||||
@@ -513,6 +519,10 @@ impl eframe::App for App {
|
|||||||
*show_demangle = !*show_demangle;
|
*show_demangle = !*show_demangle;
|
||||||
ui.close_menu();
|
ui.close_menu();
|
||||||
}
|
}
|
||||||
|
if ui.button("Rlwinm Decoder…").clicked() {
|
||||||
|
*show_rlwinm_decode = !*show_rlwinm_decode;
|
||||||
|
ui.close_menu();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
ui.menu_button("Diff Options", |ui| {
|
ui.menu_button("Diff Options", |ui| {
|
||||||
if ui.button("Arch Settings…").clicked() {
|
if ui.button("Arch Settings…").clicked() {
|
||||||
@@ -582,6 +592,10 @@ impl eframe::App for App {
|
|||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
data_diff_ui(ui, diff_state, appearance);
|
data_diff_ui(ui, diff_state, appearance);
|
||||||
});
|
});
|
||||||
|
} else if diff_state.current_view == View::ExtabDiff && build_success {
|
||||||
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
|
extab_diff_ui(ui, diff_state, appearance);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
egui::SidePanel::left("side_panel").show(ctx, |ui| {
|
egui::SidePanel::left("side_panel").show(ctx, |ui| {
|
||||||
egui::ScrollArea::both().show(ui, |ui| {
|
egui::ScrollArea::both().show(ui, |ui| {
|
||||||
@@ -598,6 +612,7 @@ impl eframe::App for App {
|
|||||||
project_window(ctx, config, show_project_config, config_state, appearance);
|
project_window(ctx, config, show_project_config, config_state, appearance);
|
||||||
appearance_window(ctx, show_appearance_config, appearance);
|
appearance_window(ctx, show_appearance_config, appearance);
|
||||||
demangle_window(ctx, show_demangle, demangle_state, appearance);
|
demangle_window(ctx, show_demangle, demangle_state, appearance);
|
||||||
|
rlwinm_decode_window(ctx, show_rlwinm_decode, rlwinm_decode_state, appearance);
|
||||||
arch_config_window(ctx, config, show_arch_config, appearance);
|
arch_config_window(ctx, config, show_arch_config, appearance);
|
||||||
debug_window(ctx, show_debug, frame_history, appearance);
|
debug_window(ctx, show_debug, frame_history, appearance);
|
||||||
graphics_window(ctx, show_graphics, frame_history, graphics_state, appearance);
|
graphics_window(ctx, show_graphics, frame_history, graphics_state, appearance);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use egui::{
|
|||||||
use globset::Glob;
|
use globset::Glob;
|
||||||
use objdiff_core::{
|
use objdiff_core::{
|
||||||
config::{ProjectObject, DEFAULT_WATCH_PATTERNS},
|
config::{ProjectObject, DEFAULT_WATCH_PATTERNS},
|
||||||
diff::{ArmArchVersion, MipsAbi, MipsInstrCategory, X86Formatter},
|
diff::{ArmArchVersion, ArmR9Usage, MipsAbi, MipsInstrCategory, X86Formatter},
|
||||||
};
|
};
|
||||||
use self_update::cargo_crate_version;
|
use self_update::cargo_crate_version;
|
||||||
use strum::{EnumMessage, VariantArray};
|
use strum::{EnumMessage, VariantArray};
|
||||||
@@ -925,4 +925,51 @@ fn arch_config_ui(ui: &mut egui::Ui, config: &mut AppConfig, _appearance: &Appea
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
let response = ui
|
||||||
|
.checkbox(&mut config.diff_obj_config.arm_unified_syntax, "Unified syntax")
|
||||||
|
.on_hover_text("Disassemble as unified assembly language (UAL).");
|
||||||
|
if response.changed() {
|
||||||
|
config.queue_reload = true;
|
||||||
|
}
|
||||||
|
let response = ui
|
||||||
|
.checkbox(&mut config.diff_obj_config.arm_av_registers, "Use A/V registers")
|
||||||
|
.on_hover_text("Display R0-R3 as A1-A4 and R4-R11 as V1-V8");
|
||||||
|
if response.changed() {
|
||||||
|
config.queue_reload = true;
|
||||||
|
}
|
||||||
|
egui::ComboBox::new("arm_r9_usage", "Display R9 as")
|
||||||
|
.selected_text(config.diff_obj_config.arm_r9_usage.get_message().unwrap())
|
||||||
|
.show_ui(ui, |ui| {
|
||||||
|
for &usage in ArmR9Usage::VARIANTS {
|
||||||
|
if ui
|
||||||
|
.selectable_label(
|
||||||
|
config.diff_obj_config.arm_r9_usage == usage,
|
||||||
|
usage.get_message().unwrap(),
|
||||||
|
)
|
||||||
|
.on_hover_text(usage.get_detailed_message().unwrap())
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
config.diff_obj_config.arm_r9_usage = usage;
|
||||||
|
config.queue_reload = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let response = ui
|
||||||
|
.checkbox(&mut config.diff_obj_config.arm_sl_usage, "Display R10 as SL")
|
||||||
|
.on_hover_text("Used for explicit stack limits.");
|
||||||
|
if response.changed() {
|
||||||
|
config.queue_reload = true;
|
||||||
|
}
|
||||||
|
let response = ui
|
||||||
|
.checkbox(&mut config.diff_obj_config.arm_fp_usage, "Display R11 as FP")
|
||||||
|
.on_hover_text("Used for frame pointers.");
|
||||||
|
if response.changed() {
|
||||||
|
config.queue_reload = true;
|
||||||
|
}
|
||||||
|
let response = ui
|
||||||
|
.checkbox(&mut config.diff_obj_config.arm_ip_usage, "Display R12 as IP")
|
||||||
|
.on_hover_text("Used for interworking and long branches.");
|
||||||
|
if response.changed() {
|
||||||
|
config.queue_reload = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
218
objdiff-gui/src/views/extab_diff.rs
Normal file
218
objdiff-gui/src/views/extab_diff.rs
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
use egui::{text::LayoutJob, Align, Layout, ScrollArea, Ui, Vec2};
|
||||||
|
use egui_extras::{Size, StripBuilder};
|
||||||
|
use objdiff_core::{
|
||||||
|
diff::ObjDiff,
|
||||||
|
obj::{ObjExtab, ObjInfo, ObjSymbol, SymbolRef},
|
||||||
|
};
|
||||||
|
use time::format_description;
|
||||||
|
|
||||||
|
use crate::views::{
|
||||||
|
appearance::Appearance,
|
||||||
|
symbol_diff::{match_color_for_symbol, DiffViewState, SymbolRefByName, View},
|
||||||
|
};
|
||||||
|
|
||||||
|
fn find_symbol(obj: &ObjInfo, selected_symbol: &SymbolRefByName) -> Option<SymbolRef> {
|
||||||
|
for (section_idx, section) in obj.sections.iter().enumerate() {
|
||||||
|
for (symbol_idx, symbol) in section.symbols.iter().enumerate() {
|
||||||
|
if symbol.name == selected_symbol.symbol_name {
|
||||||
|
return Some(SymbolRef { section_idx, symbol_idx });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn decode_extab(extab: &ObjExtab) -> String {
|
||||||
|
let mut text = String::from("");
|
||||||
|
|
||||||
|
let mut dtor_names: Vec<&str> = vec![];
|
||||||
|
for dtor in &extab.dtors {
|
||||||
|
//For each function name, use the demangled name by default,
|
||||||
|
//and if not available fallback to the original name
|
||||||
|
let name = match &dtor.demangled_name {
|
||||||
|
Some(demangled_name) => demangled_name,
|
||||||
|
None => &dtor.name,
|
||||||
|
};
|
||||||
|
dtor_names.push(name.as_str());
|
||||||
|
}
|
||||||
|
if let Some(decoded) = extab.data.to_string(&dtor_names) {
|
||||||
|
text += decoded.as_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
text
|
||||||
|
}
|
||||||
|
|
||||||
|
fn find_extab_entry(obj: &ObjInfo, symbol: &ObjSymbol) -> Option<ObjExtab> {
|
||||||
|
if let Some(extab_array) = &obj.extab {
|
||||||
|
for extab_entry in extab_array {
|
||||||
|
if extab_entry.func.name == symbol.name {
|
||||||
|
return Some(extab_entry.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extab_text_ui(
|
||||||
|
ui: &mut Ui,
|
||||||
|
obj: &(ObjInfo, ObjDiff),
|
||||||
|
symbol_ref: SymbolRef,
|
||||||
|
appearance: &Appearance,
|
||||||
|
) -> Option<()> {
|
||||||
|
let (_section, symbol) = obj.0.section_symbol(symbol_ref);
|
||||||
|
|
||||||
|
if let Some(extab_entry) = find_extab_entry(&obj.0, symbol) {
|
||||||
|
let text = decode_extab(&extab_entry);
|
||||||
|
ui.colored_label(appearance.replace_color, &text);
|
||||||
|
return Some(());
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extab_ui(
|
||||||
|
ui: &mut Ui,
|
||||||
|
obj: Option<&(ObjInfo, ObjDiff)>,
|
||||||
|
selected_symbol: &SymbolRefByName,
|
||||||
|
appearance: &Appearance,
|
||||||
|
_left: bool,
|
||||||
|
) {
|
||||||
|
ScrollArea::both().auto_shrink([false, false]).show(ui, |ui| {
|
||||||
|
ui.scope(|ui| {
|
||||||
|
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
|
||||||
|
ui.style_mut().wrap = Some(false);
|
||||||
|
|
||||||
|
let symbol = obj.and_then(|(obj, _)| find_symbol(obj, selected_symbol));
|
||||||
|
|
||||||
|
if let (Some(object), Some(symbol_ref)) = (obj, symbol) {
|
||||||
|
extab_text_ui(ui, object, symbol_ref, appearance);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn extab_diff_ui(ui: &mut egui::Ui, state: &mut DiffViewState, appearance: &Appearance) {
|
||||||
|
let (Some(result), Some(selected_symbol)) = (&state.build, &state.symbol_state.selected_symbol)
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Header
|
||||||
|
let available_width = ui.available_width();
|
||||||
|
let column_width = available_width / 2.0;
|
||||||
|
ui.allocate_ui_with_layout(
|
||||||
|
Vec2 { x: available_width, y: 100.0 },
|
||||||
|
Layout::left_to_right(Align::Min),
|
||||||
|
|ui| {
|
||||||
|
// Left column
|
||||||
|
ui.allocate_ui_with_layout(
|
||||||
|
Vec2 { x: column_width, y: 100.0 },
|
||||||
|
Layout::top_down(Align::Min),
|
||||||
|
|ui| {
|
||||||
|
ui.set_width(column_width);
|
||||||
|
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
if ui.button("⏴ Back").clicked() {
|
||||||
|
state.current_view = View::SymbolDiff;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let name = selected_symbol
|
||||||
|
.demangled_symbol_name
|
||||||
|
.as_deref()
|
||||||
|
.unwrap_or(&selected_symbol.symbol_name);
|
||||||
|
let mut job = LayoutJob::simple(
|
||||||
|
name.to_string(),
|
||||||
|
appearance.code_font.clone(),
|
||||||
|
appearance.highlight_color,
|
||||||
|
column_width,
|
||||||
|
);
|
||||||
|
job.wrap.break_anywhere = true;
|
||||||
|
job.wrap.max_rows = 1;
|
||||||
|
ui.label(job);
|
||||||
|
|
||||||
|
ui.scope(|ui| {
|
||||||
|
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
|
||||||
|
ui.label("Diff target:");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// Right column
|
||||||
|
ui.allocate_ui_with_layout(
|
||||||
|
Vec2 { x: column_width, y: 100.0 },
|
||||||
|
Layout::top_down(Align::Min),
|
||||||
|
|ui| {
|
||||||
|
ui.set_width(column_width);
|
||||||
|
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
if ui
|
||||||
|
.add_enabled(!state.build_running, egui::Button::new("Build"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
state.queue_build = true;
|
||||||
|
}
|
||||||
|
ui.scope(|ui| {
|
||||||
|
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
|
||||||
|
ui.style_mut().wrap = Some(false);
|
||||||
|
if state.build_running {
|
||||||
|
ui.colored_label(appearance.replace_color, "Building…");
|
||||||
|
} else {
|
||||||
|
ui.label("Last built:");
|
||||||
|
let format =
|
||||||
|
format_description::parse("[hour]:[minute]:[second]").unwrap();
|
||||||
|
ui.label(
|
||||||
|
result
|
||||||
|
.time
|
||||||
|
.to_offset(appearance.utc_offset)
|
||||||
|
.format(&format)
|
||||||
|
.unwrap(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ui.scope(|ui| {
|
||||||
|
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
|
||||||
|
if let Some(match_percent) = result
|
||||||
|
.second_obj
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|(obj, diff)| {
|
||||||
|
find_symbol(obj, selected_symbol).map(|sref| {
|
||||||
|
&diff.sections[sref.section_idx].symbols[sref.symbol_idx]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.and_then(|symbol| symbol.match_percent)
|
||||||
|
{
|
||||||
|
ui.colored_label(
|
||||||
|
match_color_for_symbol(match_percent, appearance),
|
||||||
|
&format!("{match_percent:.0}%"),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ui.colored_label(appearance.replace_color, "Missing");
|
||||||
|
}
|
||||||
|
ui.label("Diff base:");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
ui.separator();
|
||||||
|
|
||||||
|
// Table
|
||||||
|
StripBuilder::new(ui).size(Size::remainder()).vertical(|mut strip| {
|
||||||
|
strip.strip(|builder| {
|
||||||
|
builder.sizes(Size::remainder(), 2).horizontal(|mut strip| {
|
||||||
|
strip.cell(|ui| {
|
||||||
|
extab_ui(ui, result.first_obj.as_ref(), selected_symbol, appearance, true);
|
||||||
|
});
|
||||||
|
strip.cell(|ui| {
|
||||||
|
extab_ui(ui, result.second_obj.as_ref(), selected_symbol, appearance, false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -5,11 +5,13 @@ pub(crate) mod config;
|
|||||||
pub(crate) mod data_diff;
|
pub(crate) mod data_diff;
|
||||||
pub(crate) mod debug;
|
pub(crate) mod debug;
|
||||||
pub(crate) mod demangle;
|
pub(crate) mod demangle;
|
||||||
|
pub(crate) mod extab_diff;
|
||||||
pub(crate) mod file;
|
pub(crate) mod file;
|
||||||
pub(crate) mod frame_history;
|
pub(crate) mod frame_history;
|
||||||
pub(crate) mod function_diff;
|
pub(crate) mod function_diff;
|
||||||
pub(crate) mod graphics;
|
pub(crate) mod graphics;
|
||||||
pub(crate) mod jobs;
|
pub(crate) mod jobs;
|
||||||
|
pub(crate) mod rlwinm;
|
||||||
pub(crate) mod symbol_diff;
|
pub(crate) mod symbol_diff;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
34
objdiff-gui/src/views/rlwinm.rs
Normal file
34
objdiff-gui/src/views/rlwinm.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use egui::TextStyle;
|
||||||
|
|
||||||
|
use crate::views::appearance::Appearance;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct RlwinmDecodeViewState {
|
||||||
|
pub text: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn rlwinm_decode_window(
|
||||||
|
ctx: &egui::Context,
|
||||||
|
show: &mut bool,
|
||||||
|
state: &mut RlwinmDecodeViewState,
|
||||||
|
appearance: &Appearance,
|
||||||
|
) {
|
||||||
|
egui::Window::new("Rlwinm Decoder").open(show).show(ctx, |ui| {
|
||||||
|
ui.text_edit_singleline(&mut state.text);
|
||||||
|
ui.add_space(10.0);
|
||||||
|
if let Some(demangled) = rlwinmdec::decode(&state.text) {
|
||||||
|
ui.scope(|ui| {
|
||||||
|
ui.style_mut().override_text_style = Some(TextStyle::Monospace);
|
||||||
|
ui.colored_label(appearance.replace_color, &demangled);
|
||||||
|
});
|
||||||
|
if ui.button("Copy").clicked() {
|
||||||
|
ui.output_mut(|output| output.copied_text = demangled);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ui.scope(|ui| {
|
||||||
|
ui.style_mut().override_text_style = Some(TextStyle::Monospace);
|
||||||
|
ui.colored_label(appearance.replace_color, "[invalid]");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ use objdiff_core::{
|
|||||||
diff::{ObjDiff, ObjSymbolDiff},
|
diff::{ObjDiff, ObjSymbolDiff},
|
||||||
obj::{ObjInfo, ObjSection, ObjSectionKind, ObjSymbol, ObjSymbolFlags, SymbolRef},
|
obj::{ObjInfo, ObjSection, ObjSectionKind, ObjSymbol, ObjSymbolFlags, SymbolRef},
|
||||||
};
|
};
|
||||||
|
use regex::{Regex, RegexBuilder};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::AppConfigRef,
|
app::AppConfigRef,
|
||||||
@@ -33,6 +34,7 @@ pub enum View {
|
|||||||
SymbolDiff,
|
SymbolDiff,
|
||||||
FunctionDiff,
|
FunctionDiff,
|
||||||
DataDiff,
|
DataDiff,
|
||||||
|
ExtabDiff,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@@ -43,6 +45,7 @@ pub struct DiffViewState {
|
|||||||
pub symbol_state: SymbolViewState,
|
pub symbol_state: SymbolViewState,
|
||||||
pub function_state: FunctionViewState,
|
pub function_state: FunctionViewState,
|
||||||
pub search: String,
|
pub search: String,
|
||||||
|
pub search_regex: Option<Regex>,
|
||||||
pub queue_build: bool,
|
pub queue_build: bool,
|
||||||
pub build_running: bool,
|
pub build_running: bool,
|
||||||
pub scratch_available: bool,
|
pub scratch_available: bool,
|
||||||
@@ -57,6 +60,7 @@ pub struct SymbolViewState {
|
|||||||
pub reverse_fn_order: bool,
|
pub reverse_fn_order: bool,
|
||||||
pub disable_reverse_fn_order: bool,
|
pub disable_reverse_fn_order: bool,
|
||||||
pub show_hidden_symbols: bool,
|
pub show_hidden_symbols: bool,
|
||||||
|
pub queue_extab_decode: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DiffViewState {
|
impl DiffViewState {
|
||||||
@@ -131,7 +135,12 @@ pub fn match_color_for_symbol(match_percent: f32, appearance: &Appearance) -> Co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn symbol_context_menu_ui(ui: &mut Ui, symbol: &ObjSymbol) {
|
fn symbol_context_menu_ui(
|
||||||
|
ui: &mut Ui,
|
||||||
|
state: &mut SymbolViewState,
|
||||||
|
symbol: &ObjSymbol,
|
||||||
|
section: Option<&ObjSection>,
|
||||||
|
) {
|
||||||
ui.scope(|ui| {
|
ui.scope(|ui| {
|
||||||
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
|
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
|
||||||
ui.style_mut().wrap = Some(false);
|
ui.style_mut().wrap = Some(false);
|
||||||
@@ -152,6 +161,17 @@ fn symbol_context_menu_ui(ui: &mut Ui, symbol: &ObjSymbol) {
|
|||||||
ui.close_menu();
|
ui.close_menu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Some(section) = section {
|
||||||
|
if symbol.has_extab && ui.button("Decode exception table").clicked() {
|
||||||
|
state.queue_extab_decode = true;
|
||||||
|
state.selected_symbol = Some(SymbolRefByName {
|
||||||
|
symbol_name: symbol.name.clone(),
|
||||||
|
demangled_symbol_name: symbol.demangled_name.clone(),
|
||||||
|
section_name: section.name.clone(),
|
||||||
|
});
|
||||||
|
ui.close_menu();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +193,20 @@ fn symbol_hover_ui(ui: &mut Ui, symbol: &ObjSymbol, appearance: &Appearance) {
|
|||||||
if let Some(address) = symbol.virtual_address {
|
if let Some(address) = symbol.virtual_address {
|
||||||
ui.colored_label(appearance.replace_color, format!("Virtual address: {:#x}", address));
|
ui.colored_label(appearance.replace_color, format!("Virtual address: {:#x}", address));
|
||||||
}
|
}
|
||||||
|
if symbol.has_extab {
|
||||||
|
if let (Some(extab_name), Some(extabindex_name)) =
|
||||||
|
(&symbol.extab_name, &symbol.extabindex_name)
|
||||||
|
{
|
||||||
|
ui.colored_label(
|
||||||
|
appearance.highlight_color,
|
||||||
|
format!("Extab Symbol: {}", extab_name),
|
||||||
|
);
|
||||||
|
ui.colored_label(
|
||||||
|
appearance.highlight_color,
|
||||||
|
format!("Extabindex Symbol: {}", extabindex_name),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +262,7 @@ fn symbol_ui(
|
|||||||
let response = SelectableLabel::new(selected, job)
|
let response = SelectableLabel::new(selected, job)
|
||||||
.ui(ui)
|
.ui(ui)
|
||||||
.on_hover_ui_at_pointer(|ui| symbol_hover_ui(ui, symbol, appearance));
|
.on_hover_ui_at_pointer(|ui| symbol_hover_ui(ui, symbol, appearance));
|
||||||
response.context_menu(|ui| symbol_context_menu_ui(ui, symbol));
|
response.context_menu(|ui| symbol_context_menu_ui(ui, state, symbol, section));
|
||||||
if response.clicked() {
|
if response.clicked() {
|
||||||
if let Some(section) = section {
|
if let Some(section) = section {
|
||||||
if section.kind == ObjSectionKind::Code {
|
if section.kind == ObjSectionKind::Code {
|
||||||
@@ -258,17 +292,23 @@ fn symbol_ui(
|
|||||||
(None, None)
|
(None, None)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If the decode extab context menu option was clicked, switch to the extab view
|
||||||
|
if state.queue_extab_decode {
|
||||||
|
ret = Some(View::ExtabDiff);
|
||||||
|
state.queue_extab_decode = false;
|
||||||
|
}
|
||||||
|
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
fn symbol_matches_search(symbol: &ObjSymbol, search_str: &str) -> bool {
|
fn symbol_matches_search(symbol: &ObjSymbol, search_regex: Option<&Regex>) -> bool {
|
||||||
search_str.is_empty()
|
if let Some(search_regex) = search_regex {
|
||||||
|| symbol.name.contains(search_str)
|
search_regex.is_match(&symbol.name)
|
||||||
|| symbol
|
|| symbol.demangled_name.as_ref().map(|s| search_regex.is_match(s)).unwrap_or(false)
|
||||||
.demangled_name
|
} else {
|
||||||
.as_ref()
|
true
|
||||||
.map(|s| s.to_ascii_lowercase().contains(search_str))
|
}
|
||||||
.unwrap_or(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
@@ -276,7 +316,7 @@ fn symbol_list_ui(
|
|||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
obj: &(ObjInfo, ObjDiff),
|
obj: &(ObjInfo, ObjDiff),
|
||||||
state: &mut SymbolViewState,
|
state: &mut SymbolViewState,
|
||||||
lower_search: &str,
|
search_regex: Option<&Regex>,
|
||||||
appearance: &Appearance,
|
appearance: &Appearance,
|
||||||
left: bool,
|
left: bool,
|
||||||
) -> Option<View> {
|
) -> Option<View> {
|
||||||
@@ -289,6 +329,9 @@ fn symbol_list_ui(
|
|||||||
if !obj.0.common.is_empty() {
|
if !obj.0.common.is_empty() {
|
||||||
CollapsingHeader::new(".comm").default_open(true).show(ui, |ui| {
|
CollapsingHeader::new(".comm").default_open(true).show(ui, |ui| {
|
||||||
for (symbol, symbol_diff) in obj.0.common.iter().zip(&obj.1.common) {
|
for (symbol, symbol_diff) in obj.0.common.iter().zip(&obj.1.common) {
|
||||||
|
if !symbol_matches_search(symbol, search_regex) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
ret = ret.or(symbol_ui(
|
ret = ret.or(symbol_ui(
|
||||||
ui,
|
ui,
|
||||||
symbol,
|
symbol,
|
||||||
@@ -336,7 +379,7 @@ fn symbol_list_ui(
|
|||||||
for (symbol, symbol_diff) in
|
for (symbol, symbol_diff) in
|
||||||
section.symbols.iter().zip(§ion_diff.symbols).rev()
|
section.symbols.iter().zip(§ion_diff.symbols).rev()
|
||||||
{
|
{
|
||||||
if !symbol_matches_search(symbol, lower_search) {
|
if !symbol_matches_search(symbol, search_regex) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ret = ret.or(symbol_ui(
|
ret = ret.or(symbol_ui(
|
||||||
@@ -353,7 +396,7 @@ fn symbol_list_ui(
|
|||||||
for (symbol, symbol_diff) in
|
for (symbol, symbol_diff) in
|
||||||
section.symbols.iter().zip(§ion_diff.symbols)
|
section.symbols.iter().zip(§ion_diff.symbols)
|
||||||
{
|
{
|
||||||
if !symbol_matches_search(symbol, lower_search) {
|
if !symbol_matches_search(symbol, search_regex) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ret = ret.or(symbol_ui(
|
ret = ret.or(symbol_ui(
|
||||||
@@ -407,7 +450,7 @@ fn missing_obj_ui(ui: &mut Ui, appearance: &Appearance) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn symbol_diff_ui(ui: &mut Ui, state: &mut DiffViewState, appearance: &Appearance) {
|
pub fn symbol_diff_ui(ui: &mut Ui, state: &mut DiffViewState, appearance: &Appearance) {
|
||||||
let DiffViewState { build, current_view, symbol_state, search, .. } = state;
|
let DiffViewState { build, current_view, symbol_state, search, search_regex, .. } = state;
|
||||||
let Some(result) = build else {
|
let Some(result) = build else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@@ -442,7 +485,17 @@ pub fn symbol_diff_ui(ui: &mut Ui, state: &mut DiffViewState, appearance: &Appea
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
TextEdit::singleline(search).hint_text("Filter symbols").ui(ui);
|
if TextEdit::singleline(search).hint_text("Filter symbols").ui(ui).changed() {
|
||||||
|
if search.is_empty() {
|
||||||
|
*search_regex = None;
|
||||||
|
} else if let Ok(regex) =
|
||||||
|
RegexBuilder::new(search).case_insensitive(true).build()
|
||||||
|
{
|
||||||
|
*search_regex = Some(regex);
|
||||||
|
} else {
|
||||||
|
*search_regex = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -480,7 +533,6 @@ pub fn symbol_diff_ui(ui: &mut Ui, state: &mut DiffViewState, appearance: &Appea
|
|||||||
|
|
||||||
// Table
|
// Table
|
||||||
let mut ret = None;
|
let mut ret = None;
|
||||||
let lower_search = search.to_ascii_lowercase();
|
|
||||||
StripBuilder::new(ui).size(Size::remainder()).vertical(|mut strip| {
|
StripBuilder::new(ui).size(Size::remainder()).vertical(|mut strip| {
|
||||||
strip.strip(|builder| {
|
strip.strip(|builder| {
|
||||||
builder.sizes(Size::remainder(), 2).horizontal(|mut strip| {
|
builder.sizes(Size::remainder(), 2).horizontal(|mut strip| {
|
||||||
@@ -492,7 +544,7 @@ pub fn symbol_diff_ui(ui: &mut Ui, state: &mut DiffViewState, appearance: &Appea
|
|||||||
ui,
|
ui,
|
||||||
obj,
|
obj,
|
||||||
symbol_state,
|
symbol_state,
|
||||||
&lower_search,
|
search_regex.as_ref(),
|
||||||
appearance,
|
appearance,
|
||||||
true,
|
true,
|
||||||
));
|
));
|
||||||
@@ -512,7 +564,7 @@ pub fn symbol_diff_ui(ui: &mut Ui, state: &mut DiffViewState, appearance: &Appea
|
|||||||
ui,
|
ui,
|
||||||
obj,
|
obj,
|
||||||
symbol_state,
|
symbol_state,
|
||||||
&lower_search,
|
search_regex.as_ref(),
|
||||||
appearance,
|
appearance,
|
||||||
false,
|
false,
|
||||||
));
|
));
|
||||||
|
|||||||
Reference in New Issue
Block a user