Ghidra is a software reverse engineering (SRE) framework
GP-2024 Fix for formatting test
caheckmanc88f59a5edda
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/database.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/database.ccindex c71e554be6..8ba62b9e74 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/database.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/database.cc@@ -1699,19 +1699,20 @@ Symbol *Scope::addDynamicSymbol(const string &nm,Datatype *ct,const Address &cadreturn sym;}-/// \brief Create a symbol that forces a constant display conversion+/// \brief Create a symbol that forces display conversion on a constant///-/// \param format is the type of conversion (Symbol::force_hex, Symbol::force_dec, etc.)+/// \param nm is the equate name to display, which may be empty for an integer conversion+/// \param format is the type of integer conversion (Symbol::force_hex, Symbol::force_dec, etc.)/// \param value is the constant value being converted/// \param addr is the address of the p-code op reading the constant/// \param hash is the dynamic hash identifying the constant/// \return the new EquateSymbol-Symbol *Scope::addConvertSymbol(uint4 format,uintb value,Address &addr,uint8 hash)+Symbol *Scope::addEquateSymbol(const string &nm,uint4 format,uintb value,const Address &addr,uint8 hash){Symbol *sym;- sym = new EquateSymbol(owner,"",format,value);+ sym = new EquateSymbol(owner,nm,format,value);addSymbolInternal(sym);RangeList rnglist;if (!addr.isInvalid())diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/database.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/database.hhindex 6dff61a8c6..77df585871 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/database.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/database.hh@@ -727,7 +727,7 @@ public:ExternRefSymbol *addExternalRef(const Address &addr,const Address &refaddr,const string &nm);LabSymbol *addCodeLabel(const Address &addr,const string &nm);Symbol *addDynamicSymbol(const string &nm,Datatype *ct,const Address &caddr,uint8 hash);- Symbol *addConvertSymbol(uint4 format,uintb value,Address &addr,uint8 hash);+ Symbol *addEquateSymbol(const string &nm,uint4 format,uintb value,const Address &addr,uint8 hash);string buildDefaultName(Symbol *sym,int4 &base,Varnode *vn) const; ///< Create a default name for the given Symbolbool isReadOnly(const Address &addr,int4 size,const Address &usepoint) const;void printBounds(ostream &s) const { rangetree.printBounds(s); } ///< Print a description of \b this Scope's \e owned memory rangesdiff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.ccindex a8e761ea19..4c22cbd42c 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc@@ -1198,7 +1198,11 @@ void Funcdata::buildDynamicSymbol(Varnode *vn)if (dhash.getHash() == 0)throw RecovError("Unable to find unique hash for varnode");- Symbol *sym = localmap->addDynamicSymbol("",high->getType(),dhash.getAddress(),dhash.getHash());+ Symbol *sym;+ if (vn->isConstant())+ sym = localmap->addEquateSymbol("",Symbol::force_hex, vn->getOffset(), dhash.getAddress(), dhash.getHash());+ else+ sym = localmap->addDynamicSymbol("",high->getType(),dhash.getAddress(),dhash.getHash());vn->setSymbolEntry(sym->getFirstWholeMap());}diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ifacedecomp.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ifacedecomp.ccindex 5b1d265771..f2994e1fcb 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ifacedecomp.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ifacedecomp.cc@@ -708,7 +708,7 @@ void IfcMapconvert::execute(istream &s)s >> hex >> hash; // Parse the hash value- dcp->fd->getScopeLocal()->addConvertSymbol(format, value, addr, hash);+ dcp->fd->getScopeLocal()->addEquateSymbol("", format, value, addr, hash);}/// \class IfcPrintdisasmdiff --git a/Ghidra/Features/Decompiler/src/decompile/datatests/displayformat.xml b/Ghidra/Features/Decompiler/src/decompile/datatests/displayformat.xmlindex b1dd5661d5..9ddb3a6db4 100644--- a/Ghidra/Features/Decompiler/src/decompile/datatests/displayformat.xml+++ b/Ghidra/Features/Decompiler/src/decompile/datatests/displayformat.xml@@ -25,7 +25,7 @@<com>map addr r0x301020 octint4 globalbin</com><com>lo fu setglobals</com><com>decompile</com>- <com>force varnode #0xaa(0x100625:0x12) bin</com>+ <com>force varnode #0xaa(0x100619:7) bin</com><com>print C</com><com>quit</com></script>