Skip to content

Commit

Permalink
Bump unarm to 1.5.0 (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
AetiasHax authored Aug 26, 2024
1 parent 1f4175d commit 3bd8aae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion objdiff-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
27 changes: 15 additions & 12 deletions objdiff-core/src/arch/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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(_)));
}
_ => (),
}
Expand All @@ -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,
});
}
Expand Down Expand Up @@ -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(),
))),
}
}
Expand Down

0 comments on commit 3bd8aae

Please sign in to comment.