From b940cdcc4fad6d9e4ab70d8f7b386481065dac59 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Mon, 8 Mar 2021 16:14:09 -0800 Subject: [PATCH 1/4] Correct typos and spacing in decompiler documentation --- .../Decompiler/src/decompile/cpp/doccore.hh | 66 +++++++++---------- .../Decompiler/src/decompile/cpp/docmain.hh | 8 +-- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/doccore.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/doccore.hh index e8f0cae6db..8640982188 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/doccore.hh +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/doccore.hh @@ -27,7 +27,7 @@ implement these models provides the quickest inroad into obtaining an overall understanding of the code. - We list all these fundemental classes here, loosely grouped + We list all these fundamental classes here, loosely grouped as follows. There is one set of classes that describe the \e Syntax \e Trees, which are built up from the original p-code, and transformed during the decompiler's simplification process. @@ -43,18 +43,18 @@ - AddrSpace - A place within the reverse engineering model where data can be stored. The typical address spaces are \b ram, - modeling the main databus of a processor, and \b register, - modeling a processors on board registers. Data is stored a - byte at a time at \b offsets within the AddrSpace. + modeling the main databus of a processor, and \b register, + modeling a processor's on board registers. Data is stored a + byte at a time at \b offsets within the AddrSpace. . - Address - An AddrSpace and an offset within the space forms the - Address of the byte at that offset. + Address of the byte at that offset. . - Varnode - A contiguous set of bytes, given by an Address and a size, - encoding a single value in the model. In terms of SSA - syntax tree, a Varnode is also a node in the tree. + encoding a single value in the model. In terms of SSA + syntax tree, a Varnode is also a node in the tree. . - SeqNum - A \e sequence \e number that extends Address for distinguishing PcodeOps @@ -161,14 +161,14 @@ and local scope. \code - string & getName(); // get name of function - Address & getAddress(); // get Address of function's entry point - int4 numCalls(); // number of subfunctions called by this function + string & getName(); // get name of function + Address & getAddress(); // get Address of function's entry point + int4 numCalls(); // number of subfunctions called by this function FuncCallSpecs *getCallSpecs(int4 i); // get specs for one of the subfunctions - BlockGraph & getBasicBlocks(); // get the collection of basic blocks + BlockGraph & getBasicBlocks(); // get the collection of basic blocks iterator beginLoc(Address &); // Search for Varnodes in tree - iterator beginLoc(int4,Address &); // based on the Varnode's address + iterator beginLoc(int4,Address &); // based on the Varnode's address iterator beginLoc(int4,Address &,Address &,uintm); iterator beginDef(uint4,Address &); // Search for Varnode based on the // address of its defining operation @@ -221,14 +221,14 @@ array, and structure qualifiers. \code - class TypePointer : public Datatype { // pointer to (some other type) - Datatype *getBase(); // get Datatype being pointed to + class TypePointer : public Datatype { // pointer to (some other type) + Datatype *getBase(); // get Datatype being pointed to }; - class TypeArray : public Datatype { // array of (some other type) - Datatype *getBase(); // get Datatype of array element + class TypeArray : public Datatype { // array of (some other type) + Datatype *getBase(); // get Datatype of array element }; - class TypeStruct : public Datatype { // structure with fields of (some other types) - TypeField *getField(int4,int4,int4 *); // get Datatype of a field + class TypeStruct : public Datatype { // structure with fields of (some other types) + TypeField *getField(int4,int4,int4 *); // get Datatype of a field }; \endcode @@ -237,12 +237,12 @@ This is a container for Datatypes. \code - Datatype *findByName(string &); // find a Datatype by name - Datatype *getTypeVoid(); // retrieve common types + Datatype *findByName(string &); // find a Datatype by name + Datatype *getTypeVoid(); // retrieve common types Datatype *getTypeChar(); Datatype *getBase(int4 size,type_metatype); - Datatype *getTypePointer(int4,Datatype *,uint4); // get a pointer to another type - Datatype *getTypeArray(int4,Datatype *); // get an array of another type + Datatype *getTypePointer(int4,Datatype *,uint4); // get a pointer to another type + Datatype *getTypeArray(int4,Datatype *); // get an array of another type \endcode \section classhighvariable HighVariable @@ -257,7 +257,7 @@ \code int4 numInstances(); // get number of different Varnodes associated // with this variable. - Varnode * getInstance(int4); // get (one of the) Varnodes associated with + Varnode * getInstance(int4); // get (one of the) Varnodes associated with // this variable. Datatype * getType(); // get Datatype of this variable Symbol * getSymbol(); // get Symbol associated with this variable @@ -274,11 +274,11 @@ lives in a scope, has a name, and has a Datatype. \code - string & getName(); // get the name of the symbol - Datatype * getType(); // get the Datatype of the symbol - Scope * getScope(); // get the scope containing the symbol + string & getName(); // get the name of the symbol + Datatype * getType(); // get the Datatype of the symbol + Scope * getScope(); // get the scope containing the symbol SymbolEntry * getFirstWholeMap(); // get the (first) SymbolEntry associated - // with this symbol + // with this symbol \endcode \section classsymbolentry SymbolEntry @@ -300,16 +300,16 @@ This is a container for symbols. \code - SymbolEntry *findAddr(Address &,Address &); // find a Symbol by address + SymbolEntry *findAddr(Address &,Address &); // find a Symbol by address SymbolEntry *findContainer(Address &,int4,Address &); // find containing symbol - Funcdata * findFunction(Address &); // find a function by entry address - Symbol * findByName(string &); // find a Symbol by name - SymbolEntry *queryByAddr(Address &,Address &); // search for symbols across multiple scopes + Funcdata * findFunction(Address &); // find a function by entry address + Symbol * findByName(string &); // find a Symbol by name + SymbolEntry *queryByAddr(Address &,Address &); // search for symbols across multiple scopes SymbolEntry *queryContainer(Address &,int4,Address &); Funcdata * queryFunction(Address &); Scope * discoverScope(Address &,int4,Address &); // discover scope of an address - string & getName(); // get name of scope - Scope * getParent(); // get parent scope + string & getName(); // get name of scope + Scope * getParent(); // get parent scope \endcode \section classdatabase Database diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/docmain.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/docmain.hh index 9abe262728..23008d2685 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/docmain.hh +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/docmain.hh @@ -38,7 +38,7 @@ the main code workflow. The library provides its own Register - Transfer Languate (RTL), referred to internally as \b p-code, + Transfer Language (RTL), referred to internally as \b p-code, which is designed specifically for reverse engineering applications. The disassembly of processor specific machine-code languages, and subsequent translation into \b p-code, forms @@ -275,7 +275,7 @@ about the variables it analyzes, as this kind of information is generally not present in the input binary. Some information can be gathered about a - variable, based on the instructions it is used in (.i.e + variable, based on the instructions it is used in (i.e. if it is used in a floating point instruction). Other information about type might be available from header files or from the user. Once this is gathered, the @@ -301,7 +301,7 @@ compiler would, but to simplify and normalize for easier understanding and recognition by human analysts (and follow on machine processing). Typical examples - of transforms include, copy propagation, constant + of transforms include: copy propagation, constant propagation, collecting terms, cancellation of operators and other algebraic simplifications, undoing multiplication and division optimizations, commuting @@ -373,7 +373,7 @@ Even after the initial merging of variables in phase 1, there are generally still too many for normal C code. So - the decompiler, does additional, more speculative merging. + the decompiler does additional, more speculative merging. It first tries to merge the inputs and outputs of copy operations, and then the inputs and outputs of more general operations. And finally, merging is attempted on From 58a9ff92af00d41021e074e2289c55dc38d2c3b6 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Mon, 8 Mar 2021 16:44:13 -0800 Subject: [PATCH 2/4] Fix JavaDoc warning --- .../src/main/java/ghidra/app/util/bin/format/elf/ElfSymbol.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/elf/ElfSymbol.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/elf/ElfSymbol.java index 170c317d97..16a0468b89 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/elf/ElfSymbol.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/elf/ElfSymbol.java @@ -111,7 +111,6 @@ public class ElfSymbol implements ByteArrayConverter { * @param reader to read symbol from * @param symbolIndex index of the symbol to read * @param symbolTable symbol table to associate the symbol to - * @param stringTable string table to read symbols from * @param header else header * @return newly created ElfSymbol * From 682bc88df07074baffbc65ee67c2a8221a21a50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sun, 14 Mar 2021 14:39:12 +0100 Subject: [PATCH 3/4] Fix monitor messages for constant propagation --- .../Base/ghidra_scripts/PropagateConstantReferences.java | 2 +- .../Base/ghidra_scripts/PropagateX86ConstantReferences.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Ghidra/Features/Base/ghidra_scripts/PropagateConstantReferences.java b/Ghidra/Features/Base/ghidra_scripts/PropagateConstantReferences.java index a996abab90..ed529a0cfb 100644 --- a/Ghidra/Features/Base/ghidra_scripts/PropagateConstantReferences.java +++ b/Ghidra/Features/Base/ghidra_scripts/PropagateConstantReferences.java @@ -36,7 +36,7 @@ public class PropagateConstantReferences extends GhidraScript { public void run() throws Exception { long numInstructions = currentProgram.getListing().getNumInstructions(); monitor.initialize((int) (numInstructions)); - monitor.setMessage("Constant Propogation Markup"); + monitor.setMessage("Constant Propagation Markup"); // set up the address set to restrict processing AddressSet restrictedSet = diff --git a/Ghidra/Features/Base/ghidra_scripts/PropagateX86ConstantReferences.java b/Ghidra/Features/Base/ghidra_scripts/PropagateX86ConstantReferences.java index 354c35519e..6d4379c26a 100644 --- a/Ghidra/Features/Base/ghidra_scripts/PropagateX86ConstantReferences.java +++ b/Ghidra/Features/Base/ghidra_scripts/PropagateX86ConstantReferences.java @@ -57,7 +57,7 @@ public class PropagateX86ConstantReferences extends GhidraScript { public void run() throws Exception { long numInstructions = currentProgram.getListing().getNumInstructions(); monitor.initialize((int) (numInstructions)); - monitor.setMessage("Constant Propogation Markup"); + monitor.setMessage("Constant Propagation Markup"); // set up the address set to restrict processing AddressSet restrictedSet = new AddressSet(currentSelection); From 359925c9b3e7602e71fb569e44c2c121e9b98c94 Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Fri, 2 Apr 2021 13:08:05 -0400 Subject: [PATCH 4/4] GP-832: Certify --- Ghidra/Features/Decompiler/src/decompile/cpp/docmain.hh | 1 - 1 file changed, 1 deletion(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/docmain.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/docmain.hh index 23008d2685..1e3520b6f5 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/docmain.hh +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/docmain.hh @@ -1,6 +1,5 @@ /* ### * IP: GHIDRA - * REVIEWED: YES * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.