Enum Class TraceMemoryStatePcodeArithmetic
- All Implemented Interfaces:
PcodeArithmetic<TraceMemoryState>,Serializable,Comparable<TraceMemoryStatePcodeArithmetic>,Constable
TraceMemoryState
This arithmetic is meant to be used as an auxiliary to a concrete arithmetic. It should be used
with a state that knows how to load state markings from the same trace as the concrete state, so
that it can compute the "state" of a Sleigh expression's value. It essentially works like a
rudimentary taint analyzer: If any part of any input to the expression in tainted, i.e., not
TraceMemoryState.KNOWN, then the result is TraceMemoryState.UNKNOWN. This is best
exemplified in binaryOp(int, int, int, TraceMemoryState, int, TraceMemoryState).
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>Nested classes/interfaces inherited from interface ghidra.pcode.exec.PcodeArithmetic
PcodeArithmetic.Purpose -
Enum Constant Summary
Enum Constants -
Field Summary
Fields inherited from interface ghidra.pcode.exec.PcodeArithmetic
SIZEOF_SIZEOF -
Method Summary
Modifier and TypeMethodDescriptionbinaryOp(int opcode, int sizeout, int sizein1, TraceMemoryState in1, int sizein2, TraceMemoryState in2) Apply a binary operator to the given inputsfromConst(byte[] value) Convert the given constant concrete value to typeThaving the same size.fromConst(long value, int size) Convert the given constant concrete value to typeThaving the given size.fromConst(BigInteger value, int size, boolean isContextreg) Convert the given constant concrete value to typeThaving the given size.Get the type of values over which this arithmetic operates.Get the endianness of this arithmeticmodAfterLoad(int sizeinOffset, AddressSpace space, TraceMemoryState inOffset, int sizeinValue, TraceMemoryState inValue) Apply any modifications after a value is loadedmodBeforeStore(int sizeinOffset, AddressSpace space, TraceMemoryState inOffset, int sizeinValue, TraceMemoryState inValue) Apply any modifications before a value is storedlongsizeOf(TraceMemoryState value) Get the size in bytes, if possible, of the given abstract valuebyte[]toConcrete(TraceMemoryState value, PcodeArithmetic.Purpose purpose) Convert, if possible, the given abstract value to a concrete byte arrayunaryOp(int opcode, int sizeout, int sizein1, TraceMemoryState in1) Apply a unary operator to the given inputReturns the enum constant of this class with the specified name.static TraceMemoryStatePcodeArithmetic[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfMethods inherited from interface ghidra.pcode.exec.PcodeArithmetic
binaryOp, fromConst, fromConst, fromConst, fromConst, fromConst, fromConst, fromConst, fromConst, fromConst, isTrue, modAfterLoad, modBeforeStore, ptrAdd, ptrSub, sizeOfAbstract, toAddress, toBigInteger, toDouble, toFloat, toLong, toRegisterValue, unaryOp
-
Enum Constant Details
-
INSTANCE
The singleton instance
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getDomain
Description copied from interface:PcodeArithmeticGet the type of values over which this arithmetic operates.- Specified by:
getDomainin interfacePcodeArithmetic<TraceMemoryState>- Returns:
- the domain
-
getEndian
Description copied from interface:PcodeArithmeticGet the endianness of this arithmeticOften T is a byte array, or at least represents one abstractly. Ideally, it is an array where each element is an abstraction of a byte. If that is the case, then the arithmetic likely has to interpret those bytes as integral values according to an endianness. This should return that endianness.
If the abstraction has no notion of endianness, return null. In that case, the both
PcodeArithmetic.fromConst(BigInteger, int, boolean)andPcodeArithmetic.fromConst(long, int)must be overridden. Furthermore, unlessPcodeArithmetic.toConcrete(Object, Purpose)is guaranteed to throw an exception, thenPcodeArithmetic.toBigInteger(Object, Purpose)andPcodeArithmetic.toLong(Object, Purpose)must also be overridden.- Specified by:
getEndianin interfacePcodeArithmetic<TraceMemoryState>- Returns:
- the endianness or null
-
unaryOp
Description copied from interface:PcodeArithmeticApply a unary operator to the given inputNote the sizes of variables are given, because values don't necessarily have an intrinsic size. For example, a
BigIntegermay have a minimum encoding size, but that does not necessarily reflect the size of the variable from which is was read.- Specified by:
unaryOpin interfacePcodeArithmetic<TraceMemoryState>- Parameters:
opcode- the p-code opcodesizeout- the size (in bytes) of the output variablesizein1- the size (in bytes) of the input variablein1- the input value- Returns:
- the output value
-
binaryOp
public TraceMemoryState binaryOp(int opcode, int sizeout, int sizein1, TraceMemoryState in1, int sizein2, TraceMemoryState in2) Description copied from interface:PcodeArithmeticApply a binary operator to the given inputsNote the sizes of variables are given, because values don't necessarily have an intrinsic size. For example, a
BigIntegermay have a minimum encoding size, but that does not necessarily reflect the size of the variable from which is was read.- Specified by:
binaryOpin interfacePcodeArithmetic<TraceMemoryState>- Parameters:
opcode- the operation's opcode. SeePcodeOp.sizeout- the size (in bytes) of the output variablesizein1- the size (in bytes) of the first (left) input variablein1- the first (left) input valuesizein2- the size (in bytes) of the second (right) input variablein2- the second (right) input value- Returns:
- the output value
-
modBeforeStore
public TraceMemoryState modBeforeStore(int sizeinOffset, AddressSpace space, TraceMemoryState inOffset, int sizeinValue, TraceMemoryState inValue) Description copied from interface:PcodeArithmeticApply any modifications before a value is storedThis implements any abstractions associated with
PcodeOp.STORE. This is called on the offset and the value before the value is actually stored into the state. NOTE: STORE ops always quantize the offset.- Specified by:
modBeforeStorein interfacePcodeArithmetic<TraceMemoryState>- Parameters:
sizeinOffset- the size (in bytes) of the variable used for indirectionspace- the address spaceinOffset- the value used as the address (or offset)sizeinValue- the size (in bytes) of the variable to store and of the output variableinValue- the value to store- Returns:
- the modified value to store
-
modAfterLoad
public TraceMemoryState modAfterLoad(int sizeinOffset, AddressSpace space, TraceMemoryState inOffset, int sizeinValue, TraceMemoryState inValue) Description copied from interface:PcodeArithmeticApply any modifications after a value is loadedThis implements any abstractions associated with
PcodeOp.LOAD. This is called on the address/offset and the value after the value is actually loaded from the state. NOTE: LOAD ops always quantize the offset.- Specified by:
modAfterLoadin interfacePcodeArithmetic<TraceMemoryState>- Parameters:
sizeinOffset- the size (in bytes) of the variable used for indirectionspace- the address spaceinOffset- the value used as the offsetsizeinValue- the size (in bytes) of the variable loaded and of the output variableinValue- the value loaded- Returns:
- the modified value loaded
-
fromConst
Description copied from interface:PcodeArithmeticConvert the given constant concrete value to typeThaving the same size.- Specified by:
fromConstin interfacePcodeArithmetic<TraceMemoryState>- Parameters:
value- the constant value- Returns:
- the value as a
T
-
fromConst
Description copied from interface:PcodeArithmeticConvert the given constant concrete value to typeThaving the given size.Note that the size may not be applicable to
T. It is given to ensure the value can be held in a variable of that size when passed to downstream operators or stored in the executor state.- Specified by:
fromConstin interfacePcodeArithmetic<TraceMemoryState>- Parameters:
value- the constant valuesize- the size (in bytes) of the variable into which the value is to be storedisContextreg- true to indicate the value is from the disassembly context register. IfTrepresents bytes, and the value is the contextreg, then the bytes are in big endian, no matter the machine language's endianness.- Returns:
- the value as a
T
-
fromConst
Description copied from interface:PcodeArithmeticConvert the given constant concrete value to typeThaving the given size.Note that the size may not be applicable to
T. It is given to ensure the value can be held in a variable of that size when passed to downstream operators or stored in the executor state.- Specified by:
fromConstin interfacePcodeArithmetic<TraceMemoryState>- Parameters:
value- the constant valuesize- the size (in bytes) of the variable into which the value is to be stored- Returns:
- the value as a
T
-
toConcrete
Description copied from interface:PcodeArithmeticConvert, if possible, the given abstract value to a concrete byte array- Specified by:
toConcretein interfacePcodeArithmetic<TraceMemoryState>- Parameters:
value- the abstract valuepurpose- the purpose for which the emulator needs a concrete value- Returns:
- the array
-
sizeOf
Description copied from interface:PcodeArithmeticGet the size in bytes, if possible, of the given abstract valueIf the abstract value does not conceptually have a size, throw an exception.
- Specified by:
sizeOfin interfacePcodeArithmetic<TraceMemoryState>- Parameters:
value- the abstract value- Returns:
- the size in bytes
-