Handle conditional computed jumps in SwitchOverride.java

SwitchOverride.java is one of the recommended ways to fix switch
statements in the decompiler when there are too many branches
(GhidraDocs/GhidraClass/Advanced/improvingDisassemblyAndDecompilation)

Currently the indirect jump is only allowed to be an unconditional
computed jump (or a call). However, compilers can sometimes implement
switch statements using conditional indirect jumps (via conditional
loads, conditional adds, etc.) if the target architecture supports them
(e.g., ARM). In this case, SwitchOverride.java will fail because the
instruction flow type will be RefType.CONDITIONAL_COMPUTED_JUMP rather
than the expected RefType.COMPUTED_JUMP, even though both should be
equally acceptable.
This commit is contained in:
johanngan
2022-11-13 18:30:31 -06:00
parent 97097daa68
commit 680a7640cd

View File

@@ -83,7 +83,7 @@ public class SwitchOverride extends GhidraScript {
FlowType flowType = instr.getFlowType();
if (flowType == RefType.COMPUTED_JUMP) {
if (flowType.isJump() && flowType.isComputed()) {
return true;
}
if (flowType.isCall()) {