Bump unarm to 1.5.0 (#98)

This commit is contained in:
Aetias 2024-08-26 04:57:45 +02:00 committed by GitHub
parent 1f4175dc21
commit 3bd8aaee41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 15 deletions

4
Cargo.lock generated
View File

@ -4540,9 +4540,9 @@ dependencies = [
[[package]] [[package]]
name = "unarm" name = "unarm"
version = "1.4.0" version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "379762d9433a2e6e498cde97801fb238318b024a513d0843eeac98b9056b9f3c" checksum = "e82790df6bdacbe2661a9ea0e075d1aefe18198420afaa0662cef93b580c3b26"
[[package]] [[package]]
name = "unicase" name = "unicase"

View File

@ -67,7 +67,7 @@ iced-x86 = { version = "1.21.0", default-features = false, features = ["std", "d
msvc-demangler = { version = "0.10.0", optional = true } msvc-demangler = { version = "0.10.0", optional = true }
# arm # arm
unarm = { version = "1.4.0", optional = true } unarm = { version = "1.5.0", optional = true }
arm-attr = { version = "0.1.1", optional = true } arm-attr = { version = "0.1.1", optional = true }
[build-dependencies] [build-dependencies]

View File

@ -150,9 +150,9 @@ impl ObjArch for ObjArchArm {
object::Endianness::Big => unarm::Endian::Big, 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 { let display_options = DisplayOptions {
reg_names: RegNames { 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 { if let Some(next) = next_mapping {
let next_address = parser.address; let next_address = parser.address;
if next_address >= next.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_PC24 }
| RelocationFlags::Elf { r_type: elf::R_ARM_XPC25 } | RelocationFlags::Elf { r_type: elf::R_ARM_XPC25 }
| RelocationFlags::Elf { r_type: elf::R_ARM_CALL } => { | RelocationFlags::Elf { r_type: elf::R_ARM_CALL } => {
reloc_arg = reloc_arg = parsed_ins
ins.args.iter().rposition(|a| matches!(a, Argument::BranchDest(_))); .args
.iter()
.rposition(|a| matches!(a, Argument::BranchDest(_)));
} }
// Data // Data
RelocationFlags::Elf { r_type: elf::R_ARM_ABS32 } => { 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 { let (args, branch_dest) = if reloc.is_some() && parser.mode == ParseMode::Data {
(vec![ObjInsArg::Reloc], None) (vec![ObjInsArg::Reloc], None)
} else { } 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 { insts.push(ObjIns {
address: address as u64, address: address as u64,
size: (parser.address - address) as u8, size: (parser.address - address) as u8,
op: op.id(), op: ins.opcode_id(),
mnemonic: ins.mnemonic.to_string(), mnemonic: parsed_ins.mnemonic.to_string(),
args, args,
reloc, reloc,
branch_dest, branch_dest,
line, line,
formatted: ins.display(display_options).to_string(), formatted: parsed_ins.display(display_options).to_string(),
orig: None, orig: None,
}); });
} }
@ -425,7 +428,7 @@ fn push_args(
| Argument::Shift(_) | Argument::Shift(_)
| Argument::CpsrFlags(_) | Argument::CpsrFlags(_)
| Argument::Endian(_) => args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque( | Argument::Endian(_) => args.push(ObjInsArg::Arg(ObjInsArgValue::Opaque(
arg.display(display_options).to_string().into(), arg.display(display_options, None).to_string().into(),
))), ))),
} }
} }