Skip to content

Ghidra is a software reverse engineering (SRE) framework

Detect if setSymbolProperties has been previously applied

caheckmana3988a7db2e7
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
index ec60f9a03a..2a489639b4 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
@@ -1128,8 +1128,8 @@ bool Funcdata::attemptDynamicMapping(SymbolEntry *entry,DynamicHash &dhash)
}
}
else if (entry->getSize() == vn->getSize()) {
- vn->setSymbolProperties(entry);
- return true;
+ if (vn->setSymbolProperties(entry))
+ return true;
}
return false;
}
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/varnode.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/varnode.cc
index 96088aa3bf..2c6ce5f5eb 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/varnode.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/varnode.cc
@@ -363,16 +363,21 @@ void Varnode::setDef(PcodeOp *op)
/// The given Symbol's data-type and flags are inherited by \b this Varnode.
/// If the Symbol is \e type-locked, a reference to the Symbol is set on \b this Varnode.
/// \param entry is a mapping to the given Symbol
-void Varnode::setSymbolProperties(SymbolEntry *entry)
+/// \return \b true if any properties have changed
+bool Varnode::setSymbolProperties(SymbolEntry *entry)
{
- entry->updateType(this);
+ bool res = entry->updateType(this);
if (entry->getSymbol()->isTypeLocked()) {
- mapentry = entry;
- if (high != (HighVariable *)0)
- high->setSymbol(this);
+ if (mapentry != entry) {
+ mapentry = entry;
+ if (high != (HighVariable *)0)
+ high->setSymbol(this);
+ res = true;
+ }
}
setFlags(entry->getAllFlags() & ~Varnode::typelock);
+ return res;
}
/// A reference to the given Symbol is set on \b this Varnode.
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/varnode.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/varnode.hh
index c6c8a629eb..59ba001819 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/varnode.hh
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/varnode.hh
@@ -154,7 +154,7 @@ private:
// These functions should be only private things used by VarnodeBank
void setInput(void) { setFlags(Varnode::input|Varnode::coverdirty); } ///< Mark Varnode as \e input
void setDef(PcodeOp *op); ///< Set the defining PcodeOp of this Varnode
- void setSymbolProperties(SymbolEntry *entry); ///< Set properties from the given Symbol to \b this Varnode
+ bool setSymbolProperties(SymbolEntry *entry); ///< Set properties from the given Symbol to \b this Varnode
void setSymbolEntry(SymbolEntry *entry); ///< Attach a Symbol to \b this Varnode
void setSymbolReference(SymbolEntry *entry,int4 off); ///< Attach a Symbol reference to \b this
void addDescend(PcodeOp *op); ///< Add a descendant (reading) PcodeOp to this Varnode's list