ROSE 0.11.145.147
|
Analysis that looks for no-op equivalents.
Definition at line 14 of file NoOperation.h.
#include <Rose/BinaryAnalysis/NoOperation.h>
Classes | |
class | StateNormalizer |
Base class for normalizing a state. More... | |
Public Types | |
typedef Sawyer::Container::Interval< size_t > | IndexInterval |
An interval of instruction indices. | |
typedef std::vector< IndexInterval > | IndexIntervals |
A vector of instruction indices. | |
Public Member Functions | |
NoOperation () | |
Default constructor. | |
NoOperation (const InstructionSemantics::BaseSemantics::DispatcherPtr &cpu) | |
Construct a new analysis with specified virtual CPU. | |
NoOperation (const BinaryAnalysis::Disassembler::BasePtr &) | |
Construct a new analysis for a specific disassembler. | |
bool | isNoop (SgAsmInstruction *) const |
Determines if an instruction is a no-op. | |
bool | isNoop (const std::vector< SgAsmInstruction * > &) const |
Determines if a sequence of instructions is a no-op. | |
IndexIntervals | findNoopSubsequences (const std::vector< SgAsmInstruction * > &) const |
Finds all sequences of instructions that are equivalent to no-operation. | |
StateNormalizer::Ptr | stateNormalizer () const |
Property: state normalizer. | |
void | stateNormalizer (const StateNormalizer::Ptr &f) |
Property: state normalizer. | |
const Sawyer::Optional< rose_addr_t > | initialStackPointer () const |
Property: initial concrete value for stack pointer. | |
void | initialStackPointer (const Sawyer::Optional< rose_addr_t > &v) |
Property: initial concrete value for stack pointer. | |
bool | ignoreTerminalBranches () const |
Property: Whether terminal branches can be no-ops. | |
void | ignoreTerminalBranches (bool b) |
Property: Whether terminal branches can be no-ops. | |
Static Public Member Functions | |
static IndexIntervals | largestEarliestNonOverlapping (const IndexIntervals &) |
Select certain no-op sequences. | |
static std::vector< bool > | toVector (const IndexIntervals &, size_t size=0) |
Return a boolean vector. | |
static void | initDiagnostics () |
Initializes and registers disassembler diagnostic streams. | |
Static Public Attributes | |
static Sawyer::Message::Facility | mlog |
Diagnostic streams. | |
Protected Member Functions | |
InstructionSemantics::BaseSemantics::StatePtr | initialState (SgAsmInstruction *firstInsn) const |
std::string | normalizeState (const InstructionSemantics::BaseSemantics::StatePtr &) const |
An interval of instruction indices.
Definition at line 17 of file NoOperation.h.
typedef std::vector<IndexInterval> Rose::BinaryAnalysis::NoOperation::IndexIntervals |
A vector of instruction indices.
Definition at line 20 of file NoOperation.h.
Rose::BinaryAnalysis::NoOperation::NoOperation | ( | ) |
Default constructor.
Since this default constructor has no information about the virtual CPU, it will assume that all instructions have an effect.
|
inlineexplicit |
Construct a new analysis with specified virtual CPU.
Definition at line 77 of file NoOperation.h.
|
explicit |
Construct a new analysis for a specific disassembler.
An analysis constructed this way will use the symbolic semantics domain.
|
inline |
Property: state normalizer.
The state normalizer is responsible for normalizing a virtual machine state and turning it into a string. When looking for no-ops, if two state strings compare equal then the instruction(s) that transitioned the machine from one state to the other are effectively a no-op. In particular, the state normalizer should probably not try to compare instruction pointer registers, or memory that was read without being written (i.e., memory that sprang into existence by reading). The default normalizer does both of these things if the register state is derived from InstructionSemantics::BaseSemantics::RegisterStateGeneric and the memory state is derived from InstructionSemantics::BaseSemantics::MemoryCellList.
Definition at line 96 of file NoOperation.h.
|
inline |
Property: state normalizer.
The state normalizer is responsible for normalizing a virtual machine state and turning it into a string. When looking for no-ops, if two state strings compare equal then the instruction(s) that transitioned the machine from one state to the other are effectively a no-op. In particular, the state normalizer should probably not try to compare instruction pointer registers, or memory that was read without being written (i.e., memory that sprang into existence by reading). The default normalizer does both of these things if the register state is derived from InstructionSemantics::BaseSemantics::RegisterStateGeneric and the memory state is derived from InstructionSemantics::BaseSemantics::MemoryCellList.
Definition at line 97 of file NoOperation.h.
|
inline |
Property: initial concrete value for stack pointer.
A concrete initial value for the stack pointer can be used to help decide whether memory addresses are recently popped. It may be possible to do this without a concrete value also, depending on the semantic domain.
Definition at line 106 of file NoOperation.h.
|
inline |
Property: initial concrete value for stack pointer.
A concrete initial value for the stack pointer can be used to help decide whether memory addresses are recently popped. It may be possible to do this without a concrete value also, depending on the semantic domain.
Definition at line 107 of file NoOperation.h.
|
inline |
Property: Whether terminal branches can be no-ops.
If set (the default) then branch instructions that appear as the last instruction of a basic block, and which have one constant, known successor which is not the fall-through address are not considered to be part of any no-op sequence.
Definition at line 116 of file NoOperation.h.
|
inline |
Property: Whether terminal branches can be no-ops.
If set (the default) then branch instructions that appear as the last instruction of a basic block, and which have one constant, known successor which is not the fall-through address are not considered to be part of any no-op sequence.
Definition at line 117 of file NoOperation.h.
|
static |
Select certain no-op sequences.
Given a list of no-op sequences, such as returned by findNoopSubsequences, process the list so that the largest non-overlapping sequences are returned. If sequence A is larger than sequence B, then B is discarded. If A and B are the same size and overlap and A starts before B then B is discarded.
The return value is sorted by decreasing size and contains non-overlapping intervals.
|
static |
Return a boolean vector.
Returns a vector with one element per instruction. The element is true if the instruction is part of one of the specified index intervals. The returned vector will contain at least size
elements.
|
static |
Initializes and registers disassembler diagnostic streams.
|
static |
Diagnostic streams.
Definition at line 67 of file NoOperation.h.