decompiler
1.0.0
|
Get rid of registers with trash values. More...
#include <coreaction.hh>
Public Member Functions | |
ActionLikelyTrash (const string &g) | |
Constructor. | |
virtual Action * | clone (const ActionGroupList &grouplist) const |
Clone the Action. More... | |
virtual int4 | apply (Funcdata &data) |
Make a single attempt to apply this Action. More... | |
Public Member Functions inherited from ghidra::Action | |
Action (uint4 f, const string &nm, const string &g) | |
Base constructor for an Action. More... | |
virtual | ~Action (void) |
Destructor. | |
virtual void | printStatistics (ostream &s) const |
Dump statistics to stream. More... | |
int4 | perform (Funcdata &data) |
Perform this action (if necessary) More... | |
bool | setBreakPoint (uint4 tp, const string &specify) |
Set a breakpoint on this action. More... | |
virtual void | clearBreakPoints (void) |
Clear all breakpoints set on this Action. | |
bool | setWarning (bool val, const string &specify) |
Set a warning on this action. More... | |
bool | disableRule (const string &specify) |
Disable a specific Rule within this. More... | |
bool | enableRule (const string &specify) |
Enable a specific Rule within this. More... | |
const string & | getName (void) const |
Get the Action's name. | |
const string & | getGroup (void) const |
Get the Action's group. | |
uint4 | getStatus (void) const |
Get the current status of this Action. | |
uint4 | getNumTests (void) |
Get the number of times apply() was invoked. | |
uint4 | getNumApply (void) |
virtual void | reset (Funcdata &data) |
Reset the Action for a new function. More... | |
virtual void | resetStats (void) |
Reset all the counts to zero. More... | |
virtual int4 | print (ostream &s, int4 num, int4 depth) const |
Print a description of this Action to stream. More... | |
virtual void | printState (ostream &s) const |
Print status to stream. More... | |
virtual Action * | getSubAction (const string &specify) |
Retrieve a specific sub-action by name. More... | |
virtual Rule * | getSubRule (const string &specify) |
Retrieve a specific sub-rule by name. More... | |
Static Private Member Functions | |
static uint4 | countMarks (PcodeOp *op) |
static bool | traceTrash (Varnode *vn, vector< PcodeOp *> &indlist) |
Decide if the given Varnode only ever flows into CPUI_INDIRECT. More... | |
Additional Inherited Members | |
Public Types inherited from ghidra::Action | |
enum | ruleflags { rule_repeatapply = 4, rule_onceperfunc = 8, rule_oneactperfunc = 16, rule_debug = 32, rule_warnings_on = 64, rule_warnings_given = 128 } |
Boolean behavior properties governing this particular Action. More... | |
enum | statusflags { status_start =1, status_breakstarthit =2, status_repeat =4, status_mid =8, status_end =16, status_actionbreak =32 } |
Boolean properties describing the status of an action. More... | |
enum | breakflags { break_start = 1, tmpbreak_start = 2, break_action = 4, tmpbreak_action = 8 } |
Break points associated with an Action. More... | |
Protected Member Functions inherited from ghidra::Action | |
void | issueWarning (Architecture *glb) |
Warn that this Action has applied. More... | |
bool | checkStartBreak (void) |
Check start breakpoint. More... | |
bool | checkActionBreak (void) |
Check action breakpoint. More... | |
void | turnOnWarnings (void) |
Enable warnings for this Action. | |
void | turnOffWarnings (void) |
Disable warnings for this Action. | |
Protected Attributes inherited from ghidra::Action | |
int4 | lcount |
Changes not including last call to apply() | |
int4 | count |
Number of changes made by this action so far. | |
uint4 | status |
Current status. | |
uint4 | breakpoint |
Breakpoint properties. | |
uint4 | flags |
Behavior properties. | |
uint4 | count_tests |
Number of times apply() has been called. | |
uint4 | count_apply |
Number of times apply() made changes. | |
string | name |
Name of the action. | |
string | basegroup |
Base group this action belongs to. | |
Get rid of registers with trash values.
Register locations called likely trash are read as a side-effect of some instruction the compiler was using. The canonical example in x86 code is the PUSH ECX which compilers use to create space on the stack without caring about what's in ECX. Even though the decompiler can see that the read ECX value is never getting used directly by the function, because the value is getting copied to the stack, the decompiler frequently can't tell if the value has been aliased across sub-function calls. By marking the ECX register as likely \ trash the decompiler will assume that, unless there is a direct read of the incoming ECX, none of subfunctions alias the stack location where ECX was stored. This allows the spurious references to the register to be removed.
|
virtual |
Make a single attempt to apply this Action.
This is the main entry point for applying changes to a function that are specific to this Action. The method can inspect whatever it wants to decide if the Action does or does not apply. Changes are indicated by incrementing the count field.
data | is the function to inspect/modify |
Implements ghidra::Action.
References ghidra::PcodeOp::code(), ghidra::CPUI_INDIRECT, ghidra::CPUI_INT_AND, ghidra::Funcdata::findCoveredInput(), ghidra::VarnodeData::getAddr(), ghidra::Funcdata::getFuncProto(), ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), ghidra::Varnode::isNameLock(), ghidra::Varnode::isTypeLock(), ghidra::Funcdata::markIndirectCreation(), ghidra::Funcdata::newConstant(), ghidra::Funcdata::opSetInput(), ghidra::VarnodeData::size, ghidra::FuncProto::trashBegin(), and ghidra::FuncProto::trashEnd().
|
inlinevirtual |
Clone the Action.
If this Action is a member of one of the groups in the grouplist, this returns a clone of the Action, otherwise NULL is returned.
grouplist | is the list of groups being cloned |
Implements ghidra::Action.
References ghidra::ActionStart::apply(), ghidra::ActionGroupList::contains(), and ghidra::Action::getGroup().
|
staticprivate |
Count the number of inputs to op which have their mark set
op | is the PcodeOp to count |
References ghidra::PcodeOp::code(), ghidra::CPUI_INDIRECT, ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::isMark(), ghidra::Varnode::isWritten(), and ghidra::PcodeOp::numInput().
|
staticprivate |
Decide if the given Varnode only ever flows into CPUI_INDIRECT.
Return all the CPUI_INDIRECT ops that the Varnode hits in a list. Trace forward down all paths from -vn-, if we hit
For any CPUI_MULTIEQUAL and CPUI_PIECE that are hit, all the other inputs must be hit as well
vn | is the given Varnode |
indlist | is the list to populate with CPUI_INDIRECT ops |
References ghidra::Varnode::beginDescend(), ghidra::calc_mask(), ghidra::PcodeOp::code(), ghidra::CPUI_INDIRECT, ghidra::CPUI_INT_AND, ghidra::CPUI_MULTIEQUAL, ghidra::CPUI_PIECE, ghidra::CPUI_SUBPIECE, ghidra::Varnode::endDescend(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), ghidra::Varnode::isConstant(), ghidra::PcodeOp::isIndirectStore(), ghidra::PcodeOp::isMark(), ghidra::Varnode::isMark(), ghidra::Varnode::isPersist(), ghidra::PcodeOp::numInput(), ghidra::PcodeOp::setMark(), and ghidra::Varnode::setMark().