Ghidra is a software reverse engineering (SRE) framework
Fix for NEW operator
caheckmane47fa5151808
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.ccindex 0cb2ddc1f3..f5cd4e5a99 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/coreaction.cc@@ -3425,11 +3425,11 @@ int4 ActionDeadCode::apply(Funcdata &data)op->clearIndirectSource();if (op->isCall()) {- if (op->code() == CPUI_CALLOTHER) {+ // Postpone setting consumption on CALL and CALLIND inputs+ if (op->isCallWithoutSpec()) {for(i=0;i<op->numInput();++i)pushConsumed(~((uintb)0),op->getIn(i),worklist);}- // Postpone setting consumption on CALL and CALLIND inputsif (!op->isAssignment())continue;}diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.hhindex 06d632bc00..467b604792 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata.hh@@ -433,7 +433,7 @@ public:void opMarkNonPrinting(PcodeOp *op) { op->setFlag(PcodeOp::nonprinting); } ///< Mark PcodeOp as not being printedvoid opMarkSpecialPrint(PcodeOp *op) { op->setAdditionalFlag(PcodeOp::special_print); } ///< Mark PcodeOp as needing special printingvoid opMarkNoCollapse(PcodeOp *op) { op->setFlag(PcodeOp::nocollapse); } ///< Mark PcodeOp as not collapsible- void opMarkCpoolTransformed(PcodeOp *op) { op->setFlag(PcodeOp::is_cpool_transformed); } ///< Mark cpool record was visited+ void opMarkCpoolTransformed(PcodeOp *op) { op->setAdditionalFlag(PcodeOp::is_cpool_transformed); } ///< Mark cpool record was visitedvoid opMarkCalculatedBool(PcodeOp *op) { op->setFlag(PcodeOp::calculated_bool); } ///< Mark PcodeOp as having boolean outputvoid opMarkSpacebasePtr(PcodeOp *op) { op->setFlag(PcodeOp::spacebase_ptr); } ///< Mark PcodeOp as LOAD/STORE from spacebase ptrvoid opClearSpacebasePtr(PcodeOp *op) { op->clearFlag(PcodeOp::spacebase_ptr); } ///< Unmark PcodeOp as using spacebase ptrdiff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/op.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/op.hhindex b9163037cf..5b0aee6f53 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/op.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/op.hh@@ -95,7 +95,7 @@ public:spacebase_ptr = 0x4000000, ///< Loads or stores from a dynamic pointer into a spacebaseindirect_creation = 0x8000000, ///< Output varnode is created by indirect effectcalculated_bool = 0x10000000, ///< Output has been determined to be a 1-bit boolean value- is_cpool_transformed = 0x20000000, ///< Have we checked for cpool transforms+ has_callspec = 0x20000000, ///< Op has a call specification associated with itptrflow = 0x40000000, ///< Op consumes or produces a ptrindirect_store = 0x80000000 ///< CPUI_INDIRECT is caused by CPUI_STORE};@@ -107,7 +107,8 @@ public:special_print = 0x10, ///< Op is marked for special printingmodified = 0x20, ///< This op has been modified by the current actionwarning = 0x40, ///< Warning has been generated for this op- incidental_copy = 0x80 ///< Treat this as \e incidental for parameter recovery algorithms+ incidental_copy = 0x80, ///< Treat this as \e incidental for parameter recovery algorithms+ is_cpool_transformed = 0x100 ///< Have we checked for cpool transforms};private:TypeOp *opcode; ///< Pointer to class providing behavioral details of the operation@@ -164,6 +165,8 @@ public:bool isDead(void) const { return ((flags&PcodeOp::dead)!=0); } ///< Return \b true if this op is deadbool isAssignment(void) const { return (output!=(Varnode *)0); } ///< Return \b true is this op has an outputbool isCall(void) const { return ((flags&PcodeOp::call)!=0); } ///< Return \b true if this op indicates call semantics+ /// \brief Return \b true if this op acts as call but does not have a full specification+ bool isCallWithoutSpec(void) const { return ((flags&(PcodeOp::call|PcodeOp::has_callspec))==PcodeOp::call); }bool isMarker(void) const { return ((flags&PcodeOp::marker)!=0); } ///< Return \b true is a special SSA form opbool isIndirectCreation(void) const { return ((flags&PcodeOp::indirect_creation)!=0); } ///< Return \b true if op creates a varnode indirectlybool isIndirectStore(void) const { return ((flags&PcodeOp::indirect_store)!=0); } ///< Return \b true if \b this INDIRECT is caused by STORE@@ -203,7 +206,7 @@ public:/// \brief Return \b true if output is 1-bit booleanbool isCalculatedBool(void) const { return ((flags&(PcodeOp::calculated_bool|PcodeOp::booloutput))!=0); }/// \brief Return \b true if we have already examined this cpool- bool isCpoolTransformed(void) const { return ((flags&PcodeOp::is_cpool_transformed)!=0); }+ bool isCpoolTransformed(void) const { return ((addlflags&PcodeOp::is_cpool_transformed)!=0); }bool isCollapsible(void) const; ///< Return \b true if this can be collapsed to a COPY of a constant/// \brief Return \b true if this LOADs or STOREs from a dynamic \e spacebase pointerbool usesSpacebasePtr(void) const { return ((flags&PcodeOp::spacebase_ptr)!=0); }diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.ccindex 1db2c08607..c72f485f48 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/typeop.cc@@ -537,7 +537,7 @@ void TypeOpBranchind::printRaw(ostream &s,const PcodeOp *op)TypeOpCall::TypeOpCall(TypeFactory *t) : TypeOp(t,CPUI_CALL,"call"){- opflags = (PcodeOp::special|PcodeOp::call|PcodeOp::coderef|PcodeOp::nocollapse);+ opflags = (PcodeOp::special|PcodeOp::call|PcodeOp::has_callspec|PcodeOp::coderef|PcodeOp::nocollapse);behave = new OpBehavior(CPUI_CALL,false,true); // Dummy behavior}@@ -610,7 +610,7 @@ Datatype *TypeOpCall::getOutputLocal(const PcodeOp *op) constTypeOpCallind::TypeOpCallind(TypeFactory *t) : TypeOp(t,CPUI_CALLIND,"callind"){- opflags = PcodeOp::special|PcodeOp::call|PcodeOp::nocollapse;+ opflags = PcodeOp::special|PcodeOp::call|PcodeOp::has_callspec|PcodeOp::nocollapse;behave = new OpBehavior(CPUI_CALLIND,false,true); // Dummy behavior}