Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-2212 Mark calls with boolean return values

caheckman359ddc5c8719
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
index ae0b1c3a3c..5c6ac3021c 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc
@@ -1470,6 +1470,8 @@ void ActionFuncLink::funcLinkOutput(FuncCallSpecs *fc,Funcdata &data)
Datatype *outtype = outparam->getType();
if (outtype->getMetatype() != TYPE_VOID) {
int4 sz = outparam->getSize();
+ if (sz == 1 && outtype->getMetatype() == TYPE_BOOL)
+ data.opMarkCalculatedBool(fc->getOp());
Address addr = outparam->getAddress();
data.newVarnodeOut(sz,addr,fc->getOp());
VarnodeData vdata;
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
index a59ad6f651..89685bd767 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
@@ -4638,6 +4638,8 @@ void FuncCallSpecs::commitNewOutputs(Funcdata &data,Varnode *newout)
// We could conceivably truncate the output to the correct size to match the parameter
activeoutput.registerTrial(param->getAddress(),param->getSize());
PcodeOp *indop = newout->getDef();
+ if (newout->getSize() == 1 && param->getType()->getMetatype() == TYPE_BOOL)
+ data.opMarkCalculatedBool(op);
if (newout->getSize() == param->getSize()) {
if (indop != op) {
data.opUnsetOutput(indop);