mirror of
https://github.com/encounter/objdiff.git
synced 2025-12-17 08:57:25 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c02eb31dbb | |||
|
|
86d92866aa | ||
| 51c3af2bbe | |||
|
|
d0b8b449d9 | ||
|
|
32f5f202f7 | ||
|
|
481dbc185a |
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -3491,7 +3491,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objdiff-cli"
|
name = "objdiff-cli"
|
||||||
version = "3.4.3"
|
version = "3.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"argp",
|
"argp",
|
||||||
@@ -3514,7 +3514,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objdiff-core"
|
name = "objdiff-core"
|
||||||
version = "3.4.3"
|
version = "3.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"arm-attr",
|
"arm-attr",
|
||||||
@@ -3570,7 +3570,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objdiff-gui"
|
name = "objdiff-gui"
|
||||||
version = "3.4.3"
|
version = "3.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"argp",
|
"argp",
|
||||||
@@ -3608,7 +3608,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objdiff-wasm"
|
name = "objdiff-wasm"
|
||||||
version = "3.4.3"
|
version = "3.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"objdiff-core",
|
"objdiff-core",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ default-members = [
|
|||||||
resolver = "3"
|
resolver = "3"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "3.4.3"
|
version = "3.4.5"
|
||||||
authors = ["Luke Street <luke@street.dev>"]
|
authors = ["Luke Street <luke@street.dev>"]
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
|||||||
@@ -345,7 +345,10 @@ impl Arch for ArchArm {
|
|||||||
let address = address as usize;
|
let address = address as usize;
|
||||||
let addend = match r_type {
|
let addend = match r_type {
|
||||||
// ARM calls
|
// ARM calls
|
||||||
elf::R_ARM_PC24 | elf::R_ARM_XPC25 | elf::R_ARM_CALL => {
|
elf::R_ARM_PC24
|
||||||
|
| elf::R_ARM_XPC25
|
||||||
|
| elf::R_ARM_CALL
|
||||||
|
| elf::R_ARM_JUMP24 => {
|
||||||
let data = section_data[address..address + 4].try_into()?;
|
let data = section_data[address..address + 4].try_into()?;
|
||||||
let addend = self.endianness.read_i32_bytes(data);
|
let addend = self.endianness.read_i32_bytes(data);
|
||||||
let imm24 = addend & 0xffffff;
|
let imm24 = addend & 0xffffff;
|
||||||
|
|||||||
@@ -7,12 +7,10 @@ use alloc::{
|
|||||||
};
|
};
|
||||||
use core::{
|
use core::{
|
||||||
any::Any,
|
any::Any,
|
||||||
ffi::CStr,
|
|
||||||
fmt::{self, Debug},
|
fmt::{self, Debug},
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{Result, bail};
|
use anyhow::{Result, bail};
|
||||||
use encoding_rs::SHIFT_JIS;
|
|
||||||
use object::Endian as _;
|
use object::Endian as _;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -44,6 +42,16 @@ pub mod x86;
|
|||||||
pub const OPCODE_INVALID: u16 = u16::MAX;
|
pub const OPCODE_INVALID: u16 = u16::MAX;
|
||||||
pub const OPCODE_DATA: u16 = u16::MAX - 1;
|
pub const OPCODE_DATA: u16 = u16::MAX - 1;
|
||||||
|
|
||||||
|
const SUPPORTED_ENCODINGS: [(&encoding_rs::Encoding, &str); 7] = [
|
||||||
|
(encoding_rs::UTF_8, "UTF-8"),
|
||||||
|
(encoding_rs::SHIFT_JIS, "Shift JIS"),
|
||||||
|
(encoding_rs::UTF_16BE, "UTF-16BE"),
|
||||||
|
(encoding_rs::UTF_16LE, "UTF-16LE"),
|
||||||
|
(encoding_rs::WINDOWS_1252, "Windows-1252"),
|
||||||
|
(encoding_rs::EUC_JP, "EUC-JP"),
|
||||||
|
(encoding_rs::BIG5, "Big5"),
|
||||||
|
];
|
||||||
|
|
||||||
/// Represents the type of data associated with an instruction
|
/// Represents the type of data associated with an instruction
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub enum DataType {
|
pub enum DataType {
|
||||||
@@ -77,7 +85,7 @@ impl DataType {
|
|||||||
let mut strs = Vec::new();
|
let mut strs = Vec::new();
|
||||||
for (literal, label_override) in self.display_literals(endian, bytes) {
|
for (literal, label_override) in self.display_literals(endian, bytes) {
|
||||||
let label = label_override.unwrap_or_else(|| self.to_string());
|
let label = label_override.unwrap_or_else(|| self.to_string());
|
||||||
strs.push(format!("{label}: {literal}"))
|
strs.push(format!("{label}: {literal:?}"))
|
||||||
}
|
}
|
||||||
strs
|
strs
|
||||||
}
|
}
|
||||||
@@ -164,16 +172,18 @@ impl DataType {
|
|||||||
strs.push((format!("{bytes:#?}"), None));
|
strs.push((format!("{bytes:#?}"), None));
|
||||||
}
|
}
|
||||||
DataType::String => {
|
DataType::String => {
|
||||||
if let Ok(cstr) = CStr::from_bytes_until_nul(bytes) {
|
|
||||||
strs.push((format!("{cstr:?}"), None));
|
|
||||||
}
|
|
||||||
if let Some(nul_idx) = bytes.iter().position(|&c| c == b'\0') {
|
if let Some(nul_idx) = bytes.iter().position(|&c| c == b'\0') {
|
||||||
let (cow, _, had_errors) = SHIFT_JIS.decode(&bytes[..nul_idx]);
|
let str_bytes = &bytes[..nul_idx];
|
||||||
if !had_errors {
|
// Special case to display (ASCII) as the label for ASCII-only strings.
|
||||||
let str = format!("{cow:?}");
|
let (cow, _, had_errors) = encoding_rs::UTF_8.decode(str_bytes);
|
||||||
// Only add the Shift JIS string if it's different from the ASCII string.
|
if !had_errors && cow.is_ascii() {
|
||||||
if !strs.iter().any(|x| x.0 == str) {
|
strs.push((format!("{cow}"), Some("ASCII".into())));
|
||||||
strs.push((str, Some("Shift JIS".into())));
|
}
|
||||||
|
for (encoding, encoding_name) in SUPPORTED_ENCODINGS {
|
||||||
|
let (cow, _, had_errors) = encoding.decode(str_bytes);
|
||||||
|
// Avoid showing ASCII-only strings more than once if the encoding is ASCII-compatible.
|
||||||
|
if !had_errors && (!encoding.is_ascii_compatible() || !cow.is_ascii()) {
|
||||||
|
strs.push((format!("{cow}"), Some(encoding_name.into())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -588,6 +588,7 @@ fn symbols_matching_section(
|
|||||||
s.section == Some(section_idx)
|
s.section == Some(section_idx)
|
||||||
&& s.kind != SymbolKind::Section
|
&& s.kind != SymbolKind::Section
|
||||||
&& s.size > 0
|
&& s.size > 0
|
||||||
|
&& !s.flags.contains(SymbolFlag::Hidden)
|
||||||
&& !s.flags.contains(SymbolFlag::Ignored)
|
&& !s.flags.contains(SymbolFlag::Ignored)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -668,7 +668,7 @@ pub fn instruction_hover(
|
|||||||
for (literal, label_override) in literals {
|
for (literal, label_override) in literals {
|
||||||
out.push(HoverItem::Text {
|
out.push(HoverItem::Text {
|
||||||
label: label_override.unwrap_or_else(|| ty.to_string()),
|
label: label_override.unwrap_or_else(|| ty.to_string()),
|
||||||
value: literal,
|
value: format!("{literal:?}"),
|
||||||
color: HoverItemColor::Normal,
|
color: HoverItemColor::Normal,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,19 +69,19 @@ Object {
|
|||||||
action_param: 0,
|
action_param: 0,
|
||||||
has_end_bit: true,
|
has_end_bit: true,
|
||||||
bytes: [
|
bytes: [
|
||||||
130,
|
|
||||||
0,
|
|
||||||
0,
|
0,
|
||||||
8,
|
8,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
relocations: [
|
relocations: [
|
||||||
Relocation {
|
Relocation {
|
||||||
offset: 18,
|
offset: 20,
|
||||||
address: 524288,
|
address: 0,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -871,19 +871,13 @@ pub fn context_menu_items_ui(
|
|||||||
match item {
|
match item {
|
||||||
ContextItem::Copy { value, label } => {
|
ContextItem::Copy { value, label } => {
|
||||||
let mut job = LayoutJob::default();
|
let mut job = LayoutJob::default();
|
||||||
|
write_text("Copy ", appearance.text_color, &mut job, appearance.code_font.clone());
|
||||||
write_text(
|
write_text(
|
||||||
"Copy \"",
|
&format!("{value:?}"),
|
||||||
appearance.text_color,
|
|
||||||
&mut job,
|
|
||||||
appearance.code_font.clone(),
|
|
||||||
);
|
|
||||||
write_text(
|
|
||||||
&value,
|
|
||||||
appearance.highlight_color,
|
appearance.highlight_color,
|
||||||
&mut job,
|
&mut job,
|
||||||
appearance.code_font.clone(),
|
appearance.code_font.clone(),
|
||||||
);
|
);
|
||||||
write_text("\"", appearance.text_color, &mut job, appearance.code_font.clone());
|
|
||||||
if let Some(label) = label {
|
if let Some(label) = label {
|
||||||
write_text(" (", appearance.text_color, &mut job, appearance.code_font.clone());
|
write_text(" (", appearance.text_color, &mut job, appearance.code_font.clone());
|
||||||
write_text(
|
write_text(
|
||||||
|
|||||||
8
objdiff-wasm/package-lock.json
generated
8
objdiff-wasm/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "objdiff-wasm",
|
"name": "objdiff-wasm",
|
||||||
"version": "3.4.3",
|
"version": "3.4.5",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "objdiff-wasm",
|
"name": "objdiff-wasm",
|
||||||
"version": "3.4.3",
|
"version": "3.4.5",
|
||||||
"license": "MIT OR Apache-2.0",
|
"license": "MIT OR Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^1.9.3",
|
"@biomejs/biome": "^1.9.3",
|
||||||
@@ -852,7 +852,6 @@
|
|||||||
"integrity": "sha512-Y3b4Y7lGIvNPywspP38deHkp/EEkTXrJEHeX1K5yz8U/94PkWvPlDebjjiSvmI6TT+9iVzsq22qDlBEdDuJZhA==",
|
"integrity": "sha512-Y3b4Y7lGIvNPywspP38deHkp/EEkTXrJEHeX1K5yz8U/94PkWvPlDebjjiSvmI6TT+9iVzsq22qDlBEdDuJZhA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rspack/core": "1.2.3",
|
"@rspack/core": "1.2.3",
|
||||||
"@rspack/lite-tapable": "~1.0.1",
|
"@rspack/lite-tapable": "~1.0.1",
|
||||||
@@ -1084,7 +1083,6 @@
|
|||||||
"integrity": "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==",
|
"integrity": "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tslib": "^2.8.0"
|
"tslib": "^2.8.0"
|
||||||
}
|
}
|
||||||
@@ -2141,7 +2139,6 @@
|
|||||||
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
@@ -2169,7 +2166,6 @@
|
|||||||
"integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
|
"integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"peer": true,
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "objdiff-wasm",
|
"name": "objdiff-wasm",
|
||||||
"version": "3.4.3",
|
"version": "3.4.5",
|
||||||
"description": "A local diffing tool for decompilation projects.",
|
"description": "A local diffing tool for decompilation projects.",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Luke Street",
|
"name": "Luke Street",
|
||||||
|
|||||||
Reference in New Issue
Block a user