ROSE 0.11.145.147
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Rose::BinaryAnalysis::NoOperation Class Reference

Description

Analysis that looks for no-op equivalents.

Definition at line 14 of file NoOperation.h.

#include <Rose/BinaryAnalysis/NoOperation.h>

Collaboration diagram for Rose::BinaryAnalysis::NoOperation:
Collaboration graph
[legend]

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< IndexIntervalIndexIntervals
 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
 

Member Typedef Documentation

◆ IndexInterval

An interval of instruction indices.

Definition at line 17 of file NoOperation.h.

◆ IndexIntervals

A vector of instruction indices.

Definition at line 20 of file NoOperation.h.

Constructor & Destructor Documentation

◆ NoOperation() [1/3]

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.

◆ NoOperation() [2/3]

Rose::BinaryAnalysis::NoOperation::NoOperation ( const InstructionSemantics::BaseSemantics::DispatcherPtr cpu)
inlineexplicit

Construct a new analysis with specified virtual CPU.

Definition at line 77 of file NoOperation.h.

◆ NoOperation() [3/3]

Rose::BinaryAnalysis::NoOperation::NoOperation ( const BinaryAnalysis::Disassembler::BasePtr )
explicit

Construct a new analysis for a specific disassembler.

An analysis constructed this way will use the symbolic semantics domain.

Member Function Documentation

◆ stateNormalizer() [1/2]

StateNormalizer::Ptr Rose::BinaryAnalysis::NoOperation::stateNormalizer ( ) const
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.

◆ stateNormalizer() [2/2]

void Rose::BinaryAnalysis::NoOperation::stateNormalizer ( const StateNormalizer::Ptr f)
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.

◆ initialStackPointer() [1/2]

const Sawyer::Optional< rose_addr_t > Rose::BinaryAnalysis::NoOperation::initialStackPointer ( ) const
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.

◆ initialStackPointer() [2/2]

void Rose::BinaryAnalysis::NoOperation::initialStackPointer ( const Sawyer::Optional< rose_addr_t > &  v)
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.

◆ ignoreTerminalBranches() [1/2]

bool Rose::BinaryAnalysis::NoOperation::ignoreTerminalBranches ( ) const
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.

◆ ignoreTerminalBranches() [2/2]

void Rose::BinaryAnalysis::NoOperation::ignoreTerminalBranches ( bool  b)
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.

◆ largestEarliestNonOverlapping()

static IndexIntervals Rose::BinaryAnalysis::NoOperation::largestEarliestNonOverlapping ( const IndexIntervals )
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.

◆ toVector()

static std::vector< bool > Rose::BinaryAnalysis::NoOperation::toVector ( const IndexIntervals ,
size_t  size = 0 
)
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.

◆ initDiagnostics()

static void Rose::BinaryAnalysis::NoOperation::initDiagnostics ( )
static

Initializes and registers disassembler diagnostic streams.

See Diagnostics::initialize().

Member Data Documentation

◆ mlog

Sawyer::Message::Facility Rose::BinaryAnalysis::NoOperation::mlog
static

Diagnostic streams.

Definition at line 67 of file NoOperation.h.


The documentation for this class was generated from the following file: