Skip to content

Ghidra is a software reverse engineering (SRE) framework

Don't let splitflow undo double-precision merges

caheckman1271bf044a64
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/double.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/double.cc
index 3034d95b94..a314fac335 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/double.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/double.cc
@@ -723,6 +723,8 @@ void SplitVarnode::wholeList(Varnode *w,vector<SplitVarnode> &splitvec)
}
}
if (res==0) return;
+ if (res == 3 && (basic.lo->getSize() + basic.hi->getSize() != basic.wholesize))
+ return;
splitvec.push_back(basic);
findCopies(basic,splitvec);
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
index f64aeb8fd8..96d7193869 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
@@ -7610,6 +7610,8 @@ int4 RuleSplitFlow::applyOp(PcodeOp *op,Funcdata &data)
Varnode *vn = op->getIn(0);
if (!vn->isWritten())
return 0;
+ if (vn->isPrecisLo() || vn->isPrecisHi())
+ return 0;
if (op->getOut()->getSize() + loSize != vn->getSize())
return 0; // Make sure SUBPIECE is taking most significant part
PcodeOp *concatOp = (PcodeOp *)0;
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc
index a4d37d7e3a..9c4d872f9c 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc
@@ -1554,6 +1554,8 @@ bool SplitFlow::traceForward(TransformVar *rvn)
break;
case CPUI_SUBPIECE:
{
+ if (outvn->isPrecisLo() || outvn->isPrecisHi())
+ return false; // Do not split if we know value comes from double precision pieces
uintb val = op->getIn(1)->getOffset();
if ((val==0)&&(outvn->getSize() == laneDescription.getSize(0))) {
TransformOp *rop = newPreexistingOp(1,CPUI_COPY,op); // Grabs the low piece