From 202a07c6044194d2b89a1c455662e869e18355d9 Mon Sep 17 00:00:00 2001 From: "Edward J. Schwartz" Date: Wed, 29 Nov 2023 16:31:09 -0500 Subject: [PATCH] Add another HighCFG entry block heuristic --- .../java/kaiju/tools/ghihorn/cfg/HighCfg.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/kaiju/tools/ghihorn/cfg/HighCfg.java b/src/main/java/kaiju/tools/ghihorn/cfg/HighCfg.java index afeb9d8..079fc7d 100644 --- a/src/main/java/kaiju/tools/ghihorn/cfg/HighCfg.java +++ b/src/main/java/kaiju/tools/ghihorn/cfg/HighCfg.java @@ -310,7 +310,7 @@ public static HighCfg build(final HighFunction highFu // Ensure the p-code is in basicblock order final List 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 @@ -545,14 +545,28 @@ public static HighCfg 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() + "."); } }