diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc index f5074f6cf1..befa26c1e8 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc @@ -2085,11 +2085,11 @@ bool SplitDatatype::generateConstants(Varnode *vn,vector &inVarnodes) /// based on the input offsets in \b dataTypePieces. /// \param rootVn is the given root constant /// \param inVarnodes is the container for the new Varnodes -void SplitDatatype::buildInConstants(Varnode *rootVn,vector &inVarnodes) +/// \param bigEndian is \b true if the output address space is big endian +void SplitDatatype::buildInConstants(Varnode *rootVn,vector &inVarnodes,bool bigEndian) { uintb baseVal = rootVn->getOffset(); - bool bigEndian = rootVn->getSpace()->isBigEndian(); for(int4 i=0;i inVarnodes; vector outVarnodes; if (inVn->isConstant()) - buildInConstants(inVn,inVarnodes); + buildInConstants(inVn,inVarnodes,outVn->getSpace()->isBigEndian()); else buildInSubpieces(inVn,copyOp,inVarnodes); buildOutVarnodes(outVn,outVarnodes); @@ -2461,9 +2461,10 @@ bool SplitDatatype::splitStore(PcodeOp *storeOp,Datatype *outType) return false; } + AddrSpace *storeSpace = storeOp->getIn(0)->getSpaceFromConst(); vector inVarnodes; if (inVn->isConstant()) - buildInConstants(inVn,inVarnodes); + buildInConstants(inVn,inVarnodes,storeSpace->isBigEndian()); else if (loadOp != (PcodeOp *)0) { vector loadPtrs; buildPointers(loadRoot.pointer, loadRoot.ptrType, loadRoot.baseOffset, loadOp, loadPtrs, true); @@ -2485,7 +2486,6 @@ bool SplitDatatype::splitStore(PcodeOp *storeOp,Datatype *outType) vector storePtrs; buildPointers(storeRoot.pointer, storeRoot.ptrType, storeRoot.baseOffset, storeOp, storePtrs, false); - AddrSpace *storeSpace = storeOp->getIn(0)->getSpaceFromConst(); // Preserve original STORE object, so that INDIRECT references are still valid // but convert it into the first of the smaller STOREs data.opSetInput(storeOp,storePtrs[0],1); diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.hh index 83460c4497..17353af49a 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.hh +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.hh @@ -188,7 +188,7 @@ class SplitDatatype { bool testDatatypeCompatibility(Datatype *inBase,Datatype *outBase,bool inConstant); bool testCopyConstraints(PcodeOp *copyOp); bool generateConstants(Varnode *vn,vector &inVarnodes); - void buildInConstants(Varnode *rootVn,vector &inVarnodes); + void buildInConstants(Varnode *rootVn,vector &inVarnodes,bool bigEndian); void buildInSubpieces(Varnode *rootVn,PcodeOp *followOp,vector &inVarnodes); void buildOutVarnodes(Varnode *rootVn,vector &outVarnodes); void buildOutConcats(Varnode *rootVn,PcodeOp *previousOp,vector &outVarnodes);