Skip to content

Commit

Permalink
Merge pull request #10 from CERTCC/entry-block-heuristic
Browse files Browse the repository at this point in the history
Add another HighCFG entry block heuristic
  • Loading branch information
sei-eschwartz committed Nov 29, 2023
2 parents cf6a4bf + 202a07c commit f25e13d
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/main/java/kaiju/tools/ghihorn/cfg/HighCfg.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public static HighCfg<Address, VertexAttributes> build(final HighFunction highFu
// Ensure the p-code is in basicblock order
final List<PcodeOp> bbPcodeList = getPcodeInBBOrder(bb);
if (bbPcodeList.isEmpty()) {
Msg.warn(null, "Basic block: " + bb.getStart() + " has no p-code");
Msg.warn(HighCfg.class, "Basic block: " + bb.getStart() + " has no p-code");
}

// Create the list of pcodes in a list and split out the calls as
Expand Down Expand Up @@ -545,14 +545,28 @@ public static HighCfg<Address, VertexAttributes> build(final HighFunction highFu
break;
}
}
if (bbstart == null) {
throw new RuntimeException("No entry point found for function: " + highFunction.getFunction().getName() + ".");
} else {
Msg.warn(HighCfg.class, "No entry point found for function: " + highFunction.getFunction().getName() + ". I'm going to try the first pcode op at " + bbstart.toString() + ". This is experimental and might not work right!");
if (bbstart != null) {
Msg.warn(HighCfg.class,
"No entry point found for function: " + highFunction.getFunction().getName()
+ ". I'm going to try the first pcode op at " + bbstart.toString()
+ ". This is experimental and might not work right!");
} else if (blocks.size() > 0) {
bbstart = blocks.get(0).getStart();
Msg.warn(HighCfg.class,
"No entry point found for function: " + highFunction.getFunction().getName()
+ ". I'm going to try the first block in the list of HighFunction blocks at "
+ bbstart.toString() + ". This is experimental and might not work right!");
}

if (bbstart != null) {
cfg.setEntryLocation(bbstart);
if (cfg.getEntryVertex() == null) {
throw new RuntimeException("The workaround did not work for function " + highFunction.getFunction().getName());
throw new RuntimeException(
"The workaround did not work for function " + highFunction.getFunction().getName());
}
} else {
throw new RuntimeException(
"No entry point found for function: " + highFunction.getFunction().getName() + ".");
}
}

Expand Down

0 comments on commit f25e13d

Please sign in to comment.