Skip to content

Commit

Permalink
add test for armv7 thumb lift cmp instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
rchtsang committed Jul 22, 2024
1 parent b59d903 commit 434149f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions fugue-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ uuid = "1"
[dev-dependencies]
anyhow = "1"
env_logger = "0.10"
ahash = { version = "0.8", features = ["serde"] }
34 changes: 34 additions & 0 deletions fugue-ir/src/translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,4 +1037,38 @@ mod test {

Ok(())
}

#[test]
fn test_arm7_thumb_cmp_bug() {
use crate::disassembly::IRBuilderArena;
use crate::translator::Translator;
use fugue_arch::ArchitectureDef;
use fugue_bytes::endian::Endian;
use ahash::AHashMap as Map;

let mut translator = Translator::from_file(
"pc",
&ArchitectureDef::new("ARM", Endian::Little, 64, "Cortex"),
&Map::default(),
"./data/processors/ARM/ARM7_le.sla",
).expect("failed to load translator");

translator.set_variable_default("TMode", 1);
translator.set_variable_default("LRset", 0);
translator.set_variable_default("spsr", 0);


let bytes = [0x02, 0x2b];

let mut db = translator.context_database();
let irb = IRBuilderArena::with_capacity(4096);

let addr = translator.address(0x1000u64);
let pcode = translator.lift(&mut db, &irb, addr, &bytes)
.expect("failed to lift bytes");

println!("{}", pcode.display(&translator));
let intlesseq_op = &pcode.operations[0];
assert!(intlesseq_op.inputs[0].space().is_register(), "expected lhs to be register")
}
}

0 comments on commit 434149f

Please sign in to comment.