ROSE
0.11.27.0
|
Analysis that looks for no-op equivalents.
Definition at line 15 of file BinaryNoOperation.h.
#include <BinaryNoOperation.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. More... | |
typedef std::vector< IndexInterval > | IndexIntervals |
A vector of instruction indices. More... | |
Public Member Functions | |
NoOperation () | |
Default constructor. More... | |
NoOperation (const InstructionSemantics2::BaseSemantics::DispatcherPtr &cpu) | |
Construct a new analysis with specified virtual CPU. More... | |
NoOperation (BinaryAnalysis::Disassembler *) | |
Construct a new analysis for a specific disassembler. More... | |
bool | isNoop (SgAsmInstruction *) const |
Determines if an instruction is a no-op. More... | |
bool | isNoop (const std::vector< SgAsmInstruction * > &) const |
Determines if a sequence of instructions is a no-op. More... | |
IndexIntervals | findNoopSubsequences (const std::vector< SgAsmInstruction * > &) const |
Finds all sequences of instructions that are equivalent to no-operation. More... | |
StateNormalizer::Ptr | stateNormalizer () const |
Property: state normalizer. More... | |
void | stateNormalizer (const StateNormalizer::Ptr &f) |
Property: state normalizer. More... | |
const Sawyer::Optional< rose_addr_t > | initialStackPointer () const |
Property: initial concrete value for stack pointer. More... | |
void | initialStackPointer (const Sawyer::Optional< rose_addr_t > &v) |
Property: initial concrete value for stack pointer. More... | |
bool | ignoreTerminalBranches () const |
Property: Whether terminal branches can be no-ops. More... | |
void | ignoreTerminalBranches (bool b) |
Property: Whether terminal branches can be no-ops. More... | |
Static Public Member Functions | |
static IndexIntervals | largestEarliestNonOverlapping (const IndexIntervals &) |
Select certain no-op sequences. More... | |
static std::vector< bool > | toVector (const IndexIntervals &, size_t size=0) |
Return a boolean vector. More... | |
static void | initDiagnostics () |
Initializes and registers disassembler diagnostic streams. More... | |
Static Public Attributes | |
static Sawyer::Message::Facility | mlog |
Diagnostic streams. More... | |
Protected Member Functions | |
InstructionSemantics2::BaseSemantics::StatePtr | initialState (SgAsmInstruction *firstInsn) const |
std::string | normalizeState (const InstructionSemantics2::BaseSemantics::StatePtr &) const |
An interval of instruction indices.
Definition at line 18 of file BinaryNoOperation.h.
typedef std::vector<IndexInterval> Rose::BinaryAnalysis::NoOperation::IndexIntervals |
A vector of instruction indices.
Definition at line 21 of file BinaryNoOperation.h.
|
inline |
Default constructor.
Since this default constructor has no information about the virtual CPU, it will assume that all instructions have an effect.
Definition at line 75 of file BinaryNoOperation.h.
|
inlineexplicit |
Construct a new analysis with specified virtual CPU.
Definition at line 79 of file BinaryNoOperation.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 InstructionSemantics2::BaseSemantics::RegisterStateGeneric and the memory state is derived from InstructionSemantics2::BaseSemantics::MemoryCellList.
Definition at line 98 of file BinaryNoOperation.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 InstructionSemantics2::BaseSemantics::RegisterStateGeneric and the memory state is derived from InstructionSemantics2::BaseSemantics::MemoryCellList.
Definition at line 99 of file BinaryNoOperation.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 108 of file BinaryNoOperation.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 109 of file BinaryNoOperation.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 118 of file BinaryNoOperation.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 119 of file BinaryNoOperation.h.
bool Rose::BinaryAnalysis::NoOperation::isNoop | ( | SgAsmInstruction * | ) | const |
Determines if an instruction is a no-op.
bool Rose::BinaryAnalysis::NoOperation::isNoop | ( | const std::vector< SgAsmInstruction * > & | ) | const |
Determines if a sequence of instructions is a no-op.
IndexIntervals Rose::BinaryAnalysis::NoOperation::findNoopSubsequences | ( | const std::vector< SgAsmInstruction * > & | ) | const |
Finds all sequences of instructions that are equivalent to no-operation.
|
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 68 of file BinaryNoOperation.h.