Skip to content

Commit 424434e

Browse files
committed
Experimental ARM64 support
Based on yaxpeax-arm, but with a heavy dose of custom code to work around its limitations. Please report any issues or unhandled relocations.
1 parent 7f14b68 commit 424434e

File tree

13 files changed

+2930
-20
lines changed

13 files changed

+2930
-20
lines changed

Cargo.lock

Lines changed: 63 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ strip = "debuginfo"
1313
codegen-units = 1
1414

1515
[workspace.package]
16-
version = "2.3.4"
16+
version = "2.4.0"
1717
authors = ["Luke Street <luke@street.dev>"]
1818
edition = "2021"
1919
license = "MIT OR Apache-2.0"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Supports:
2020
- MIPS (N64, PS1, PS2, PSP)
2121
- x86 (COFF only at the moment)
2222
- ARM (GBA, DS, 3DS)
23+
- ARM64 (Switch, experimental)
2324

2425
See [Usage](#usage) for more information.
2526

objdiff-core/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ documentation = "https://docs.rs/objdiff-core"
1616
crate-type = ["cdylib", "rlib"]
1717

1818
[features]
19-
all = ["config", "dwarf", "mips", "ppc", "x86", "arm", "bindings"]
19+
all = ["config", "dwarf", "mips", "ppc", "x86", "arm", "arm64", "bindings"]
2020
any-arch = ["config", "dep:bimap", "dep:strum", "dep:similar", "dep:flagset", "dep:log", "dep:memmap2", "dep:byteorder", "dep:num-traits"] # Implicit, used to check if any arch is enabled
2121
config = ["dep:bimap", "dep:globset", "dep:semver", "dep:serde_json", "dep:serde_yaml", "dep:serde", "dep:filetime"]
2222
dwarf = ["dep:gimli"]
2323
mips = ["any-arch", "dep:rabbitizer"]
2424
ppc = ["any-arch", "dep:cwdemangle", "dep:cwextab", "dep:ppc750cl"]
2525
x86 = ["any-arch", "dep:cpp_demangle", "dep:iced-x86", "dep:msvc-demangler"]
2626
arm = ["any-arch", "dep:cpp_demangle", "dep:unarm", "dep:arm-attr"]
27+
arm64 = ["any-arch", "dep:cpp_demangle", "dep:yaxpeax-arch", "dep:yaxpeax-arm"]
2728
bindings = ["dep:serde_json", "dep:prost", "dep:pbjson", "dep:serde", "dep:prost-build", "dep:pbjson-build"]
2829
wasm = ["bindings", "any-arch", "dep:console_error_panic_hook", "dep:console_log", "dep:wasm-bindgen", "dep:tsify-next", "dep:log"]
2930

@@ -76,6 +77,10 @@ msvc-demangler = { version = "0.10", optional = true }
7677
unarm = { version = "1.6", optional = true }
7778
arm-attr = { version = "0.1", optional = true }
7879

80+
# arm64
81+
yaxpeax-arch = { version = "0.3", default-features = false, features = ["std"], optional = true }
82+
yaxpeax-arm = { version = "0.3", default-features = false, features = ["std"], optional = true }
83+
7984
[build-dependencies]
8085
prost-build = { version = "0.13", optional = true }
8186
pbjson-build = { version = "0.7", optional = true }

objdiff-core/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ objdiff-core contains the core functionality of [objdiff](https://github.com/enc
1111
- **`ppc`**: Enables the PowerPC backend powered by [ppc750cl](https://github.com/encounter/ppc750cl).
1212
- **`x86`**: Enables the x86 backend powered by [iced-x86](https://crates.io/crates/iced-x86).
1313
- **`arm`**: Enables the ARM backend powered by [unarm](https://github.com/AetiasHax/unarm).
14+
- **`arm64`**: Enables the ARM64 backend powered by [yaxpeax-arm](https://github.com/iximeow/yaxpeax-arm).
1415
- **`bindings`**: Enables serialization and deserialization of objdiff data structures.

objdiff-core/src/arch/arm.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,9 @@ impl ObjArch for ObjArchArm {
124124
.get(&SectionIndex(section_index))
125125
.map(|x| x.as_slice())
126126
.unwrap_or(&fallback_mappings);
127-
let first_mapping_idx =
128-
match mapping_symbols.binary_search_by_key(&start_addr, |x| x.address) {
129-
Ok(idx) => idx,
130-
Err(idx) => idx - 1,
131-
};
127+
let first_mapping_idx = mapping_symbols
128+
.binary_search_by_key(&start_addr, |x| x.address)
129+
.unwrap_or_else(|idx| idx - 1);
132130
let first_mapping = mapping_symbols[first_mapping_idx].mapping;
133131

134132
let mut mappings_iter =
@@ -215,7 +213,7 @@ impl ObjArch for ObjArchArm {
215213
address: address as u64,
216214
size: (parser.address - address) as u8,
217215
op: ins.opcode_id(),
218-
mnemonic: parsed_ins.mnemonic.to_string(),
216+
mnemonic: Cow::Borrowed(parsed_ins.mnemonic),
219217
args,
220218
reloc,
221219
branch_dest,
@@ -234,7 +232,7 @@ impl ObjArch for ObjArchArm {
234232
section: &ObjSection,
235233
address: u64,
236234
reloc: &Relocation,
237-
) -> anyhow::Result<i64> {
235+
) -> Result<i64> {
238236
let address = address as usize;
239237
Ok(match reloc.flags() {
240238
// ARM calls

0 commit comments

Comments
 (0)