Skip to content

Commit

Permalink
WIP ARM64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
encounter committed Oct 31, 2024
1 parent 21f8f24 commit 09aa52d
Show file tree
Hide file tree
Showing 10 changed files with 2,340 additions and 16 deletions.
64 changes: 64 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion objdiff-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ documentation = "https://docs.rs/objdiff-core"
crate-type = ["cdylib", "rlib"]

[features]
all = ["config", "dwarf", "mips", "ppc", "x86", "arm", "bindings"]
all = ["config", "dwarf", "mips", "ppc", "x86", "arm", "arm64", "bindings"]
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
config = ["dep:bimap", "dep:globset", "dep:semver", "dep:serde_json", "dep:serde_yaml", "dep:serde", "dep:filetime"]
dwarf = ["dep:gimli"]
mips = ["any-arch", "dep:rabbitizer"]
ppc = ["any-arch", "dep:cwdemangle", "dep:cwextab", "dep:ppc750cl"]
x86 = ["any-arch", "dep:cpp_demangle", "dep:iced-x86", "dep:msvc-demangler"]
arm = ["any-arch", "dep:cpp_demangle", "dep:unarm", "dep:arm-attr"]
arm64 = ["any-arch", "dep:cpp_demangle", "dep:yaxpeax-arch", "dep:yaxpeax-arm"]
bindings = ["dep:serde_json", "dep:prost", "dep:pbjson", "dep:serde", "dep:prost-build", "dep:pbjson-build"]
wasm = ["bindings", "any-arch", "dep:console_error_panic_hook", "dep:console_log", "dep:wasm-bindgen", "dep:tsify-next", "dep:log"]

Expand Down Expand Up @@ -76,6 +77,10 @@ msvc-demangler = { version = "0.10", optional = true }
unarm = { version = "1.6", optional = true }
arm-attr = { version = "0.1", optional = true }

# arm64
yaxpeax-arch = { version = "0.3", optional = true }
yaxpeax-arm = { version = "0.3", optional = true }

[build-dependencies]
prost-build = { version = "0.13", optional = true }
pbjson-build = { version = "0.7", optional = true }
12 changes: 5 additions & 7 deletions objdiff-core/src/arch/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,9 @@ impl ObjArch for ObjArchArm {
.get(&SectionIndex(section_index))
.map(|x| x.as_slice())
.unwrap_or(&fallback_mappings);
let first_mapping_idx =
match mapping_symbols.binary_search_by_key(&start_addr, |x| x.address) {
Ok(idx) => idx,
Err(idx) => idx - 1,
};
let first_mapping_idx = mapping_symbols
.binary_search_by_key(&start_addr, |x| x.address)
.unwrap_or_else(|idx| idx - 1);
let first_mapping = mapping_symbols[first_mapping_idx].mapping;

let mut mappings_iter =
Expand Down Expand Up @@ -215,7 +213,7 @@ impl ObjArch for ObjArchArm {
address: address as u64,
size: (parser.address - address) as u8,
op: ins.opcode_id(),
mnemonic: parsed_ins.mnemonic.to_string(),
mnemonic: Cow::Borrowed(parsed_ins.mnemonic),
args,
reloc,
branch_dest,
Expand All @@ -234,7 +232,7 @@ impl ObjArch for ObjArchArm {
section: &ObjSection,
address: u64,
reloc: &Relocation,
) -> anyhow::Result<i64> {
) -> Result<i64> {
let address = address as usize;
Ok(match reloc.flags() {
// ARM calls
Expand Down
Loading

0 comments on commit 09aa52d

Please sign in to comment.