Unverified Commit 3a25050e by Enkelmann Committed by GitHub

Ensure that each block is contained in exactly one subroutine (#204)

parent 531e2bc1
...@@ -284,9 +284,8 @@ impl<'a> GraphBuilder<'a> { ...@@ -284,9 +284,8 @@ impl<'a> GraphBuilder<'a> {
Node::BlkEnd(source_block, _) => source_block, Node::BlkEnd(source_block, _) => source_block,
_ => panic!(), _ => panic!(),
}; };
for target_address in source_block.term.indirect_jmp_targets.iter() { for target_tid in source_block.term.indirect_jmp_targets.iter() {
let target_tid = Tid::blk_id_at_address(target_address); self.add_intraprocedural_edge(source, target_tid, jump, untaken_conditional);
self.add_intraprocedural_edge(source, &target_tid, jump, untaken_conditional);
} }
} }
...@@ -604,11 +603,11 @@ mod tests { ...@@ -604,11 +603,11 @@ mod tests {
let mut blk_tid = Tid::new("blk_00001000"); let mut blk_tid = Tid::new("blk_00001000");
blk_tid.address = "00001000".to_string(); blk_tid.address = "00001000".to_string();
let blk_term = Term { let blk_term = Term {
tid: blk_tid, tid: blk_tid.clone(),
term: Blk { term: Blk {
defs: Vec::new(), defs: Vec::new(),
jmps: vec![indirect_jmp_term], jmps: vec![indirect_jmp_term],
indirect_jmp_targets: vec!["00001000".to_string()], indirect_jmp_targets: vec![blk_tid],
}, },
}; };
let sub_term = Term { let sub_term = Term {
......
...@@ -218,6 +218,10 @@ impl Blk { ...@@ -218,6 +218,10 @@ impl Blk {
term: jmp_term.term.into(), term: jmp_term.term.into(),
}) })
.collect(); .collect();
let indirect_jmp_targets = indirect_jmp_targets
.into_iter()
.map(|address| Tid::blk_id_at_address(&address))
.collect();
IrBlk { IrBlk {
defs, defs,
jmps, jmps,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment