Skip to content

Commit 3c42815

Browse files
committed
Allow setting spec load address
1 parent 1d70b8a commit 3c42815

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/bin/crackers/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ fn new(path: PathBuf) -> anyhow::Result<()> {
5858
specification: SpecificationConfig {
5959
path: "spec.o".to_string(),
6060
max_instructions: 1,
61+
base_address: None,
6162
},
6263
library: Default::default(),
6364
sleigh: SleighConfig {

src/config/constraint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::error::CrackersError;
22
use crate::synthesis::builder::{StateConstraintGenerator, TransitionConstraintGenerator};
33
use jingle::modeling::{ModeledBlock, ModelingContext, State};
4-
use jingle::sleigh::{IndirectVarNode, RegisterManager, SpaceManager, VarNode};
4+
use jingle::sleigh::{RegisterManager, SpaceManager, VarNode};
55
use jingle::varnode::{ResolvedIndirectVarNode, ResolvedVarnode};
66
use jingle::JingleContext;
77
use serde::{Deserialize, Serialize};

src/config/specification.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ use crate::config::sleigh::SleighConfig;
1414
pub struct SpecificationConfig {
1515
pub path: String,
1616
pub max_instructions: usize,
17+
pub base_address: Option<u64>,
1718
}
1819

1920
impl SpecificationConfig {
20-
pub fn load_sleigh<'a>(
21+
fn load_sleigh<'a>(
2122
&self,
2223
sleigh_config: &'a SleighConfig,
2324
) -> Result<LoadedSleighContext<'a>, CrackersConfigError> {
@@ -36,7 +37,10 @@ impl SpecificationConfig {
3637
let _section = gimli_file
3738
.section_by_name(".text")
3839
.ok_or(SpecMissingTextSection)?;
39-
let sleigh = self.load_sleigh(sleigh_config)?;
40+
let mut sleigh = self.load_sleigh(sleigh_config)?;
41+
if let Some(o) = self.base_address {
42+
sleigh.set_base_address(o)
43+
}
4044
let instrs: Vec<Instruction> = sleigh
4145
.read_until_branch(sym.address(), self.max_instructions)
4246
.collect();

0 commit comments

Comments
 (0)