mirror of
https://github.com/lifting-bits/sleigh
synced 2026-06-21 13:56:12 +00:00
Update Ghidra HEAD to commit 85cc8ee88 (#172)
Changed files: ALL decompiler sources New 'ghidra' namespace! --------- Co-authored-by: Eric Kilmer <eric.d.kilmer@gmail.com>
This commit is contained in:
committed by
GitHub
parent
ef4e13d243
commit
262f8d8421
@@ -12,6 +12,12 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
// NOTE: The ghidra symbols should be fully-qualified after the 'ghidra'
|
||||
// namespace changes make it into a stable release
|
||||
#ifdef sleigh_RELEASE_IS_HEAD
|
||||
using namespace ghidra;
|
||||
#endif
|
||||
|
||||
static void PrintUsage(std::ostream &os) {
|
||||
os << "Usage: sleigh-lift [action] [sla_file] [bytes] [-a address] "
|
||||
"[-p root_sla_dir] [-s pspec_file]"
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
From a89963a71d725fa9f85d06149d291bc1f6213ae1 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Thu, 28 Jul 2022 09:20:03 -0400
|
||||
Subject: [PATCH 1/7] Add include guards to decompiler C++ headers
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh | 5 +++++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh | 6 ++++++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh | 5 +++++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh | 5 +++++
|
||||
.../Features/Decompiler/src/decompile/cpp/slgh_compile.hh | 5 +++++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh | 6 ++++++
|
||||
6 files changed, 32 insertions(+)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh
|
||||
index 875d3bb78..6ade01ecc 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/bfd_arch.hh
|
||||
@@ -17,6 +17,9 @@
|
||||
/// \file bfd_arch.hh
|
||||
/// \brief Specific implementation of Architecture using GNU BFD libraries
|
||||
|
||||
+#ifndef __BFD_ARCH__
|
||||
+#define __BFD_ARCH__
|
||||
+
|
||||
#include "sleigh_arch.hh"
|
||||
#include "loadimage_bfd.hh"
|
||||
|
||||
@@ -47,3 +50,5 @@ class BfdArchitecture : public SleighArchitecture {
|
||||
BfdArchitecture(const string &fname,const string &targ,ostream *estream); ///< Constructor
|
||||
virtual ~BfdArchitecture(void) {}
|
||||
};
|
||||
+
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh
|
||||
index 364a5258d..edd6ce865 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/graph.hh
|
||||
@@ -14,8 +14,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
+
|
||||
+#ifndef __GRAPH__
|
||||
+#define __GRAPH__
|
||||
+
|
||||
#include "funcdata.hh"
|
||||
|
||||
extern void dump_dataflow_graph(Funcdata &data,ostream &s);
|
||||
extern void dump_controlflow_graph(const string &name,const BlockGraph &graph,ostream &s);
|
||||
extern void dump_dom_graph(const string &name,const BlockGraph &graph,ostream &s);
|
||||
+
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh
|
||||
index 3ca912dd6..0b70d8b22 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ifaceterm.hh
|
||||
@@ -16,6 +16,9 @@
|
||||
/// \file ifaceterm.hh
|
||||
/// \brief Add some terminal capabilities to the command-line interface (IfaceStatus)
|
||||
|
||||
+#ifndef __IFACE_TERM__
|
||||
+#define __IFACE_TERM__
|
||||
+
|
||||
#include "interface.hh"
|
||||
|
||||
#ifdef __TERMINAL__
|
||||
@@ -48,3 +51,5 @@ class IfaceTerm : public IfaceStatus {
|
||||
virtual void popScript(void);
|
||||
virtual bool isStreamFinished(void) const;
|
||||
};
|
||||
+
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh
|
||||
index 2245840a0..490abf901 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/raw_arch.hh
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
/// \file raw_arch.hh
|
||||
/// \brief Bare bones capability for treating a file as a raw executable image
|
||||
+
|
||||
+#ifndef __RAW_ARCH__
|
||||
+#define __RAW_ARCH__
|
||||
+
|
||||
#include "sleigh_arch.hh"
|
||||
#include "loadimage.hh"
|
||||
|
||||
@@ -46,3 +50,4 @@ class RawBinaryArchitecture : public SleighArchitecture {
|
||||
virtual ~RawBinaryArchitecture(void) {}
|
||||
};
|
||||
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh
|
||||
index 91e12244b..2b18e10fc 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.hh
|
||||
@@ -16,6 +16,9 @@
|
||||
/// \file slgh_compile.hh
|
||||
/// \brief High-level control of the sleigh compilation process
|
||||
|
||||
+#ifndef __SLGH_COMPILE__
|
||||
+#define __SLGH_COMPILE__
|
||||
+
|
||||
#include "sleighbase.hh"
|
||||
#include "pcodecompile.hh"
|
||||
#include "filemanage.hh"
|
||||
@@ -450,3 +453,5 @@ class SleighCompile : public SleighBase {
|
||||
|
||||
extern SleighCompile *slgh; ///< A global reference to the SLEIGH compiler accessible to the parse functions
|
||||
extern int yydebug; ///< Debug state for the SLEIGH parse functions
|
||||
+
|
||||
+#endif
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh
|
||||
index d395fb8a3..6371148b0 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/xml_arch.hh
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
/// \file xml_arch.hh
|
||||
/// \brief Extension to read executables based on an XML format
|
||||
+
|
||||
+#ifndef __XML_ARCH__
|
||||
+#define __XML_ARCH__
|
||||
+
|
||||
#include "sleigh_arch.hh"
|
||||
#include "loadimage_xml.hh"
|
||||
|
||||
@@ -45,3 +49,5 @@ class XmlArchitecture : public SleighArchitecture {
|
||||
XmlArchitecture(const string &fname,const string &targ,ostream *estream); ///< Constructor
|
||||
virtual ~XmlArchitecture(void) {}
|
||||
};
|
||||
+
|
||||
+#endif
|
||||
--
|
||||
2.40.0
|
||||
|
||||
+34
-34
@@ -1,7 +1,7 @@
|
||||
From fe9ae9a6a60d2e8560b3de62e375ffde322d56b2 Mon Sep 17 00:00:00 2001
|
||||
From 098585db4fa8c8eb9184851a40ef6706f1d176ed Mon Sep 17 00:00:00 2001
|
||||
From: Alex Cameron <asc@tetsuo.sh>
|
||||
Date: Mon, 7 Feb 2022 02:02:03 +1100
|
||||
Subject: [PATCH 2/7] Fix UBSAN errors in decompiler
|
||||
Subject: [PATCH 1/3] Fix UBSAN errors in decompiler
|
||||
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/address.cc | 4 ++--
|
||||
@@ -20,10 +20,10 @@ Subject: [PATCH 2/7] Fix UBSAN errors in decompiler
|
||||
13 files changed, 59 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
|
||||
index 26694b558..395fee432 100644
|
||||
index 2eb08b96a..07bf3ba55 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
|
||||
@@ -685,7 +685,7 @@ uintb sign_extend(uintb in,int4 sizein,int4 sizeout)
|
||||
@@ -687,7 +687,7 @@ uintb sign_extend(uintb in,int4 sizein,int4 sizeout)
|
||||
void sign_extend(intb &val,int4 bit)
|
||||
|
||||
{
|
||||
@@ -32,7 +32,7 @@ index 26694b558..395fee432 100644
|
||||
mask = (~mask)<<bit;
|
||||
if (((val>>bit)&1)!=0)
|
||||
val |= mask;
|
||||
@@ -699,7 +699,7 @@ void sign_extend(intb &val,int4 bit)
|
||||
@@ -701,7 +701,7 @@ void sign_extend(intb &val,int4 bit)
|
||||
void zero_extend(intb &val,int4 bit)
|
||||
|
||||
{
|
||||
@@ -42,10 +42,10 @@ index 26694b558..395fee432 100644
|
||||
mask <<= 1;
|
||||
val &= (~mask);
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
index 0f8c95d60..95ab4b0ee 100644
|
||||
index 1402bbd80..4b271e055 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/fspec.cc
|
||||
@@ -2659,8 +2659,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
|
||||
@@ -2661,8 +2661,12 @@ void ProtoModelMerged::decode(Decoder &decoder)
|
||||
modellist.push_back(mymodel);
|
||||
}
|
||||
decoder.closeElement(elemId);
|
||||
@@ -61,10 +61,10 @@ index 0f8c95d60..95ab4b0ee 100644
|
||||
|
||||
void ParameterBasic::setTypeLock(bool val)
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
index e5b85187d..a13b146df 100644
|
||||
index f77817073..283d81c31 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/funcdata_varnode.cc
|
||||
@@ -501,7 +501,13 @@ void Funcdata::setHighLevel(void)
|
||||
@@ -503,7 +503,13 @@ void Funcdata::setHighLevel(void)
|
||||
void Funcdata::transferVarnodeProperties(Varnode *vn,Varnode *newVn,int4 lsbOffset)
|
||||
|
||||
{
|
||||
@@ -80,10 +80,10 @@ index e5b85187d..a13b146df 100644
|
||||
uint4 vnFlags = vn->getFlags() & (Varnode::directwrite|Varnode::addrforce);
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
index 00962c6b3..71fd0047e 100644
|
||||
index 0e3decc80..403ec35a7 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
|
||||
@@ -670,7 +670,11 @@ uintb PcodeOp::getNZMaskLocal(bool cliploop) const
|
||||
@@ -672,7 +672,11 @@ uintb PcodeOp::getNZMaskLocal(bool cliploop) const
|
||||
break;
|
||||
case CPUI_PIECE:
|
||||
resmask = getIn(0)->getNZMask();
|
||||
@@ -97,10 +97,10 @@ index 00962c6b3..71fd0047e 100644
|
||||
break;
|
||||
case CPUI_INT_MULT:
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
index bbf2de8f5..add0487b7 100644
|
||||
index fcd75cc7d..6da2a2a7c 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/opbehavior.cc
|
||||
@@ -748,7 +748,13 @@ uintb OpBehaviorPiece::evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb i
|
||||
@@ -750,7 +750,13 @@ uintb OpBehaviorPiece::evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb i
|
||||
uintb OpBehaviorSubpiece::evaluateBinary(int4 sizeout,int4 sizein,uintb in1,uintb in2) const
|
||||
|
||||
{
|
||||
@@ -116,10 +116,10 @@ index bbf2de8f5..add0487b7 100644
|
||||
}
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
index 49128f7e6..133da8178 100644
|
||||
index ca9d71ab9..85d4dd281 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/pcodecompile.cc
|
||||
@@ -619,8 +619,10 @@ vector<OpTpl *> *PcodeCompile::assignBitRange(VarnodeTpl *vn,uint4 bitoffset,uin
|
||||
@@ -621,8 +621,10 @@ vector<OpTpl *> *PcodeCompile::assignBitRange(VarnodeTpl *vn,uint4 bitoffset,uin
|
||||
uint4 smallsize = (numbits+7)/8; // Size of input (output of rhs)
|
||||
bool shiftneeded = (bitoffset != 0);
|
||||
bool zextneeded = true;
|
||||
@@ -132,7 +132,7 @@ index 49128f7e6..133da8178 100644
|
||||
|
||||
if (vn->getSize().getType()==ConstTpl::real) {
|
||||
// If we know the size of the bitranged varnode, we can
|
||||
@@ -724,9 +726,6 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
|
||||
@@ -726,9 +728,6 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ index 49128f7e6..133da8178 100644
|
||||
if (truncneeded && ((bitoffset % 8)==0)) {
|
||||
truncshift = bitoffset/8;
|
||||
bitoffset = 0;
|
||||
@@ -749,8 +748,13 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
|
||||
@@ -751,8 +750,13 @@ ExprTree *PcodeCompile::createBitRange(SpecificSymbol *sym,uint4 bitoffset,uint4
|
||||
appendOp(CPUI_INT_RIGHT,res,bitoffset,4);
|
||||
if (truncneeded)
|
||||
appendOp(CPUI_SUBPIECE,res,truncshift,4);
|
||||
@@ -159,10 +159,10 @@ index 49128f7e6..133da8178 100644
|
||||
return res;
|
||||
}
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
index 036583ad6..ccc2980e4 100644
|
||||
index f11ab8dea..66a0b32fc 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ruleaction.cc
|
||||
@@ -974,7 +974,12 @@ int4 RulePullsubIndirect::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -976,7 +976,12 @@ int4 RulePullsubIndirect::applyOp(PcodeOp *op,Funcdata &data)
|
||||
Varnode *outvn = op->getOut();
|
||||
if (outvn->isPrecisLo()||outvn->isPrecisHi()) return 0; // Don't pull apart double precision object
|
||||
|
||||
@@ -176,7 +176,7 @@ index 036583ad6..ccc2980e4 100644
|
||||
consume = ~consume;
|
||||
if ((consume & indir->getIn(0)->getConsume())!=0) return 0;
|
||||
|
||||
@@ -6776,8 +6781,9 @@ int4 RulePtrsubCharConstant::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -6778,8 +6783,9 @@ int4 RulePtrsubCharConstant::applyOp(PcodeOp *op,Funcdata &data)
|
||||
Varnode *sb = op->getIn(0);
|
||||
Datatype *sbType = sb->getTypeReadFacing(op);
|
||||
if (sbType->getMetatype() != TYPE_PTR) return 0;
|
||||
@@ -188,7 +188,7 @@ index 036583ad6..ccc2980e4 100644
|
||||
Varnode *vn1 = op->getIn(1);
|
||||
if (!vn1->isConstant()) return 0;
|
||||
Varnode *outvn = op->getOut();
|
||||
@@ -8507,7 +8513,11 @@ int4 RuleSubvarSubpiece::applyOp(PcodeOp *op,Funcdata &data)
|
||||
@@ -8509,7 +8515,11 @@ int4 RuleSubvarSubpiece::applyOp(PcodeOp *op,Funcdata &data)
|
||||
Varnode *outvn = op->getOut();
|
||||
int4 flowsize = outvn->getSize();
|
||||
uintb mask = calc_mask( flowsize );
|
||||
@@ -202,10 +202,10 @@ index 036583ad6..ccc2980e4 100644
|
||||
if (!aggressive) {
|
||||
if ((vn->getConsume() & mask) != vn->getConsume()) return 0;
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
index ecebc0970..1c9ab7560 100644
|
||||
index 2e3531ea2..42482be7c 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.cc
|
||||
@@ -20,6 +20,7 @@ ConstTpl::ConstTpl(const_type tp)
|
||||
@@ -22,6 +22,7 @@ ConstTpl::ConstTpl(const_type tp)
|
||||
|
||||
{ // Constructor for relative jump constants and uniques
|
||||
type = tp;
|
||||
@@ -213,7 +213,7 @@ index ecebc0970..1c9ab7560 100644
|
||||
}
|
||||
|
||||
ConstTpl::ConstTpl(const_type tp,uintb val)
|
||||
@@ -54,6 +55,7 @@ ConstTpl::ConstTpl(AddrSpace *sid)
|
||||
@@ -56,6 +57,7 @@ ConstTpl::ConstTpl(AddrSpace *sid)
|
||||
{
|
||||
type = spaceid;
|
||||
value.spaceid = sid;
|
||||
@@ -222,10 +222,10 @@ index ecebc0970..1c9ab7560 100644
|
||||
|
||||
bool ConstTpl::isConstSpace(void) const
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
index 3b836244c..1fbd169c9 100644
|
||||
index 8e283dca0..652600c16 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/semantics.hh
|
||||
@@ -46,7 +46,7 @@ class ConstTpl {
|
||||
@@ -48,7 +48,7 @@ class ConstTpl {
|
||||
static void printHandleSelector(ostream &s,v_field val);
|
||||
static v_field readHandleSelector(const string &name);
|
||||
public:
|
||||
@@ -235,10 +235,10 @@ index 3b836244c..1fbd169c9 100644
|
||||
type=op2.type; value=op2.value; value_real=op2.value_real; select=op2.select; }
|
||||
ConstTpl(const_type tp,uintb val);
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
index df6cbe4e4..c7c9e12a0 100644
|
||||
index b40f74389..3c37958df 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slgh_compile.cc
|
||||
@@ -2160,8 +2160,8 @@ string SleighCompile::checkSymbols(SymbolScope *scope)
|
||||
@@ -2163,8 +2163,8 @@ string SleighCompile::checkSymbols(SymbolScope *scope)
|
||||
ostringstream msg;
|
||||
SymbolTree::const_iterator iter;
|
||||
for(iter=scope->begin();iter!=scope->end();++iter) {
|
||||
@@ -249,10 +249,10 @@ index df6cbe4e4..c7c9e12a0 100644
|
||||
msg << " Label <" << sym->getName() << "> was placed but not used" << endl;
|
||||
else if (!sym->isPlaced())
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
index 8516dbf10..352a0ae99 100644
|
||||
index b308e1b71..af2982aee 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghsymbol.cc
|
||||
@@ -2566,7 +2566,7 @@ void ContextOp::restoreXml(const Element *el,SleighBase *trans)
|
||||
@@ -2569,7 +2569,7 @@ void ContextOp::restoreXml(const Element *el,SleighBase *trans)
|
||||
const List &list(el->getChildren());
|
||||
List::const_iterator iter;
|
||||
iter = list.begin();
|
||||
@@ -262,10 +262,10 @@ index 8516dbf10..352a0ae99 100644
|
||||
}
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
index b35dcc339..17712a0fd 100644
|
||||
index f1c0b6452..68de180fc 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/type.cc
|
||||
@@ -3294,8 +3294,8 @@ void TypeFactory::recalcPointerSubmeta(Datatype *base,sub_metatype sub)
|
||||
@@ -3296,8 +3296,8 @@ void TypeFactory::recalcPointerSubmeta(Datatype *base,sub_metatype sub)
|
||||
top.submeta = sub; // Search on the incorrect submeta
|
||||
iter = tree.lower_bound(&top);
|
||||
while(iter != tree.end()) {
|
||||
@@ -276,10 +276,10 @@ index b35dcc339..17712a0fd 100644
|
||||
++iter;
|
||||
if (ptr->submeta == sub) {
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
index f88b4d000..3b16ed13c 100644
|
||||
index c35bde877..061e53677 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/unittests/testfloatemu.cc
|
||||
@@ -343,7 +343,7 @@ TEST(float_opTrunc_to_int) {
|
||||
@@ -346,7 +346,7 @@ TEST(float_opTrunc_to_int) {
|
||||
|
||||
for(float f:float_test_values) {
|
||||
// avoid undefined behavior
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
From fca2c49381bdcc38ae46c6ec0700ab488e7762bc Mon Sep 17 00:00:00 2001
|
||||
From a2d412ce5edb750ee1f768a4a7ebfeaece6f7976 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Cameron <asc@tetsuo.sh>
|
||||
Date: Wed, 3 Aug 2022 20:01:18 +1000
|
||||
Subject: [PATCH 3/7] Use `stroull` instead of `stroul` to parse address
|
||||
Subject: [PATCH 2/3] Use `stroull` instead of `stroul` to parse address
|
||||
offsets
|
||||
|
||||
---
|
||||
@@ -9,7 +9,7 @@ Subject: [PATCH 3/7] Use `stroull` instead of `stroul` to parse address
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
index b511f8919..4ae8f18a6 100644
|
||||
index bf4e1dc96..594b4583a 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/space.cc
|
||||
@@ -16,6 +16,8 @@
|
||||
@@ -18,10 +18,10 @@ index b511f8919..4ae8f18a6 100644
|
||||
|
||||
+#include <climits>
|
||||
+
|
||||
namespace ghidra {
|
||||
|
||||
AttributeId ATTRIB_BASE = AttributeId("base",89);
|
||||
AttributeId ATTRIB_DEADCODEDELAY = AttributeId("deadcodedelay",90);
|
||||
AttributeId ATTRIB_DELAY = AttributeId("delay", 91);
|
||||
@@ -288,7 +290,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const
|
||||
@@ -290,7 +292,10 @@ uintb AddrSpace::read(const string &s,int4 &size) const
|
||||
}
|
||||
}
|
||||
catch(LowlevelError &err) { // Name doesn't exist
|
||||
@@ -0,0 +1,42 @@
|
||||
From 166e7aa2c37f51e48fb945e9b519b4997bbd4a57 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Mon, 10 Apr 2023 10:07:36 -0400
|
||||
Subject: [PATCH 3/3] Fix C++ sleighexample compilation
|
||||
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/sleighexample.cc | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/sleighexample.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/sleighexample.cc
|
||||
index 87a4d7980..f356825c9 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/sleighexample.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/sleighexample.cc
|
||||
@@ -22,6 +22,11 @@
|
||||
#include "emulate.hh"
|
||||
#include <iostream>
|
||||
|
||||
+using std::cerr;
|
||||
+using std::cout;
|
||||
+
|
||||
+namespace ghidra {
|
||||
+
|
||||
// These are the bytes for an example x86 binary
|
||||
// These bytes are loaded at address 0x80483b4
|
||||
static uint1 myprog[] = {
|
||||
@@ -283,9 +288,13 @@ static void doEmulation(Translate &trans,LoadImage &loader)
|
||||
} while(!emulater.getHalt());
|
||||
}
|
||||
|
||||
+} // End namespace ghidra
|
||||
+
|
||||
int main(int argc,char **argv)
|
||||
|
||||
{
|
||||
+ using namespace ghidra;
|
||||
+
|
||||
if (argc != 2) {
|
||||
cerr << "USAGE: " << argv[0] << " disassemble" << endl;
|
||||
cerr << " " << argv[0] << " pcode" << endl;
|
||||
--
|
||||
2.40.0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,51 +0,0 @@
|
||||
From 7f8f5fade8313ae50d8d9c38374495a706442a5b Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Wed, 15 Mar 2023 23:04:28 -0400
|
||||
Subject: [PATCH 6/7] (3/4) decompiler: Manually fix std namespace in generated
|
||||
file
|
||||
|
||||
We must manually fix the symbols from std namespace because the
|
||||
automated tool does not know how to parse yacc/bison files.
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/slghparse.y | 14 +++++++-------
|
||||
1 file changed, 7 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/slghparse.y b/Ghidra/Features/Decompiler/src/decompile/cpp/slghparse.y
|
||||
index ac10267fc..37eb2485b 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/slghparse.y
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/slghparse.y
|
||||
@@ -32,24 +32,24 @@ using namespace std;
|
||||
char ch;
|
||||
uintb *i;
|
||||
intb *big;
|
||||
- string *str;
|
||||
- vector<string> *strlist;
|
||||
- vector<intb> *biglist;
|
||||
- vector<ExprTree *> *param;
|
||||
+ std::string *str;
|
||||
+ std::vector<std::string> *strlist;
|
||||
+ std::vector<intb> *biglist;
|
||||
+ std::vector<ExprTree *> *param;
|
||||
SpaceQuality *spacequal;
|
||||
FieldQuality *fieldqual;
|
||||
StarQuality *starqual;
|
||||
VarnodeTpl *varnode;
|
||||
ExprTree *tree;
|
||||
- vector<OpTpl *> *stmt;
|
||||
+ std::vector<OpTpl *> *stmt;
|
||||
ConstructTpl *sem;
|
||||
SectionVector *sectionstart;
|
||||
Constructor *construct;
|
||||
PatternEquation *pateq;
|
||||
PatternExpression *patexp;
|
||||
|
||||
- vector<SleighSymbol *> *symlist;
|
||||
- vector<ContextChange *> *contop;
|
||||
+ std::vector<SleighSymbol *> *symlist;
|
||||
+ std::vector<ContextChange *> *contop;
|
||||
SleighSymbol *anysym;
|
||||
SpaceSymbol *spacesym;
|
||||
SectionSymbol *sectionsym;
|
||||
--
|
||||
2.40.0
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
From 15d9436abcbb286365efdef5ddeac865850d158a Mon Sep 17 00:00:00 2001
|
||||
From: Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||
Date: Wed, 15 Mar 2023 23:10:22 -0400
|
||||
Subject: [PATCH 7/7] (4/4) decompiler: Manually fix missed std variable usage
|
||||
|
||||
Unfortunately, the heuristics in remusing are unable to automatically
|
||||
fix this case of variables from the C++ standard library.
|
||||
|
||||
This was fixed by resolving the error(s) produced by the compiler.
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.hh | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.hh
|
||||
index 64fd45e35..428319a65 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/ghidra_process.hh
|
||||
@@ -79,7 +79,7 @@ class GhidraCommand {
|
||||
virtual void loadParameters(void); ///< Read parameters directing command execution
|
||||
virtual void sendResult(void); ///< Send results of the command (if any) back to the Ghidra client
|
||||
public:
|
||||
- GhidraCommand(void) : sin(cin),sout(cout) {
|
||||
+ GhidraCommand(void) : sin(std::cin),sout(std::cout) {
|
||||
ghidra = (ArchitectureGhidra *)0;
|
||||
} ///< Construct given i/o streams
|
||||
virtual ~GhidraCommand(void) {} ///< Destructor
|
||||
--
|
||||
2.40.0
|
||||
|
||||
@@ -54,20 +54,16 @@ if("${sleigh_RELEASE_TYPE}" STREQUAL "HEAD")
|
||||
# TODO: CMake only likes numeric characters in the version string....
|
||||
set(ghidra_head_version "10.3")
|
||||
set(ghidra_version "${ghidra_head_version}")
|
||||
set(ghidra_head_git_tag "ca9a56b5f4d51eb2fb0ab66afe801aba30836591")
|
||||
set(ghidra_head_git_tag "85cc8ee883aad9c3bede7e62a0ffb75a1238989c")
|
||||
set(ghidra_git_tag "${ghidra_head_git_tag}")
|
||||
set(ghidra_shallow FALSE)
|
||||
set(ghidra_patches
|
||||
PATCH_COMMAND "${GIT_EXECUTABLE}" config user.name "${ghidra_patch_user}" &&
|
||||
"${GIT_EXECUTABLE}" config user.email "${ghidra_patch_email}" &&
|
||||
"${GIT_EXECUTABLE}" am --ignore-space-change --ignore-whitespace --no-gpg-sign
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0001-Add-include-guards-to-decompiler-C-headers.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0002-Fix-UBSAN-errors-in-decompiler.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0003-Use-stroull-instead-of-stroul-to-parse-address-offse.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0004-1-4-decompiler-Add-using-namespace-std-to-all-.cc-fi.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0005-2-4-decompiler-Automated-std-namespace-fix-with-remu.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0006-3-4-decompiler-Manually-fix-std-namespace-in-generat.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0007-4-4-decompiler-Manually-fix-missed-std-variable-usag.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0001-Fix-UBSAN-errors-in-decompiler.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0002-Use-stroull-instead-of-stroul-to-parse-address-offse.patch"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/patches/HEAD/0003-Fix-C-sleighexample-compilation.patch"
|
||||
)
|
||||
string(SUBSTRING "${ghidra_git_tag}" 0 7 ghidra_short_commit)
|
||||
else()
|
||||
|
||||
@@ -93,7 +93,13 @@
|
||||
#include <sleigh/sleigh_arch.hh>
|
||||
#include <sleigh/sleighbase.hh>
|
||||
#include <sleigh/slgh_compile.hh>
|
||||
#ifdef sleigh_RELEASE_IS_HEAD
|
||||
namespace ghidra {
|
||||
#endif
|
||||
#include <sleigh/slghparse.hh>
|
||||
#ifdef sleigh_RELEASE_IS_HEAD
|
||||
} // End namespace ghidra
|
||||
#endif
|
||||
#include <sleigh/slghpatexpress.hh>
|
||||
#include <sleigh/slghpattern.hh>
|
||||
#include <sleigh/slghsymbol.hh>
|
||||
|
||||
Reference in New Issue
Block a user