Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add another HighCFG entry block heuristic #10

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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