mirror of
https://github.com/radareorg/r2ghidra.git
synced 2026-11-07 06:25:57 -10:00
Consume ghidra-native's own patches instead of a private copy
Point the ghidra-native wrap at the fork (feature/r2ghidra-patches, which ships the patches/ and the patched src/) and drop the private subprojects/packagefiles/ghidra-native/patches copy plus the diff_files list. The decompiler now builds from ghidra-native's patched source directly. Note: the wrap url/revision point at the kkuehl fork until the ghidra-native PR merges to radareorg/ghidra-native; then re-point at the upstream commit.
This commit is contained in:
1 parent
a47158ce76
commit
f6a5cf8b4b
32 files changed
+2
-1061
No files matched your search
@@ -1,7 +1,6 @@
|
||||
[wrap-git]
|
||||
url = https://github.com/radareorg/ghidra-native
|
||||
revision = 483ae94bcbc661a77667e52f1eff75928cb6aa2e
|
||||
url = https://github.com/kkuehl/ghidra-native
|
||||
revision = eb4573e45b890fd3799fa66e64d5ccdbafaea6ff
|
||||
directory = ghidra-native
|
||||
patch_directory = ghidra-native
|
||||
diff_files = ghidra-native/patches/0001-space-after-comma.patch, ghidra-native/patches/0002-make-sleigharch-public.patch, ghidra-native/patches/0004-public-fields.patch, ghidra-native/patches/0006-readonly-warning.patch, ghidra-native/patches/0010-null-subflow.patch, ghidra-native/patches/0020-Fix-double-free-crash-when-deinitializing-multiple-X.patch, ghidra-native/patches/0023-Undef-LoadImage-for-windows.patch, ghidra-native/patches/0044-bad-unicode-codepoint.patch, ghidra-native/patches/0055-datatype-clone.patch, ghidra-native/patches/0056-nullderef-workaround.patch, ghidra-native/patches/0080-getparent-flow.patch, ghidra-native/patches/0090-nocasts-warnings.patch, ghidra-native/patches/0091-decompiler-xml-packer.patch, ghidra-native/patches/0092-badvar-segfault.patch, ghidra-native/patches/0093-no-virtual-destructor.patch, ghidra-native/patches/0094-parse-64bit-integers.patch, ghidra-native/patches/0100-CHAR-windows.patch, ghidra-native/patches/ghidra-native.patch
|
||||
depth = 1
|
||||
@@ -1,22 +0,0 @@
|
||||
diff --git a/src/decompiler/printc.cc b/src/decompiler/printc.cc
|
||||
index b2637c1..eac56f7 100644
|
||||
--- a/src/decompiler/printc.cc
|
||||
+++ b/src/decompiler/printc.cc
|
||||
@@ -54,7 +54,7 @@ OpToken PrintC::boolean_and = { "&&", "", 2, 22, false, OpToken::binary, 1, 0, (
|
||||
OpToken PrintC::boolean_xor = { "^^", "", 2, 20, false, OpToken::binary, 1, 0, (OpToken *)0 };
|
||||
OpToken PrintC::boolean_or = { "||", "", 2, 18, false, OpToken::binary, 1, 0, (OpToken *)0 };
|
||||
OpToken PrintC::assignment = { "=", "", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 };
|
||||
-OpToken PrintC::comma = { ",", "", 2, 2, true, OpToken::binary, 0, 0, (OpToken *)0 };
|
||||
+OpToken PrintC::comma = { ", ", "", 2, 2, true, OpToken::binary, 0, 0, (OpToken *)0 };
|
||||
OpToken PrintC::new_op = { "", "", 2, 62, false, OpToken::space, 1, 0, (OpToken *)0 };
|
||||
|
||||
// Inplace assignment operators
|
||||
@@ -82,7 +82,7 @@ const string PrintC::CLOSE_CURLY = "}";
|
||||
const string PrintC::SEMICOLON = ";";
|
||||
const string PrintC::COLON = ":";
|
||||
const string PrintC::EQUALSIGN = "=";
|
||||
-const string PrintC::COMMA = ",";
|
||||
+const string PrintC::COMMA = ", ";
|
||||
const string PrintC::DOTDOTDOT = "...";
|
||||
const string PrintC::KEYWORD_VOID = "void";
|
||||
const string PrintC::KEYWORD_TRUE = "true";
|
||||
@@ -1,21 +0,0 @@
|
||||
diff --git a/src/decompiler/sleigh_arch.hh b/src/decompiler/sleigh_arch.hh
|
||||
index 5b40bdf..397d483 100644
|
||||
--- a/src/decompiler/sleigh_arch.hh
|
||||
+++ b/src/decompiler/sleigh_arch.hh
|
||||
@@ -116,7 +116,6 @@ class SleighArchitecture : public Architecture {
|
||||
protected:
|
||||
ostream *errorstream; ///< Error stream associated with \b this SleighArchitecture
|
||||
// buildLoader must be filled in by derived class
|
||||
- static void collectSpecFiles(ostream &errs); ///< Gather specification files in normal locations
|
||||
virtual Translate *buildTranslator(DocumentStorage &store);
|
||||
virtual PcodeInjectLibrary *buildPcodeInjectLibrary(void);
|
||||
virtual void buildTypegrp(DocumentStorage &store);
|
||||
@@ -138,6 +137,8 @@ public:
|
||||
virtual void printWarning(const string &message) const;
|
||||
virtual ~SleighArchitecture(void);
|
||||
virtual string getDescription(void) const;
|
||||
+ static void collectSpecFiles(ostream &errs); ///< Gather specification files in normal locations
|
||||
+ static const vector<LanguageDescription> &getLanguageDescriptions() { return description; }
|
||||
|
||||
static string normalizeProcessor(const string &nm); ///< Try to recover a \e language \e id processor field
|
||||
static string normalizeEndian(const string &nm); ///< Try to recover a \e language \e id endianness field
|
||||
@@ -1,37 +0,0 @@
|
||||
diff --git a/src/decompiler/context.hh b/src/decompiler/context.hh
|
||||
index abe1701..b3d9d45 100644
|
||||
--- a/src/decompiler/context.hh
|
||||
+++ b/src/decompiler/context.hh
|
||||
@@ -124,6 +124,8 @@ private:
|
||||
ConstructState *base_state; ///< Root node of the constructor tree
|
||||
int4 alloc; ///< Number of unallocated ConstructState nodes remaining
|
||||
int4 delayslot; ///< delayslot depth
|
||||
+protected:
|
||||
+ ConstructState **getBaseState(void) { return &base_state; }
|
||||
public:
|
||||
ParserContext(ContextCache *ccache,Translate *trans); ///< Constructor
|
||||
~ParserContext(void); ///< Destructor
|
||||
diff --git a/src/decompiler/sleigh.hh b/src/decompiler/sleigh.hh
|
||||
index 95249cf..379ee73 100644
|
||||
--- a/src/decompiler/sleigh.hh
|
||||
+++ b/src/decompiler/sleigh.hh
|
||||
@@ -170,6 +170,7 @@ protected:
|
||||
ParserContext *obtainContext(const Address &addr,ParserContext::parse_state state) const;
|
||||
void resolve(ParserContext &pos) const; ///< Generate a parse tree suitable for disassembly
|
||||
void resolveHandles(ParserContext &pos) const; ///< Prepare the parse tree for p-code generation
|
||||
+ ContextCache *getContextCache(void) { return cache; }
|
||||
public:
|
||||
Sleigh(LoadImage *ld,ContextDatabase *c_db); ///< Constructor
|
||||
virtual ~Sleigh(void); ///< Destructor
|
||||
diff --git a/src/decompiler/type.hh b/src/decompiler/type.hh
|
||||
index cc0951c..d7b7533 100644
|
||||
--- a/src/decompiler/type.hh
|
||||
+++ b/src/decompiler/type.hh
|
||||
@@ -861,6 +861,7 @@ class TypeFactory {
|
||||
void insertWarning(Datatype *dt,string warn); ///< Register a new data-type warning with \b this factory
|
||||
void removeWarning(Datatype *dt); ///< Remove the warning associated with the given data-type
|
||||
void resolveIncompleteTypedefs(void); ///< Redefine incomplete typedefs of data-types that are now complete
|
||||
+public:
|
||||
void setFields(const vector<TypeField> &fd,const vector<TypeBitField> &bit,TypeStruct *ot,int4 newSize,int4 newAlign,uint4 flags);
|
||||
void setFields(const vector<TypeField> &fd,TypeUnion *ot,int4 newSize,int4 newAlign,uint4 flags); ///< Set fields on a TypeUnion
|
||||
protected:
|
||||
@@ -1,20 +0,0 @@
|
||||
diff --git a/src/decompiler/funcdata_varnode.cc b/src/decompiler/funcdata_varnode.cc
|
||||
index dad2994..5a43b1d 100644
|
||||
--- a/src/decompiler/funcdata_varnode.cc
|
||||
+++ b/src/decompiler/funcdata_varnode.cc
|
||||
@@ -516,6 +516,7 @@ void Funcdata::transferVarnodeProperties(Varnode *vn,Varnode *newVn,int4 lsbOffs
|
||||
bool Funcdata::fillinReadOnly(Varnode *vn)
|
||||
|
||||
{
|
||||
+/*
|
||||
if (vn->isWritten()) { // Can't replace output with constant
|
||||
PcodeOp *defop = vn->getDef();
|
||||
if (defop->isMarker())
|
||||
@@ -534,6 +535,7 @@ bool Funcdata::fillinReadOnly(Varnode *vn)
|
||||
}
|
||||
return false; // No change was made
|
||||
}
|
||||
+*/
|
||||
|
||||
if (vn->getSize() > sizeof(uintb))
|
||||
return false; // Constant will exceed precision
|
||||
@@ -1,14 +0,0 @@
|
||||
diff --git a/src/decompiler/subflow.cc b/src/decompiler/subflow.cc
|
||||
index 0c42b50..522c435 100644
|
||||
--- a/src/decompiler/subflow.cc
|
||||
+++ b/src/decompiler/subflow.cc
|
||||
@@ -66,6 +66,9 @@ SubvariableFlow::ReplaceVarnode *SubvariableFlow::setReplacement(Varnode *vn,uin
|
||||
|
||||
{
|
||||
ReplaceVarnode *res;
|
||||
+ if (vn == nullptr) {
|
||||
+ return nullptr;
|
||||
+ }
|
||||
if (vn->isMark()) { // Already seen before
|
||||
map<Varnode *,ReplaceVarnode>::iterator iter;
|
||||
iter = varmap.find(vn);
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
diff --git a/src/decompiler/xml.cc b/src/decompiler/xml.cc
|
||||
index 6831da5..fb4a87c 100644
|
||||
--- a/src/decompiler/xml.cc
|
||||
+++ b/src/decompiler/xml.cc
|
||||
@@ -101,7 +101,6 @@
|
||||
|
||||
namespace ghidra {
|
||||
|
||||
-string Attributes::bogus_uri("http://unused.uri");
|
||||
|
||||
/// \brief The XML character scanner
|
||||
///
|
||||
diff --git a/src/decompiler/xml.hh b/src/decompiler/xml.hh
|
||||
index 7253301..3fff761 100644
|
||||
--- a/src/decompiler/xml.hh
|
||||
+++ b/src/decompiler/xml.hh
|
||||
@@ -42,8 +42,8 @@ using std::hex;
|
||||
/// This object is used to initialize the Element object but is not part of the final, in memory, DOM model.
|
||||
/// This also holds other properties of the element that are unused in this implementation,
|
||||
/// including the \e namespace URI.
|
||||
+#define bogus_uri "http://unused.uri"
|
||||
class Attributes {
|
||||
- static string bogus_uri; ///< A placeholder for the namespace URI that should be attached to the element
|
||||
// static string prefix;
|
||||
string *elementname; ///< The name of the XML element
|
||||
vector<string *> name; ///< List of names for each formal XML attribute
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
diff --git a/src/decompiler/prettyprint.cc b/src/decompiler/prettyprint.cc
|
||||
index 3e8d18a..6b98d02 100644
|
||||
--- a/src/decompiler/prettyprint.cc
|
||||
+++ b/src/decompiler/prettyprint.cc
|
||||
@@ -174,6 +174,14 @@ void EmitMarkup::tagOp(const string &name,syntax_highlight hl,const PcodeOp *op)
|
||||
encoder->closeElement(ELEM_OP);
|
||||
}
|
||||
|
||||
+/// \brief Emit a function noreturn identifier
|
||||
+///
|
||||
+/// An identifier string representing noreturn information of the function is emitted
|
||||
+void EmitMarkup::tagNoreturn(void)
|
||||
+{
|
||||
+ *s << "<noreturn " << highlight[(int4)no_color] << '>' << " noreturn </noreturn>";
|
||||
+}
|
||||
+
|
||||
void EmitMarkup::tagFuncName(const string &name,syntax_highlight hl,const Funcdata *fd,const PcodeOp *op)
|
||||
|
||||
{
|
||||
@@ -343,6 +351,9 @@ void TokenSplit::print(Emit *emit) const
|
||||
case fnam_t: // tagFuncName
|
||||
emit->tagFuncName(tok,hl,ptr_second.fd,op);
|
||||
break;
|
||||
+ case noret_t:
|
||||
+ emit->tagNoreturn();
|
||||
+ break;
|
||||
case type_t: // tagType
|
||||
emit->tagType(tok,hl,ptr_second.ct);
|
||||
break;
|
||||
@@ -973,6 +984,14 @@ void EmitPrettyPrint::tagFuncName(const string &name,syntax_highlight hl,const F
|
||||
scan();
|
||||
}
|
||||
|
||||
+void EmitPrettyPrint::tagNoreturn(void)
|
||||
+{
|
||||
+ checkstring();
|
||||
+ TokenSplit &tok( tokqueue.push() );
|
||||
+ tok.tagNoreturn();
|
||||
+ scan();
|
||||
+}
|
||||
+
|
||||
void EmitPrettyPrint::tagType(const string &name,syntax_highlight hl,const Datatype *ct)
|
||||
|
||||
{
|
||||
diff --git a/src/decompiler/prettyprint.hh b/src/decompiler/prettyprint.hh
|
||||
index 6e7124c..21f2fdf 100644
|
||||
--- a/src/decompiler/prettyprint.hh
|
||||
+++ b/src/decompiler/prettyprint.hh
|
||||
@@ -469,6 +469,7 @@ public:
|
||||
virtual void tagVariable(const string &name,syntax_highlight hl,const Varnode *vn,const PcodeOp *op);
|
||||
virtual void tagOp(const string &name,syntax_highlight hl,const PcodeOp *op);
|
||||
virtual void tagFuncName(const string &name,syntax_highlight hl,const Funcdata *fd,const PcodeOp *op);
|
||||
+ virtual void tagNoreturn(void);
|
||||
virtual void tagType(const string &name,syntax_highlight hl,const Datatype *ct);
|
||||
virtual void tagField(const string &name,syntax_highlight hl,const Datatype *ct,int4 off,const PcodeOp *op);
|
||||
virtual void tagComment(const string &name,syntax_highlight hl,const AddrSpace *spc,uintb off);
|
||||
@@ -514,6 +515,8 @@ public:
|
||||
*s << name; }
|
||||
virtual void tagFuncName(const string &name,syntax_highlight hl,const Funcdata *fd,const PcodeOp *op) {
|
||||
*s << name; }
|
||||
+ virtual void tagNoreturn(void) {
|
||||
+ *s << " noreturn ";}
|
||||
virtual void tagType(const string &name,syntax_highlight hl,const Datatype *ct) {
|
||||
*s << name; }
|
||||
virtual void tagField(const string &name,syntax_highlight hl,const Datatype *ct,int4 off,const PcodeOp *op) {
|
||||
@@ -580,6 +583,7 @@ public:
|
||||
vari_t, ///< A variable identifier
|
||||
op_t, ///< An operator
|
||||
fnam_t, ///< A function identifier
|
||||
+ noret_t, ///< A function noreturn identifier
|
||||
type_t, ///< A data-type identifier
|
||||
field_t, ///< A field name for a structured data-type
|
||||
comm_t, ///< Part of a comment block
|
||||
@@ -734,6 +738,10 @@ public:
|
||||
tok = name; size = tok.size();
|
||||
tagtype=fnam_t; delimtype=tokenstring; hl=h; ptr_second.fd=f; op=o; }
|
||||
|
||||
+ /// \brief Create a function noreturn identifiertoken
|
||||
+ void tagNoreturn(void) {
|
||||
+ tagtype=noret_t; delimtype=tokenstring; }
|
||||
+
|
||||
/// \brief Create a data-type identifier token
|
||||
///
|
||||
/// \param name is the character data for the identifier
|
||||
@@ -1015,6 +1023,7 @@ public:
|
||||
virtual void tagVariable(const string &name,syntax_highlight hl,const Varnode *vn,const PcodeOp *op);
|
||||
virtual void tagOp(const string &name,syntax_highlight hl,const PcodeOp *op);
|
||||
virtual void tagFuncName(const string &name,syntax_highlight hl,const Funcdata *fd,const PcodeOp *op);
|
||||
+ virtual void tagNoreturn(void);
|
||||
virtual void tagType(const string &name,syntax_highlight hl,const Datatype *ct);
|
||||
virtual void tagField(const string &name,syntax_highlight hl,const Datatype *ct,int4 off,const PcodeOp *op);
|
||||
virtual void tagComment(const string &name,syntax_highlight hl,const AddrSpace *spc,uintb off);
|
||||
diff --git a/src/decompiler/printc.cc b/src/decompiler/printc.cc
|
||||
index b2637c1..d7a680c 100644
|
||||
--- a/src/decompiler/printc.cc
|
||||
+++ b/src/decompiler/printc.cc
|
||||
@@ -2512,6 +2512,9 @@ void PrintC::emitFunctionDeclaration(const Funcdata *fd)
|
||||
emitSymbolScope(fd->getSymbol());
|
||||
emit->tagFuncName(fd->getDisplayName(),EmitMarkup::funcname_color,fd,(PcodeOp *)0);
|
||||
|
||||
+ if (proto->isNoReturn()) {
|
||||
+ emit->tagNoreturn();
|
||||
+ }
|
||||
emit->spaces(function_call.spacing,function_call.bump);
|
||||
int4 id2 = emit->openParen(OPEN_PAREN);
|
||||
emit->spaces(0,function_call.bump);
|
||||
@@ -1,30 +0,0 @@
|
||||
diff --git a/src/decompiler/loadimage.hh b/src/decompiler/loadimage.hh
|
||||
index 76dce9b..2df840a 100644
|
||||
--- a/src/decompiler/loadimage.hh
|
||||
+++ b/src/decompiler/loadimage.hh
|
||||
@@ -21,6 +21,10 @@
|
||||
|
||||
#include "address.hh"
|
||||
|
||||
+#ifdef LoadImage
|
||||
+#undef LoadImage
|
||||
+#endif
|
||||
+
|
||||
namespace ghidra {
|
||||
|
||||
/// \brief Exception indicating data was not available
|
||||
diff --git a/src/decompiler/sleigh.hh b/src/decompiler/sleigh.hh
|
||||
index 32ef856..f0a7461 100644
|
||||
--- a/src/decompiler/sleigh.hh
|
||||
+++ b/src/decompiler/sleigh.hh
|
||||
@@ -21,6 +21,10 @@
|
||||
|
||||
#include "sleighbase.hh"
|
||||
|
||||
+#ifdef LoadImage
|
||||
+#undef LoadImage
|
||||
+#endif
|
||||
+
|
||||
namespace ghidra {
|
||||
|
||||
class LoadImage;
|
||||
@@ -1,21 +0,0 @@
|
||||
diff --git a/src/decompiler/stringmanage.cc b/src/decompiler/stringmanage.cc
|
||||
index 6e60b4f..fb7e2eb 100644
|
||||
--- a/src/decompiler/stringmanage.cc
|
||||
+++ b/src/decompiler/stringmanage.cc
|
||||
@@ -40,14 +40,14 @@ void StringManager::writeUtf8(ostream &s,int4 codepoint)
|
||||
int4 size;
|
||||
|
||||
if (codepoint < 0)
|
||||
- throw LowlevelError("Negative unicode codepoint");
|
||||
+ return; // throw LowlevelError("Negative unicode codepoint");
|
||||
if (codepoint < 128) {
|
||||
s.put((uint1)codepoint);
|
||||
return;
|
||||
}
|
||||
int4 bits = mostsigbit_set(codepoint) + 1;
|
||||
if (bits > 21)
|
||||
- throw LowlevelError("Bad unicode codepoint");
|
||||
+ return; // throw LowlevelError("Bad unicode codepoint");
|
||||
if (bits < 12) { // Encode with two bytes
|
||||
bytes[0] = 0xc0 ^ ((codepoint >> 6)&0x1f);
|
||||
bytes[1] = 0x80 ^ (codepoint & 0x3f);
|
||||
@@ -1,18 +0,0 @@
|
||||
diff --git a/src/decompiler/type.hh b/src/decompiler/type.hh
|
||||
index cc0951c..01dc5ac 100644
|
||||
--- a/src/decompiler/type.hh
|
||||
+++ b/src/decompiler/type.hh
|
||||
@@ -204,12 +204,12 @@ protected:
|
||||
void encodeTypedef(Encoder &encoder) const; ///< Encode \b this as a \e typedef element to a stream
|
||||
void markComplete(void) { flags &= ~(uint4)type_incomplete; } ///< Mark \b this data-type as completely defined
|
||||
void setDisplayFormat(uint4 format); ///< Set a specific display format
|
||||
- virtual Datatype *clone(void) const=0; ///< Clone the data-type
|
||||
static uint8 hashName(const string &nm); ///< Produce a data-type id by hashing the type name
|
||||
static uint8 hashSize(uint8 id,int4 size); ///< Reversibly hash size into id
|
||||
protected:
|
||||
static int4 calcAlignSize(int4 sz,int4 align); ///< Calculate aligned size, given size and alignment of data-type
|
||||
public:
|
||||
+ virtual Datatype *clone(void) const=0; ///< Clone the data-type
|
||||
/// \brief Construct the base data-type copying low-level properties of another
|
||||
Datatype(const Datatype &op) { size = op.size; name=op.name; displayName=op.displayName; metatype=op.metatype;
|
||||
submeta=op.submeta; flags=op.flags; id=op.id; typedefImm=op.typedefImm; alignment=op.alignment; alignSize=op.alignSize; }
|
||||
@@ -1,12 +0,0 @@
|
||||
diff --git a/src/decompiler/merge.hh b/src/decompiler/merge.hh
|
||||
index bcce463..c965f86 100644
|
||||
--- a/src/decompiler/merge.hh
|
||||
+++ b/src/decompiler/merge.hh
|
||||
@@ -137,6 +137,7 @@ public:
|
||||
inline bool Merge::compareHighByBlock(const HighVariable *a,const HighVariable *b)
|
||||
|
||||
{
|
||||
+ if (!a || !b) return false;
|
||||
int4 result = a->getCover().compareTo(b->getCover());
|
||||
if ( result == 0 ) {
|
||||
Varnode *v1 = a->getInstance( 0 );
|
||||
@@ -1,17 +0,0 @@
|
||||
diff --git a/src/decompiler/flow.cc b/src/decompiler/flow.cc
|
||||
index 178047f..78565eb 100644
|
||||
--- a/src/decompiler/flow.cc
|
||||
+++ b/src/decompiler/flow.cc
|
||||
@@ -1006,8 +1006,10 @@ void FlowInfo::connectBasic(void)
|
||||
op = *iter++;
|
||||
targ_op = *iter2++;
|
||||
bs = op->getParent();
|
||||
- targ_bs = targ_op->getParent();
|
||||
- bblocks.addEdge(bs,targ_bs);
|
||||
+ if (targ_op != nullptr) {
|
||||
+ targ_bs = targ_op->getParent();
|
||||
+ bblocks.addEdge(bs,targ_bs);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
diff --git a/src/decompiler/printc.cc b/src/decompiler/printc.cc
|
||||
index 64ecda1..a02ca74 100644
|
||||
--- a/src/decompiler/printc.cc
|
||||
+++ b/src/decompiler/printc.cc
|
||||
@@ -3095,6 +3097,7 @@ void PrintC::emitCommentFuncHeader(const Funcdata *fd)
|
||||
emitLineComment(1,comm);
|
||||
}
|
||||
}
|
||||
+/*
|
||||
if (option_nocasts) {
|
||||
if (extralinebreak)
|
||||
emit->tagLine();
|
||||
@@ -3103,6 +3106,7 @@ void PrintC::emitCommentFuncHeader(const Funcdata *fd)
|
||||
emitLineComment(0,&comm);
|
||||
extralinebreak = true;
|
||||
}
|
||||
+*/
|
||||
if (extralinebreak)
|
||||
emit->tagLine(); // Extra linebreak if comment exists
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
diff --git a/src/decompiler/prettyprint.cc b/src/decompiler/prettyprint.cc
|
||||
index f85f018..1ec21f3 100644
|
||||
--- a/src/decompiler/prettyprint.cc
|
||||
+++ b/src/decompiler/prettyprint.cc
|
||||
@@ -345,7 +345,7 @@ void EmitMarkup::setOutputStream(ostream *t)
|
||||
if (encoder != (Encoder *)0)
|
||||
delete encoder;
|
||||
s = t;
|
||||
- encoder = new PackedEncode(*s);
|
||||
+ encoder = new XmlEncode(*s);
|
||||
}
|
||||
|
||||
void EmitMarkup::setPackedOutput(bool val)
|
||||
@@ -1,26 +0,0 @@
|
||||
diff --git a/src/decompiler/database.cc b/src/decompiler/database.cc
|
||||
index 26b68a6..0089445 100644
|
||||
--- a/src/decompiler/database.cc
|
||||
+++ b/src/decompiler/database.cc
|
||||
@@ -140,6 +140,8 @@ Datatype *MapEntry::getSizedType(const Address &inaddr,int4 sz) const
|
||||
{
|
||||
int4 off = (int4)(inaddr.getOffset() - addr.getOffset()) + offset;
|
||||
Datatype *cur = symbol->getType();
|
||||
+ if (symbol->getName().length() == 0)
|
||||
+ return nullptr;
|
||||
return symbol->getScope()->getArch()->types->getExactPiece(cur, off, sz);
|
||||
}
|
||||
|
||||
diff --git a/src/decompiler/varmap.cc b/src/decompiler/varmap.cc
|
||||
index 6d51a72..0388f3b 100644
|
||||
--- a/src/decompiler/varmap.cc
|
||||
+++ b/src/decompiler/varmap.cc
|
||||
@@ -1375,7 +1375,7 @@ void ScopeLocal::markUnaliased(const vector<uintb> &alias)
|
||||
// NOTE: this is primarily to reset aliasing between
|
||||
// stack parameters and stack locals
|
||||
if (aliason && (curoff - curalias > 0xffff)) aliason = false;
|
||||
- if (!aliason) symbol->getScope()->setAttribute(symbol,Varnode::nolocalalias);
|
||||
+ if (!aliason && symbol->getName().length () > 0) symbol->getScope()->setAttribute(symbol,Varnode::nolocalalias);
|
||||
if (symbol->isTypeLocked() && alias_block_level != 0) {
|
||||
if (alias_block_level == 3)
|
||||
aliason = false; // For this level, all locked data-types block aliases
|
||||
@@ -1,35 +0,0 @@
|
||||
diff --git a/src/decompiler/constseq.hh b/src/decompiler/constseq.hh
|
||||
index dbfc3c5..0036c53 100644
|
||||
--- a/src/decompiler/constseq.hh
|
||||
+++ b/src/decompiler/constseq.hh
|
||||
@@ -112,6 +112,7 @@ public:
|
||||
if (!grouplist.contains(getGroup())) return (Rule *)0;
|
||||
return new RuleStringCopy(getGroup());
|
||||
}
|
||||
+ virtual ~RuleStringCopy();
|
||||
virtual void getOpList(vector<uint4> &oplist) const;
|
||||
virtual int4 applyOp(PcodeOp *op,Funcdata &data);
|
||||
};
|
||||
@@ -123,6 +124,7 @@ public:
|
||||
if (!grouplist.contains(getGroup())) return (Rule *)0;
|
||||
return new RuleStringStore(getGroup());
|
||||
}
|
||||
+ virtual ~RuleStringStore();
|
||||
virtual void getOpList(vector<uint4> &oplist) const;
|
||||
virtual int4 applyOp(PcodeOp *op,Funcdata &data);
|
||||
};
|
||||
diff --git a/src/decompiler/coreaction.cc b/src/decompiler/coreaction.cc
|
||||
index bed14fc..8a808d5 100644
|
||||
--- a/src/decompiler/coreaction.cc
|
||||
+++ b/src/decompiler/coreaction.cc
|
||||
@@ -21,6 +21,10 @@
|
||||
|
||||
namespace ghidra {
|
||||
|
||||
+RuleStringCopy::~RuleStringCopy() {}
|
||||
+
|
||||
+RuleStringStore::~RuleStringStore() {}
|
||||
+
|
||||
/// \brief A stack equation
|
||||
struct StackEqn {
|
||||
int4 var1; ///< Variable with 1 coefficient
|
||||
@@ -1,26 +0,0 @@
|
||||
diff --git a/src/decompiler/slghscan.cc b/src/decompiler/slghscan.cc
|
||||
index a8545a5..cfae3d6 100644
|
||||
--- a/src/decompiler/slghscan.cc
|
||||
+++ b/src/decompiler/slghscan.cc
|
||||
@@ -1582,7 +1582,7 @@ int4 scan_number(char *numtext,SLEIGHSTYPE *lval,int4 radix,bool signednum)
|
||||
{
|
||||
uintb val;
|
||||
try {
|
||||
- val = std::stoul(numtext,(size_t *)0,radix);
|
||||
+ val = std::stoull(numtext,(size_t *)0,radix);
|
||||
}
|
||||
catch(...) {
|
||||
return BADINTEGER;
|
||||
diff --git a/src/decompiler/slghscan.l b/src/decompiler/slghscan.l
|
||||
index 1c25962..29db987 100644
|
||||
--- a/src/decompiler/slghscan.l
|
||||
+++ b/src/decompiler/slghscan.l
|
||||
@@ -461,7 +461,7 @@ int4 scan_number(char *numtext,SLEIGHSTYPE *lval,int4 radix,bool signednum)
|
||||
{
|
||||
uintb val;
|
||||
try {
|
||||
- val = std::stoul(numtext,(size_t *)0,radix);
|
||||
+ val = std::stoull(numtext,(size_t *)0,radix);
|
||||
}
|
||||
catch(...) {
|
||||
return BADINTEGER;
|
||||
@@ -1,26 +0,0 @@
|
||||
diff --git a/src/decompiler/slghparse.hh b/src/decompiler/slghparse.hh
|
||||
index 5d72496..d798b4b 100644
|
||||
--- a/src/decompiler/slghparse.hh
|
||||
+++ b/src/decompiler/slghparse.hh
|
||||
@@ -166,7 +166,7 @@ extern int sleighdebug;
|
||||
ELLIPSIS_KEY = 344, /* ELLIPSIS_KEY */
|
||||
GLOBALSET_KEY = 345, /* GLOBALSET_KEY */
|
||||
BITRANGE_KEY = 346, /* BITRANGE_KEY */
|
||||
- CHAR = 347, /* CHAR */
|
||||
+ CHARVALUE = 347, /* CHAR */
|
||||
INTEGER = 348, /* INTEGER */
|
||||
INTB = 349, /* INTB */
|
||||
STRING = 350, /* STRING */
|
||||
diff --git a/src/decompiler/slghscan.cc b/src/decompiler/slghscan.cc
|
||||
index a8545a5..9709240 100644
|
||||
--- a/src/decompiler/slghscan.cc
|
||||
+++ b/src/decompiler/slghscan.cc
|
||||
@@ -2129,7 +2129,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 61:
|
||||
YY_RULE_SETUP
|
||||
-{ sleighlval.ch = sleightext[0]; return CHAR; }
|
||||
+{ sleighlval.ch = sleightext[0]; return CHARVALUE; }
|
||||
YY_BREAK
|
||||
case 62:
|
||||
YY_RULE_SETUP
|
||||
-173
@@ -1,173 +0,0 @@
|
||||
From ce0bda47d99042322af318ecb425453279e8c7a4 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=A4rkl?= <[email protected]>
|
||||
Date: Thu, 25 Jul 2019 12:31:44 +0200
|
||||
Subject: [PATCH 07/23] Add some Formatting Options
|
||||
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/printc.cc | 60 +++++++++++++++----
|
||||
.../Decompiler/src/decompile/cpp/printc.hh | 7 +++
|
||||
2 files changed, 55 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
|
||||
index 79da4cfa3..c7e290fe8 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
|
||||
@@ -353,8 +353,9 @@ void PrintC::opFunc(const PcodeOp *op)
|
||||
string nm = op->getOpcode()->getOperatorName(op);
|
||||
pushAtom(Atom(nm,optoken,EmitXml::no_color,op));
|
||||
if (op->numInput() > 0) {
|
||||
- for(int4 i=0;i<op->numInput()-1;++i)
|
||||
- pushOp(&comma,op);
|
||||
+ for(int4 i=0;i<op->numInput()-1;++i) {
|
||||
+ pushOp(&comma,op);
|
||||
+ }
|
||||
// implied vn's pushed on in reverse order for efficiency
|
||||
// see PrintLanguage::pushVnImplied
|
||||
for(int4 i=op->numInput()-1;i>=0;--i)
|
||||
@@ -1386,6 +1387,10 @@ void PrintC::resetDefaultsPrintC(void)
|
||||
option_nocasts = false;
|
||||
option_NULL = false;
|
||||
option_unplaced = false;
|
||||
+ option_space_after_comma = false;
|
||||
+ option_newline_before_else = true;
|
||||
+ option_newline_before_opening_brace = false;
|
||||
+ option_newline_after_prototype = true;
|
||||
setCStyleComments();
|
||||
}
|
||||
|
||||
@@ -1838,6 +1843,9 @@ void PrintC::emitStructDefinition(const TypeStruct *ct)
|
||||
iter++;
|
||||
if (iter != ct->endField()) {
|
||||
emit->print(","); // Print comma separator
|
||||
+ if (option_space_after_comma) {
|
||||
+ emit->spaces(1);
|
||||
+ }
|
||||
emit->tagLine();
|
||||
}
|
||||
}
|
||||
@@ -1935,8 +1943,12 @@ void PrintC::emitPrototypeInputs(const FuncProto *proto)
|
||||
else {
|
||||
bool printComma = false;
|
||||
for(int4 i=0;i<sz;++i) {
|
||||
- if (printComma)
|
||||
- emit->print(",");
|
||||
+ if (printComma) {
|
||||
+ emit->print(",");
|
||||
+ if (option_space_after_comma) {
|
||||
+ emit->spaces(1);
|
||||
+ }
|
||||
+ }
|
||||
ProtoParameter *param = proto->getParam(i);
|
||||
if (isSet(hide_thisparam) && param->isThisPointer())
|
||||
continue;
|
||||
@@ -1954,8 +1966,12 @@ void PrintC::emitPrototypeInputs(const FuncProto *proto)
|
||||
}
|
||||
}
|
||||
if (proto->isDotdotdot()) {
|
||||
- if (sz != 0)
|
||||
- emit->print(",");
|
||||
+ if (sz != 0) {
|
||||
+ emit->print(",");
|
||||
+ if (option_space_after_comma) {
|
||||
+ emit->spaces(1);
|
||||
+ }
|
||||
+ }
|
||||
emit->print("...");
|
||||
}
|
||||
}
|
||||
@@ -2351,7 +2367,9 @@ void PrintC::docFunction(const Funcdata *fd)
|
||||
emit->tagLine();
|
||||
emitFunctionDeclaration(fd); // Causes us to enter function's scope
|
||||
emit->tagLine();
|
||||
- emit->tagLine();
|
||||
+ if (option_newline_after_prototype) {
|
||||
+ emit->tagLine();
|
||||
+ }
|
||||
int4 id = emit->startIndent();
|
||||
emit->print("{");
|
||||
emitLocalVarDecls(fd);
|
||||
@@ -2606,7 +2624,11 @@ void PrintC::emitBlockIf(const BlockIf *bl)
|
||||
}
|
||||
|
||||
setMod(no_branch);
|
||||
- emit->spaces(1);
|
||||
+ if (!option_newline_before_opening_brace) {
|
||||
+ emit->spaces(1);
|
||||
+ } else {
|
||||
+ emit->tagLine();
|
||||
+ }
|
||||
int4 id = emit->startIndent();
|
||||
emit->print("{");
|
||||
int4 id1 = emit->beginBlock(bl->getBlock(1));
|
||||
@@ -2616,9 +2638,15 @@ void PrintC::emitBlockIf(const BlockIf *bl)
|
||||
emit->tagLine();
|
||||
emit->print("}");
|
||||
if (bl->getSize()==3) {
|
||||
- emit->tagLine();
|
||||
+ if (option_newline_before_else) {
|
||||
+ emit->tagLine();
|
||||
+ }
|
||||
emit->print("else",EmitXml::keyword_color);
|
||||
- emit->spaces(1);
|
||||
+ if (option_newline_before_else) {
|
||||
+ emit->tagLine();
|
||||
+ } else {
|
||||
+ emit->spaces(1);
|
||||
+ }
|
||||
int4 id = emit->startIndent();
|
||||
emit->print("{");
|
||||
int4 id2 = emit->beginBlock(bl->getBlock(2));
|
||||
@@ -2769,7 +2797,11 @@ void PrintC::emitBlockDoWhile(const BlockDoWhile *bl)
|
||||
emitAnyLabelStatement(bl);
|
||||
emit->tagLine();
|
||||
emit->print("do",EmitXml::keyword_color);
|
||||
- emit->spaces(1);
|
||||
+ if (option_newline_before_opening_brace) {
|
||||
+ emit->tagLine();
|
||||
+ } else {
|
||||
+ emit->spaces(1);
|
||||
+ }
|
||||
int4 id = emit->startIndent();
|
||||
emit->print("{");
|
||||
pushMod();
|
||||
@@ -2801,7 +2833,11 @@ void PrintC::emitBlockInfLoop(const BlockInfLoop *bl)
|
||||
emitAnyLabelStatement(bl);
|
||||
emit->tagLine();
|
||||
emit->print("do",EmitXml::keyword_color);
|
||||
- emit->spaces(1);
|
||||
+ if (option_newline_before_opening_brace) {
|
||||
+ emit->tagLine();
|
||||
+ } else {
|
||||
+ emit->spaces(1);
|
||||
+ }
|
||||
int4 id = emit->startIndent();
|
||||
emit->print("{");
|
||||
int4 id1 = emit->beginBlock(bl->getBlock(0));
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh
|
||||
index 92afe1ee1..f315d7023 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh
|
||||
@@ -119,6 +119,10 @@ protected:
|
||||
bool option_nocasts; ///< Don't print a cast if \b true
|
||||
bool option_unplaced; ///< Set to \b true if we should display unplaced comments
|
||||
bool option_hide_exts; ///< Set to \b true if we should hide implied extension operations
|
||||
+ bool option_space_after_comma;
|
||||
+ bool option_newline_before_else;
|
||||
+ bool option_newline_before_opening_brace;
|
||||
+ bool option_newline_after_prototype;
|
||||
string nullToken; ///< Token to use for 'null'
|
||||
CommentSorter commsorter; ///< Container/organizer for comments in the current function
|
||||
|
||||
@@ -205,6 +209,9 @@ public:
|
||||
void setCPlusPlusStyleComments(void) { setCommentDelimeter("// ","",true); } ///< Set c++-style "//" comment delimiters
|
||||
void setDisplayUnplaced(bool val) { option_unplaced = val; } ///< Toggle whether \e unplaced comments are displayed in the header
|
||||
void setHideImpliedExts(bool val) { option_hide_exts = val; } ///< Toggle whether implied extensions are hidden
|
||||
+ void setSpaceAfterComma(bool val) { option_space_after_comma = val; }
|
||||
+ void setNewlineBeforeOpeningBrace(bool val) { option_newline_before_opening_brace = val; }
|
||||
+ void setNewlineAfterPrototype(bool val) { option_newline_after_prototype = val; }
|
||||
virtual ~PrintC(void) {}
|
||||
virtual void resetDefaults(void);
|
||||
virtual void adjustTypeOperators(void);
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
From 30eade046424dc86966d09d4ec6b26e43640ce89 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=A4rkl?= <[email protected]>
|
||||
Date: Sat, 3 Aug 2019 15:21:59 +0200
|
||||
Subject: [PATCH 09/23] Make some PrintC methods virtual
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh
|
||||
index f315d7023..9301678ee 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh
|
||||
@@ -152,9 +152,9 @@ protected:
|
||||
void emitPrototypeInputs(const FuncProto *proto); ///< Emit the input data-types of a function prototype
|
||||
void emitGlobalVarDeclsRecursive(Scope *scope); ///< Emit variable declarations for all global symbols under given scope
|
||||
void emitLocalVarDecls(const Funcdata *fd); ///< Emit variable declarations for a function
|
||||
- void emitStatement(const PcodeOp *inst); ///< Emit a statement in the body of a function
|
||||
+ virtual void emitStatement(const PcodeOp *inst); ///< Emit a statement in the body of a function
|
||||
bool emitInplaceOp(const PcodeOp *op); ///< Attempt to emit an expression rooted at an \e in-place operator
|
||||
- void emitGotoStatement(const FlowBlock *bl,const FlowBlock *exp_bl,uint4 type);
|
||||
+ virtual void emitGotoStatement(const FlowBlock *bl,const FlowBlock *exp_bl,uint4 type);
|
||||
void emitSwitchCase(int4 casenum,const BlockSwitch *switchbl); ///< Emit labels for a \e case block
|
||||
void emitLabel(const FlowBlock *bl); ///< Emit a formal label for a given control-flow block
|
||||
void emitLabelStatement(const FlowBlock *bl); ///< Emit any required label statement for a given basic block
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
From 87d83f509ba66f1b41bb5306da19d3f04f455d78 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=A4rkl?= <[email protected]>
|
||||
Date: Fri, 23 Aug 2019 18:45:22 +0200
|
||||
Subject: [PATCH 10/23] Add Setter for NL before else
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc | 8 +++++---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh | 1 +
|
||||
2 files changed, 6 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
|
||||
index 19acbfaf0..56c37e783 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
|
||||
@@ -2638,11 +2638,13 @@ void PrintC::emitBlockIf(const BlockIf *bl)
|
||||
emit->tagLine();
|
||||
emit->print("}");
|
||||
if (bl->getSize()==3) {
|
||||
- if (option_newline_before_else) {
|
||||
- emit->tagLine();
|
||||
+ if (option_newline_before_else) {
|
||||
+ emit->tagLine();
|
||||
+ } else {
|
||||
+ emit->spaces(1);
|
||||
}
|
||||
emit->print("else",EmitXml::keyword_color);
|
||||
- if (option_newline_before_else) {
|
||||
+ if (option_newline_before_opening_brace) {
|
||||
emit->tagLine();
|
||||
} else {
|
||||
emit->spaces(1);
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh
|
||||
index 9301678ee..86d4e47d2 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.hh
|
||||
@@ -211,6 +211,7 @@ public:
|
||||
void setHideImpliedExts(bool val) { option_hide_exts = val; } ///< Toggle whether implied extensions are hidden
|
||||
void setSpaceAfterComma(bool val) { option_space_after_comma = val; }
|
||||
void setNewlineBeforeOpeningBrace(bool val) { option_newline_before_opening_brace = val; }
|
||||
+ void setNewlineBeforeElse(bool val) { option_newline_before_else = val; }
|
||||
void setNewlineAfterPrototype(bool val) { option_newline_after_prototype = val; }
|
||||
virtual ~PrintC(void) {}
|
||||
virtual void resetDefaults(void);
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
From 8ae5683e2342ec67c0b4efd2cf2d6913b56e62b8 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=A4rkl?= <[email protected]>
|
||||
Date: Sun, 25 Aug 2019 18:23:23 +0200
|
||||
Subject: [PATCH 11/23] Clean Sleigh Descriptions on Shutdown
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/sleigh_arch.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh_arch.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh_arch.cc
|
||||
index 038bc379e..7cd004b4b 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh_arch.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh_arch.cc
|
||||
@@ -467,5 +467,5 @@ void SleighArchitecture::shutdown(void)
|
||||
delete last_sleigh;
|
||||
last_sleigh = (Sleigh *)0;
|
||||
}
|
||||
- // description.clear(); // static vector is destroyed by the normal exit handler
|
||||
+ description.clear();
|
||||
}
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
From ca94da1513658a208f32ccff11ed28ff9a9fafb3 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=A4rkl?= <[email protected]>
|
||||
Date: Tue, 12 May 2020 21:17:00 +0200
|
||||
Subject: [PATCH 13/23] Fix Build with G++ 4.9.2
|
||||
|
||||
---
|
||||
.../Decompiler/src/decompile/cpp/float.cc | 32 +++++++++++++++++++
|
||||
1 file changed, 32 insertions(+)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/float.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/float.cc
|
||||
index 1af9b5d79..9b044d0c1 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/float.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/float.cc
|
||||
@@ -19,6 +19,38 @@
|
||||
#include <cmath>
|
||||
#include "address.hh"
|
||||
|
||||
+#if defined(_WINDOWS) && !defined(INFINITY)
|
||||
+
|
||||
+// Some definitions for Windows floating point stuff
|
||||
+#include <cfloat>
|
||||
+
|
||||
+inline int4 signbit(double x) {
|
||||
+ return (((_fpclass(x)& (_FPCLASS_NINF | _FPCLASS_NN
|
||||
+ | _FPCLASS_ND | _FPCLASS_NZ))!=0) ? 1 : 0);
|
||||
+}
|
||||
+
|
||||
+inline int4 isnan(double x) {
|
||||
+ return (((_fpclass(x)& (_FPCLASS_SNAN | _FPCLASS_QNAN))!=0) ? 1 : 0);
|
||||
+}
|
||||
+
|
||||
+inline int4 isinf(double x) {
|
||||
+ int4 classify = _fpclass(x);
|
||||
+ if (classify == _FPCLASS_NINF) return -1;
|
||||
+ if (classify == _FPCLASS_PINF) return 1;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#define INFINITY HUGE_VAL
|
||||
+#define NAN (INFINITY/INFINITY)
|
||||
+
|
||||
+#else
|
||||
+
|
||||
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48891
|
||||
+#define isnan std::isnan
|
||||
+#define isinf std::isinf
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
/// Set format for a given encoding size according to IEEE 754 standards
|
||||
/// \param sz is the size of the encoding in bytes
|
||||
FloatFormat::FloatFormat(int4 sz)
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
From 49accbd25688976dc665b8bc7abd8775de2b26ed Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=A4rkl?= <[email protected]>
|
||||
Date: Thu, 11 Jun 2020 21:39:54 +0200
|
||||
Subject: [PATCH 14/23] Fix std::vector oob access in StringManager::saveXml()
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
|
||||
index 6e60b4f66..60b6d6852 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/stringmanage.cc
|
||||
@@ -98,7 +98,7 @@ void StringManager::saveXml(ostream &s) const
|
||||
s << " <bytes";
|
||||
a_v_b(s, "trunc", stringData.isTruncated);
|
||||
s << ">\n" << setfill('0');
|
||||
- for(int4 i=0;stringData.byteData.size();++i) {
|
||||
+ for(uintp i=0;i<stringData.byteData.size();++i) {
|
||||
s << hex << setw(2) << (int4)stringData.byteData[i];
|
||||
if (i%20 == 19)
|
||||
s << "\n ";
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
From 7849991ccefe012792f1fc8cfc56f36772db32c6 Mon Sep 17 00:00:00 2001
|
||||
From: FXTi <[email protected]>
|
||||
Date: Wed, 26 Aug 2020 15:10:30 +0800
|
||||
Subject: [PATCH 16/23] Export two private field to SLEIGH plugin. (#4)
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/context.hh | 2 ++
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.hh | 1 +
|
||||
2 files changed, 3 insertions(+)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/context.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/context.hh
|
||||
index 3372e5ac5..5920bceb4 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/context.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/context.hh
|
||||
@@ -89,6 +89,8 @@ private:
|
||||
ConstructState *base_state;
|
||||
int4 alloc; // Number of ConstructState's allocated
|
||||
int4 delayslot; // delayslot depth
|
||||
+protected:
|
||||
+ ConstructState *getBaseState(void) { return base_state; }
|
||||
public:
|
||||
ParserContext(ContextCache *ccache);
|
||||
~ParserContext(void) { if (context != (uintm *)0) delete [] context; }
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.hh
|
||||
index 1a758a488..1e96c2c30 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh.hh
|
||||
@@ -166,6 +166,7 @@ protected:
|
||||
ParserContext *obtainContext(const Address &addr,int4 state) const;
|
||||
void resolve(ParserContext &pos) const; ///< Generate a parse tree suitable for disassembly
|
||||
void resolveHandles(ParserContext &pos) const; ///< Prepare the parse tree for p-code generation
|
||||
+ ContextCache *getContextCache(void) { return cache; }
|
||||
public:
|
||||
Sleigh(LoadImage *ld,ContextDatabase *c_db); ///< Constructor
|
||||
virtual ~Sleigh(void); ///< Destructor
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
From 20caeaccb5e2b85e7c0f519b5f23cddea24b8801 Mon Sep 17 00:00:00 2001
|
||||
From: Anton Kochkov <[email protected]>
|
||||
Date: Tue, 22 Dec 2020 17:28:02 +0800
|
||||
Subject: [PATCH 18/23] Add FreeBSD and OpenBSD support (#6)
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/types.h | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/types.h b/Ghidra/Features/Decompiler/src/decompile/cpp/types.h
|
||||
index ff6f423ab..6d5b6acb2 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/types.h
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/types.h
|
||||
@@ -71,7 +71,7 @@ typedef char int1;
|
||||
typedef uint8 uintp;
|
||||
#endif
|
||||
|
||||
-#if defined (__linux__) && (defined (__i386__) || defined (__arm__))
|
||||
+#if (defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__)) && (defined (__i386__) || defined (__arm__))
|
||||
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#define HOST_ENDIAN 1
|
||||
#else
|
||||
@@ -90,7 +90,7 @@ typedef char int1;
|
||||
typedef uint4 uintp;
|
||||
#endif
|
||||
|
||||
-#if defined (__linux__) && (defined (__x86_64__) || defined (__aarch64__))
|
||||
+#if (defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__)) && (defined (__x86_64__) || defined (__aarch64__))
|
||||
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#define HOST_ENDIAN 1
|
||||
#else
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
From 8e5f8c4f5902e5874468181687fd64580eeb3119 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=A4rkl?= <[email protected]>
|
||||
Date: Sun, 14 Mar 2021 22:20:31 +0100
|
||||
Subject: [PATCH 21/23] Fail gently in PrintC when a Basic Block gives an
|
||||
invalid Address
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
|
||||
index 56c37e783..07461326a 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
|
||||
@@ -2904,6 +2904,10 @@ void PrintC::emitLabel(const FlowBlock *bl)
|
||||
if (bl == (FlowBlock *)0) return;
|
||||
BlockBasic *bb = (BlockBasic *)bl->subBlock(0);
|
||||
Address addr = bb->getEntryAddr();
|
||||
+ if (addr.isInvalid()) {
|
||||
+ emit->print("INVALID_ADDRESS");
|
||||
+ return;
|
||||
+ }
|
||||
const AddrSpace *spc = addr.getSpace();
|
||||
uintb off = addr.getOffset();
|
||||
if (!bb->hasSpecialLabel()) {
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
From bfa4d25c3154306fe03b853efec84bbc9d19c518 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=A4rkl?= <[email protected]>
|
||||
Date: Thu, 25 Jul 2019 19:00:44 +0200
|
||||
Subject: [PATCH 08/23] Make Commas less ugly
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
|
||||
index c7e290fe8..19acbfaf0 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc
|
||||
@@ -52,7 +52,7 @@ OpToken PrintC::boolean_and = { "&&", 2, 22, false, OpToken::binary, 1, 0, (OpTo
|
||||
OpToken PrintC::boolean_xor = { "^^", 2, 20, false, OpToken::binary, 1, 0, (OpToken *)0 };
|
||||
OpToken PrintC::boolean_or = { "||", 2, 18, false, OpToken::binary, 1, 0, (OpToken *)0 };
|
||||
OpToken PrintC::assignment = { "=", 2, 14, false, OpToken::binary, 1, 5, (OpToken *)0 };
|
||||
-OpToken PrintC::comma = { ",", 2, 2, true, OpToken::binary, 0, 0, (OpToken *)0 };
|
||||
+OpToken PrintC::comma = { ", ", 2, 2, true, OpToken::binary, 0, 0, (OpToken *)0 };
|
||||
OpToken PrintC::new_op = { "", 2, 62, false, OpToken::space, 1, 0, (OpToken *)0 };
|
||||
|
||||
// Inplace assignment operators
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
From c16edaf929f9087bb457a3e76e067cac9772d67b Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Florian=20M=C3=A4rkl?= <[email protected]>
|
||||
Date: Sun, 25 Aug 2019 21:20:48 +0200
|
||||
Subject: [PATCH 12/23] Make SleighArchitecture Langs public
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/sleigh_arch.hh | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh_arch.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh_arch.hh
|
||||
index 01d41fe07..7a902c5b0 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh_arch.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/sleigh_arch.hh
|
||||
@@ -98,7 +98,6 @@ class SleighArchitecture : public Architecture {
|
||||
protected:
|
||||
ostream *errorstream; ///< Error stream associated with \b this SleighArchitecture
|
||||
// buildLoader must be filled in by derived class
|
||||
- static void collectSpecFiles(ostream &errs); ///< Gather specification files in normal locations
|
||||
virtual Translate *buildTranslator(DocumentStorage &store);
|
||||
virtual PcodeInjectLibrary *buildPcodeInjectLibrary(void);
|
||||
virtual void buildSpecFile(DocumentStorage &store);
|
||||
@@ -113,7 +112,9 @@ public:
|
||||
virtual void printMessage(const string &message) const { *errorstream << message << endl; }
|
||||
virtual ~SleighArchitecture(void);
|
||||
virtual string getDescription(void) const;
|
||||
-
|
||||
+
|
||||
+ static void collectSpecFiles(ostream &errs); ///< Gather specification files in normal locations
|
||||
+ static const vector<LanguageDescription> &getLanguageDescriptions() { return description; }
|
||||
static string normalizeProcessor(const string &nm); ///< Try to recover a \e language \e id processor field
|
||||
static string normalizeEndian(const string &nm); ///< Try to recover a \e language \e id endianess field
|
||||
static string normalizeSize(const string &nm); ///< Try to recover a \e language \e id size field
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
From 815e71870e67c29187a20ee2563a11c09acb5a93 Mon Sep 17 00:00:00 2001
|
||||
From: FXTi <[email protected]>
|
||||
Date: Wed, 26 Aug 2020 22:37:55 +0800
|
||||
Subject: [PATCH 17/23] Make getBaseState return a pointer (#5)
|
||||
|
||||
---
|
||||
Ghidra/Features/Decompiler/src/decompile/cpp/context.hh | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/context.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/context.hh
|
||||
index 5920bceb4..5d2e108f7 100644
|
||||
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/context.hh
|
||||
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/context.hh
|
||||
@@ -90,7 +90,7 @@ private:
|
||||
int4 alloc; // Number of ConstructState's allocated
|
||||
int4 delayslot; // delayslot depth
|
||||
protected:
|
||||
- ConstructState *getBaseState(void) { return base_state; }
|
||||
+ ConstructState **getBaseState(void) { return &base_state; }
|
||||
public:
|
||||
ParserContext(ContextCache *ccache);
|
||||
~ParserContext(void) { if (context != (uintm *)0) delete [] context; }
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
diff --git a/src/Processors/Dalvik/data/languages/Dalvik_Base.cspec b/src/Processors/Dalvik/data/languages/Dalvik_Base.cspec
|
||||
index ba8bb33..aa7aee1 100644
|
||||
--- a/src/Processors/Dalvik/data/languages/Dalvik_Base.cspec
|
||||
+++ b/src/Processors/Dalvik/data/languages/Dalvik_Base.cspec
|
||||
@@ -47,13 +47,11 @@
|
||||
<register name="fp"/>
|
||||
<varnode space="register" offset="0x1000" size="0x400"/>
|
||||
</unaffected>
|
||||
- <pcode inject="uponentry" dynamic="true"/> <!-- Dynamically generate p-code to map input to registers -->
|
||||
+ <!-- The native decompiler cannot service Ghidra's Java-side Dalvik dynamic injects. -->
|
||||
</prototype>
|
||||
</default_proto>
|
||||
|
||||
- <callotherfixup targetop="moveRangeToIV">
|
||||
- <pcode dynamic="true"/>
|
||||
- </callotherfixup>
|
||||
+ <!-- Leave moveRangeToIV as an unresolved userop instead of failing on a missing dynamic inject. -->
|
||||
|
||||
</compiler_spec>
|
||||
|
||||
diff --git a/src/decompiler/fspec.cc b/src/decompiler/fspec.cc
|
||||
index d87eb2f..b3a11e5 100644
|
||||
--- a/src/decompiler/fspec.cc
|
||||
+++ b/src/decompiler/fspec.cc
|
||||
@@ -1984,7 +1984,7 @@ int4 ParamActive::whichTrial(const Address &addr,int4 sz) const
|
||||
{
|
||||
for(int4 i=0;i<trial.size();++i) {
|
||||
if (addr.overlap(0,trial[i].getAddress(),trial[i].getSize())>=0) return i;
|
||||
- if (sz<=1) return -1;
|
||||
+ if (sz<=1) continue;
|
||||
Address endaddr = addr + (sz-1);
|
||||
if (endaddr.overlap(0,trial[i].getAddress(),trial[i].getSize())>=0) return i;
|
||||
}
|
||||
Reference in new issue
Block a user