From 3bd8aaee4178828915db61ce96534fdadff7fe7c Mon Sep 17 00:00:00 2001 From: Aetias <144526980+AetiasHax@users.noreply.github.com> Date: Mon, 26 Aug 2024 04:57:45 +0200 Subject: [PATCH] Bump unarm to 1.5.0 (#98) --- Cargo.lock | 4 ++-- objdiff-core/Cargo.toml | 2 +- objdiff-core/src/arch/arm.rs | 27 +++++++++++++++------------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f14f41b..61dbf12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4540,9 +4540,9 @@ dependencies = [ [[package]] name = "unarm" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379762d9433a2e6e498cde97801fb238318b024a513d0843eeac98b9056b9f3c" +checksum = "e82790df6bdacbe2661a9ea0e075d1aefe18198420afaa0662cef93b580c3b26" [[package]] name = "unicase" diff --git a/objdiff-core/Cargo.toml b/objdiff-core/Cargo.toml index 2afa29b..1014403 100644 --- a/objdiff-core/Cargo.toml +++ b/objdiff-core/Cargo.toml @@ -67,7 +67,7 @@ iced-x86 = { version = "1.21.0", default-features = false, features = ["std", "d msvc-demangler = { version = "0.10.0", optional = true } # arm -unarm = { version = "1.4.0", optional = true } +unarm = { version = "1.5.0", optional = true } arm-attr = { version = "0.1.1", optional = true } [build-dependencies] diff --git a/objdiff-core/src/arch/arm.rs b/objdiff-core/src/arch/arm.rs index afb6bf9..d52a41a 100644 --- a/objdiff-core/src/arch/arm.rs +++ b/objdiff-core/src/arch/arm.rs @@ -150,9 +150,9 @@ impl ObjArch for ObjArchArm { object::Endianness::Big => unarm::Endian::Big, }; - let parse_flags = ParseFlags { ual: config.arm_unified_syntax }; + let parse_flags = ParseFlags { ual: config.arm_unified_syntax, version }; - let mut parser = Parser::new(version, first_mapping, start_addr, endian, parse_flags, code); + let mut parser = Parser::new(first_mapping, start_addr, endian, parse_flags, code); let display_options = DisplayOptions { reg_names: RegNames { @@ -168,7 +168,7 @@ impl ObjArch for ObjArchArm { }, }; - while let Some((address, op, ins)) = parser.next() { + while let Some((address, ins, parsed_ins)) = parser.next() { if let Some(next) = next_mapping { let next_address = parser.address; if next_address >= next.address { @@ -190,12 +190,15 @@ impl ObjArch for ObjArchArm { | RelocationFlags::Elf { r_type: elf::R_ARM_PC24 } | RelocationFlags::Elf { r_type: elf::R_ARM_XPC25 } | RelocationFlags::Elf { r_type: elf::R_ARM_CALL } => { - reloc_arg = - ins.args.iter().rposition(|a| matches!(a, Argument::BranchDest(_))); + reloc_arg = parsed_ins + .args + .iter() + .rposition(|a| matches!(a, Argument::BranchDest(_))); } // Data RelocationFlags::Elf { r_type: elf::R_ARM_ABS32 } => { - reloc_arg = ins.args.iter().rposition(|a| matches!(a, Argument::UImm(_))); + reloc_arg = + parsed_ins.args.iter().rposition(|a| matches!(a, Argument::UImm(_))); } _ => (), } @@ -204,20 +207,20 @@ impl ObjArch for ObjArchArm { let (args, branch_dest) = if reloc.is_some() && parser.mode == ParseMode::Data { (vec![ObjInsArg::Reloc], None) } else { - push_args(&ins, config, reloc_arg, address, display_options)? + push_args(&parsed_ins, config, reloc_arg, address, display_options)? }; - ops.push(op.id()); + ops.push(ins.opcode_id()); insts.push(ObjIns { address: address as u64, size: (parser.address - address) as u8, - op: op.id(), - mnemonic: ins.mnemonic.to_string(), + op: ins.opcode_id(), + mnemonic: parsed_ins.mnemonic.to_string(), args, reloc, branch_dest, line, - formatted: ins.display(display_options).to_string(), + formatted: parsed_ins.display(display_options).to_string(), orig: None, }); } @@ -425,7 +428,7 @@ fn push_args( | Argument::Shift(_) | Argument::CpsrFlags(_) | Argument::Endian(_) => args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque( - arg.display(display_options).to_string().into(), + arg.display(display_options, None).to_string().into(), ))), } }