diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc index 428ac0763c..82c7544253 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc @@ -4651,12 +4651,12 @@ void universal_action(Architecture *conf) act->addAction( new ActionHideShadow("merge") ); act->addAction( new ActionCopyMarker("merge") ); act->addAction( new ActionOutputPrototype("localrecovery") ); - act->addAction( new ActionSetCasts("casts") ); act->addAction( new ActionInputPrototype("fixateproto") ); act->addAction( new ActionRestructureHigh("localrecovery") ); act->addAction( new ActionMapGlobals("fixateglobals") ); act->addAction( new ActionDynamicSymbols("dynamic") ); act->addAction( new ActionNameVars("merge") ); + act->addAction( new ActionSetCasts("casts") ); act->addAction( new ActionFinalStructure("blockrecovery") ); act->addAction( new ActionPrototypeWarnings("protorecovery") ); act->addAction( new ActionStop("base") ); diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/varmap.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/varmap.cc index a7925b4762..c770c09921 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/varmap.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/varmap.cc @@ -666,8 +666,21 @@ void AliasChecker::gatherAdditiveBase(Varnode *startvn,vector &addbase) vnqueue.push_back(AddBase(subvn,indexvn)); } break; - case CPUI_INT_ADD: case CPUI_INT_SUB: + if (vn == op->getIn(1)) { // Subtracting the pointer + nonadduse = true; + break; + } + othervn = op->getIn(1); + if (!othervn->isConstant()) + indexvn = othervn; + subvn = op->getOut(); + if (!subvn->isMark()) { + subvn->setMark(); + vnqueue.push_back(AddBase(subvn,indexvn)); + } + break; + case CPUI_INT_ADD: case CPUI_PTRADD: othervn = op->getIn(1); // Check if something else is being added in besides a constant if (othervn == vn) @@ -820,7 +833,7 @@ void MapState::reconcileDatatypes(void) Datatype *curDatatype = curHint->type; if (curDatatype->typeOrder(*startDatatype) < 0) // Take the most specific variant of data-type startDatatype = curDatatype; - if (curHint->compare(*startHint) != 0) + if (curHint->compare(*newList.back()) != 0) newList.push_back(curHint); // Keep the current hint if it is otherwise different } else {