Skip to content

Commit 09aa52d

Browse files
committed
WIP ARM64 support
1 parent 21f8f24 commit 09aa52d

File tree

10 files changed

+2340
-16
lines changed

10 files changed

+2340
-16
lines changed

Cargo.lock

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

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", optional = true }
82+
yaxpeax-arm = { version = "0.3", optional = true }
83+
7984
[build-dependencies]
8085
prost-build = { version = "0.13", optional = true }
8186
pbjson-build = { version = "0.7", optional = true }

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)