decompiler
1.0.0
|
A jump-table execution model. More...
#include <jumptable.hh>
Public Member Functions | |
JumpModel (JumpTable *jt) | |
Construct given a parent jump-table. | |
virtual | ~JumpModel (void) |
Destructor. | |
virtual bool | isOverride (void) const =0 |
Return true if this model was manually overridden. | |
virtual int4 | getTableSize (void) const =0 |
Return the number of entries in the address table. | |
virtual bool | recoverModel (Funcdata *fd, PcodeOp *indop, uint4 matchsize, uint4 maxtablesize)=0 |
Attempt to recover details of the model, given a specific BRANCHIND. More... | |
virtual void | buildAddresses (Funcdata *fd, PcodeOp *indop, vector< Address > &addresstable, vector< LoadTable > *loadpoints) const =0 |
Construct the explicit list of target addresses (the Address Table) from this model. More... | |
virtual void | findUnnormalized (uint4 maxaddsub, uint4 maxleftright, uint4 maxext)=0 |
Recover the unnormalized switch variable. More... | |
virtual void | buildLabels (Funcdata *fd, vector< Address > &addresstable, vector< uintb > &label, const JumpModel *orig) const =0 |
Recover case labels associated with the Address table. More... | |
virtual Varnode * | foldInNormalization (Funcdata *fd, PcodeOp *indop)=0 |
Do normalization of the given switch specific to this model. More... | |
virtual bool | foldInGuards (Funcdata *fd, JumpTable *jump)=0 |
Eliminate any guard code involved in computing the switch destination. More... | |
virtual bool | sanityCheck (Funcdata *fd, PcodeOp *indop, vector< Address > &addresstable)=0 |
Perform a sanity check on recovered addresses. More... | |
virtual JumpModel * | clone (JumpTable *jt) const =0 |
Clone this model. | |
virtual void | clear (void) |
Clear any non-permanent aspects of the model. | |
virtual void | saveXml (ostream &s) const |
Save this model as an XML tag. | |
virtual void | restoreXml (const Element *el, Architecture *glb) |
Restore this model from an XML tag. | |
Protected Attributes | |
JumpTable * | jumptable |
The jump-table that is building this model. | |
A jump-table execution model.
This class holds details of the model and recovers these details in various stages. The model concepts include:
|
pure virtual |
Construct the explicit list of target addresses (the Address Table) from this model.
The addresses produced all come from the BRANCHIND and may not be deduped. Alternate guard destinations are not yet included.
fd | is the function containing the switch |
indop | is the root BRANCHIND of the switch |
addresstable | will hold the list of Addresses |
loadpoints | if non-null will hold LOAD table information used by the model |
Implemented in JumpAssisted, JumpBasicOverride, JumpBasic, and JumpModelTrivial.
Referenced by JumpTable::recoverAddresses(), and JumpTable::recoverLabels().
|
pure virtual |
Recover case labels associated with the Address table.
The unnormalized switch variable must already be recovered. Values that the normalized switch value can hold or walked back to obtain the value that the unnormalized switch variable would hold. Labels are returned in the order provided by normalized switch variable iterator JumpValues.
fd | is the function containing the switch |
addresstable | is the address table (used to label code blocks with bad or missing labels) |
label | will hold recovered labels in JumpValues order |
orig | is the JumpModel to use for the JumpValues iterator |
Implemented in JumpAssisted, JumpBasicOverride, JumpBasic, and JumpModelTrivial.
Referenced by JumpTable::recoverLabels().
|
pure virtual |
Recover the unnormalized switch variable.
The normalized switch variable must already be recovered. The amount of normalization between the two switch variables can be restricted.
maxaddsub | is a restriction on arithmetic operations |
maxleftright | is a restriction on shift operations |
maxext | is a restriction on extension operations |
Implemented in JumpAssisted, JumpBasic2, JumpBasic, and JumpModelTrivial.
Referenced by JumpTable::recoverLabels().
Eliminate any guard code involved in computing the switch destination.
We now think of the BRANCHIND as encompassing any guard function.
fd | is the function containing the switch |
jump | is the JumpTable owning this model. |
Implemented in JumpAssisted, JumpBasicOverride, JumpBasic, and JumpModelTrivial.
Referenced by JumpTable::foldInGuards().
Do normalization of the given switch specific to this model.
The PcodeOp machinery is removed so it looks like the CPUI_BRANCHIND simply takes the switch variable as an input Varnode and automatically interprets its values to reach the correct destination.
fd | is the function containing the switch |
indop | is the given switch as a CPUI_BRANCHIND |
Implemented in JumpAssisted, JumpBasic, and JumpModelTrivial.
Referenced by JumpTable::foldInNormalization().
|
pure virtual |
Attempt to recover details of the model, given a specific BRANCHIND.
This generally recovers the normalized switch variable and any guards.
fd | is the function containing the switch |
indop | is the given BRANCHIND |
matchsize | is the expected number of address table entries to recover, or 0 for no expectation |
maxtablesize | is maximum number of address table entries to allow in the model |
Implemented in JumpAssisted, JumpBasicOverride, JumpBasic2, JumpBasic, and JumpModelTrivial.
Referenced by JumpTable::recoverLabels().
|
pure virtual |
Perform a sanity check on recovered addresses.
Individual addresses are checked against the function or its program to determine if they are reasonable. This method can optionally remove addresses from the table. If it does so, the underlying model is changed to reflect the removal.
fd | is the function containing the switch |
indop | is the root BRANCHIND of the switch |
addresstable | is the list of recovered Addresses, which may be modified |
Implemented in JumpAssisted, JumpBasicOverride, JumpBasic, and JumpModelTrivial.