From 35ac4cf37cd1e10b14e0e758124dcc5a5741df1f Mon Sep 17 00:00:00 2001 From: caheckman <48068198+caheckman@users.noreply.github.com> Date: Mon, 17 Nov 2025 22:23:38 +0000 Subject: [PATCH] GP-6130 Correct pointer offsets for buildStore and buildLoad --- .../Decompiler/src/decompile/cpp/subflow.cc | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc index d7aef4dca3..c47293afb9 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/subflow.cc @@ -3715,13 +3715,11 @@ bool LaneDivide::buildStore(PcodeOp *op,int4 numLanes,int4 skipLanes) } TransformVar *basePtr = getPreexistingVarnode(origPtr); int4 ptrSize = origPtr->getSize(); - Varnode *valueVn = op->getIn(2); - for(int4 i=0;iisBigEndian() ? numLanes -1 - count: count; // little = least to most, big = most to least TransformOp *ropStore = newOpReplace(3, CPUI_STORE, op); - int4 bytePos = description.getPosition(skipLanes + i); - int4 sz = description.getSize(skipLanes + i); - if (spc->isBigEndian()) - bytePos = valueVn->getSize() - (bytePos + sz); // Convert position to address order // Construct the pointer TransformVar *ptrVn; @@ -3738,6 +3736,7 @@ bool LaneDivide::buildStore(PcodeOp *op,int4 numLanes,int4 skipLanes) opSetInput(ropStore,newConstant(spaceConstSize,0,spaceConst),0); opSetInput(ropStore,ptrVn,1); opSetInput(ropStore,inVars+i,2); + bytePos += description.getSize(skipLanes + i); } return true; } @@ -3763,13 +3762,11 @@ bool LaneDivide::buildLoad(PcodeOp *op,TransformVar *outVars,int4 numLanes,int4 } TransformVar *basePtr = getPreexistingVarnode(origPtr); int4 ptrSize = origPtr->getSize(); - int4 outSize = op->getOut()->getSize(); - for(int4 i=0;iisBigEndian()) - bytePos = outSize - (bytePos + sz); // Convert position to address order + int4 i = spc->isBigEndian() ? numLanes - 1 - count : count; // little = least to most, big = most to least // Construct the pointer TransformVar *ptrVn; @@ -3786,6 +3783,7 @@ bool LaneDivide::buildLoad(PcodeOp *op,TransformVar *outVars,int4 numLanes,int4 opSetInput(ropLoad,newConstant(spaceConstSize,0,spaceConst),0); opSetInput(ropLoad,ptrVn,1); opSetOutput(ropLoad,outVars+i); + bytePos += description.getSize(skipLanes + i); } return true; }