ROSE
0.11.22.0
|
Abstract location.
An abstract location represents either a register name or memory address. Registers are represented by RegisterDescriptor and addresses are represented by semantic values (subclasses of BaseSemantics::SValue).
For instance, to represent abstract locations where memory addresses have symbolic values, one uses:
Abstract locations are immutable objects.
Definition at line 25 of file AbstractLocation.h.
#include <AbstractLocation.h>
Public Types | |
typedef InstructionSemantics2::BaseSemantics::SValuePtr | Address |
Type of memory address. More... | |
Public Member Functions | |
AbstractLocation () | |
Default constructor. More... | |
AbstractLocation (const AbstractLocation &other) | |
Copy constructor. More... | |
AbstractLocation (RegisterDescriptor reg, const RegisterDictionary *regdict=NULL) | |
Register referent. More... | |
AbstractLocation (const Address &addr, size_t nBytes=0) | |
Memory referent. More... | |
AbstractLocation & | operator= (const AbstractLocation &other) |
Assignment operator. More... | |
bool | isValid () const |
Validity checker. More... | |
bool | isRegister () const |
Checks register reference. More... | |
bool | isAddress () const |
Checks memory reference. More... | |
RegisterDescriptor | getRegister () const |
Returns register. More... | |
const Address | getAddress () const |
Returns memory address. More... | |
size_t | nBytes () const |
Returns size of memory location in bytes. More... | |
bool | mayAlias (const AbstractLocation &other, const SmtSolverPtr &solver=SmtSolverPtr()) const |
True if two abstract locations could be aliases. More... | |
bool | mustAlias (const AbstractLocation &other, const SmtSolverPtr &solver=SmtSolverPtr()) const |
True if two abstract locations are certainly aliases. More... | |
void | print (std::ostream &out, const RegisterDictionary *regdict=NULL) const |
Print an abstract location. More... | |
void | print (std::ostream &out, InstructionSemantics2::BaseSemantics::Formatter &fmt) const |
Print an abstract location. More... | |
void | print (std::ostream &out, const RegisterDictionary *regdict, InstructionSemantics2::BaseSemantics::Formatter &fmt) const |
Print an abstract location. More... | |
typedef InstructionSemantics2::BaseSemantics::SValuePtr Rose::BinaryAnalysis::AbstractLocation::Address |
Type of memory address.
Definition at line 27 of file AbstractLocation.h.
|
inline |
Default constructor.
Constructs an abstract location that does not refer to any location. The isValid method will return true for such objects.
Definition at line 40 of file AbstractLocation.h.
|
inline |
Copy constructor.
Definition at line 43 of file AbstractLocation.h.
|
inlineexplicit |
Register referent.
Constructs an abstract location that refers to a register.
Definition at line 49 of file AbstractLocation.h.
|
inlineexplicit |
Memory referent.
Constructs an abstract location that refers to a memory location.
Definition at line 55 of file AbstractLocation.h.
|
inline |
Assignment operator.
Definition at line 58 of file AbstractLocation.h.
|
inline |
Validity checker.
Returns true if this abstract location refers to either a register or a memory location. Default constructed abstract locations refer to neither, as do locations that have both an invalid register descriptor and a null memory address.
Definition at line 70 of file AbstractLocation.h.
References isAddress(), and isRegister().
|
inline |
Checks register reference.
Returns true if and only if this abstract location refers to a register. It is impossible for an abstract location to refer to both a register and memory.
Definition at line 76 of file AbstractLocation.h.
References Rose::BinaryAnalysis::RegisterDescriptor::isEmpty().
Referenced by isValid().
|
inline |
Checks memory reference.
Returns true if and only if this abstract location refers to memory. It is impossible for an abstract location to refer to both a register and memory
Definition at line 82 of file AbstractLocation.h.
|
inline |
Returns register.
Returns the register to which this abstract location refers. When called for an abstract location for which isRegister returns false, the return value is an invalid register descriptor (i.e., one for which RegisterDescriptor::is_valid returns false.
Definition at line 89 of file AbstractLocation.h.
|
inline |
Returns memory address.
Returns the memory address to which this abstract location refers. When called for an abstract location for which isAddress returns false, the return value is a null pointer.
Definition at line 95 of file AbstractLocation.h.
|
inline |
Returns size of memory location in bytes.
Returns the size of the memory location in bytes if known, otherwise zero. It is not valid to call this for an abstract location that points to a register since registers are not always a multiple of the byte size.
Definition at line 101 of file AbstractLocation.h.
References isAddress().
bool Rose::BinaryAnalysis::AbstractLocation::mayAlias | ( | const AbstractLocation & | other, |
const SmtSolverPtr & | solver = SmtSolverPtr() |
||
) | const |
True if two abstract locations could be aliases.
Two abstract locations are aliases if they refer to the exact same register or memory address. By this definition, the AX and EAX registers in x86 are not aliases because they do not refer to the exact same register (one is 16 bits and the other is 32 bits, although the low-order 16 bits are aliases). Likewise, memory addresses are assumed to refer to 8 bit values and two memory addresses are aliases only when they are equal.
Since memory addresses may be symbolic, this function uses an SMT solver to return true if and only if equality of two addresses is satisfiable.
bool Rose::BinaryAnalysis::AbstractLocation::mustAlias | ( | const AbstractLocation & | other, |
const SmtSolverPtr & | solver = SmtSolverPtr() |
||
) | const |
True if two abstract locations are certainly aliases.
Two abstract locations are aliases if they refer to the exact same register or memory address. By this definition, the AX and EAX registers in x86 are not aliases because they do not refer to the exact same register (one is 16 bits and the other is 32 bits, although the low-order 16 bits are aliases). Likewise, memory addresses are assumed to refer to 8 bit values and two memory addresses are aliases only when they are equal.
Since memory addresses may be symbolic, this function uses an SMT solver to return true if and only if the inequality of two addresses is unsatisfiable.
|
inline |
Print an abstract location.
The optional register dictionary is used for register names, the optional formatter is used for memory address expressions.
Definition at line 131 of file AbstractLocation.h.
Referenced by print().
|
inline |
Print an abstract location.
The optional register dictionary is used for register names, the optional formatter is used for memory address expressions.
Definition at line 135 of file AbstractLocation.h.
References print().
void Rose::BinaryAnalysis::AbstractLocation::print | ( | std::ostream & | out, |
const RegisterDictionary * | regdict, | ||
InstructionSemantics2::BaseSemantics::Formatter & | fmt | ||
) | const |
Print an abstract location.
The optional register dictionary is used for register names, the optional formatter is used for memory address expressions.