summaryrefslogtreecommitdiff
path: root/rust/tests
diff options
context:
space:
mode:
authorTruman Kilen <trumank@users.noreply.github.com>2025-12-04 12:19:40 -0600
committerGitHub <noreply@github.com>2025-12-04 13:19:40 -0500
commit631f28123beca903701b3140031ee0b9d06511e5 (patch)
tree7af3cd950576ca8d2c7f029d0ab796e5924222a3 /rust/tests
parentd9ff4032894bd342b6e1ad7c1fd8888363980aaa (diff)
Pass arch to finalized LowLevelILFunction (#7729)
Co-authored-by: Mason Reed <mason@vector35.com>
Diffstat (limited to 'rust/tests')
-rw-r--r--rust/tests/low_level_il.rs34
1 files changed, 32 insertions, 2 deletions
diff --git a/rust/tests/low_level_il.rs b/rust/tests/low_level_il.rs
index 84ae3247..79a79964 100644
--- a/rust/tests/low_level_il.rs
+++ b/rust/tests/low_level_il.rs
@@ -1,4 +1,6 @@
-use binaryninja::architecture::{ArchitectureExt, Intrinsic, Register};
+use binaryninja::architecture::{
+ Architecture, ArchitectureExt, CoreArchitecture, Intrinsic, Register,
+};
use binaryninja::binary_view::BinaryViewExt;
use binaryninja::headless::Session;
use binaryninja::low_level_il::expression::{
@@ -8,7 +10,9 @@ use binaryninja::low_level_il::instruction::{
InstructionHandler, LowLevelILInstructionKind, LowLevelInstructionIndex,
};
use binaryninja::low_level_il::operation::IntrinsicOutput;
-use binaryninja::low_level_il::{LowLevelILRegisterKind, LowLevelILSSARegisterKind, VisitorAction};
+use binaryninja::low_level_il::{
+ LowLevelILMutableFunction, LowLevelILRegisterKind, LowLevelILSSARegisterKind, VisitorAction,
+};
use std::path::PathBuf;
#[test]
@@ -349,3 +353,29 @@ fn test_llil_intrinsic() {
_ => panic!("Expected Intrinsic"),
}
}
+
+#[test]
+fn test_llil_unbacked_function_creation() {
+ let _session = Session::new().expect("Failed to initialize session");
+ let arch = CoreArchitecture::by_name("x86_64").unwrap();
+ // Create an LLIL function backed by no Function.
+ let llil = LowLevelILMutableFunction::new(arch, None);
+ let (instr_len, _) = arch.instruction_llil(&[0x8b, 0xd9], 0x0, &llil).unwrap();
+ assert_eq!(instr_len, 2);
+ let llil = llil.finalized();
+
+ // Validate to make sure we can read the llil instruction for a non-backed LLIL function.
+ let inst = llil
+ .instruction_from_index(LowLevelInstructionIndex(0))
+ .unwrap();
+ let LowLevelILInstructionKind::SetReg(inst_operation) = inst.kind() else {
+ panic!("Expected SetReg");
+ };
+ let LowLevelILExpressionKind::Reg(src_operation) = inst_operation.source_expr().kind() else {
+ panic!("Expected Reg");
+ };
+ let src_reg = src_operation.source_reg();
+ assert_eq!(src_reg.name(), "ecx");
+ let dest_reg = inst_operation.dest_reg();
+ assert_eq!(dest_reg.name(), "ebx");
+}