Record Class AlignedMpIntHandler
- Record Components:
legs- the list of legs in little-endian ordertype- the type of the full multi-precision integer variablevn- the complete varnode accessible to this handleropnd- the (writable) list of local operands (in LE order)roOpnd- the read-only version ofopnd.
- All Implemented Interfaces:
VarHandler
In this case, we can usually give the operators direct access to the underlying mp-int operand.
We do need to be careful that we don't unintentionally permit the operator to use the variable's
storage for intermediate values. Thus, we have some provision for saying each leg is read-only,
which will cause attempts to store into them to instead generate a writable temporary local. Such
intermediate results will get written only by a call to
genStoreFromOpnd(Emitter, JitCodeGenerator, Opnd, Ext, Scope).
-
Constructor Summary
ConstructorsConstructorDescriptionAlignedMpIntHandler(List<JvmLocal<Types.TInt, JitType.IntJitType>> legs, JitType.MpIntJitType type, Varnode vn) Preferred constructorAlignedMpIntHandler(List<JvmLocal<Types.TInt, JitType.IntJitType>> legs, JitType.MpIntJitType type, Varnode vn, MpIntLocalOpnd opnd, MpIntLocalOpnd roOpnd) Creates an instance of aAlignedMpIntHandlerrecord class. -
Method Summary
Modifier and TypeMethodDescriptionprotected <N1 extends Emitter.Next,N0 extends Emitter.Ent<N1, Types.TInt>>
Emitter<N1> doGenSignFill(Emitter<N0> em, JitCodeGenerator<?> gen, List<JvmLocal<Types.TInt, JitType.IntJitType>> locals, Scope scope) Emit bytecode to sign fill the given localsprotected <N1 extends Emitter.Next,N0 extends Emitter.Ent<N1, Types.TInt>>
Emitter<N1> doGenStoreInt(Emitter<N0> em, JitCodeGenerator<?> gen, JitType.IntJitType type, JvmLocal<Types.TInt, JitType.IntJitType> local, Opnd.Ext ext, Scope scope) Emit bytecode to store a JVM int from the stack into the given localprotected <N1 extends Emitter.Next,N0 extends Emitter.Ent<N1, Types.TInt>>
Emitter<Emitter.Ent<N1, Types.TInt>> doGenStoreIntAndSign(Emitter<N0> em, JitCodeGenerator<?> gen, JitType.IntJitType type, JvmLocal<Types.TInt, JitType.IntJitType> local, Scope scope) Emit bytecode to compute the sign of the int on the stack, and store that int into a given local.protected <N1 extends Emitter.Next,N0 extends Emitter.Ent<N1, Types.TLong>>
Emitter<N1> doGenStoreLong(Emitter<N0> em, JitCodeGenerator<?> gen, JitType.LongJitType type, JvmLocal<Types.TInt, JitType.IntJitType> lower, JvmLocal<Types.TInt, JitType.IntJitType> upper, Opnd.Ext ext, Scope scope) Emit bytecode to store a JVM long from the stack into two given localsprotected <N1 extends Emitter.Next,N0 extends Emitter.Ent<N1, Types.TLong>>
Emitter<Emitter.Ent<N1, Types.TInt>> doGenStoreLongAndSign(Emitter<N0> em, JitCodeGenerator<?> gen, JitType.LongJitType type, JvmLocal<Types.TInt, JitType.IntJitType> lower, JvmLocal<Types.TInt, JitType.IntJitType> upper, Scope scope) Emit bytecode to compute the sign of the long on the stack, and store that long into two given locals.protected <N extends Emitter.Next>
Emitter<N> doGenZeroFill(Emitter<N> em, JitCodeGenerator<?> gen, List<JvmLocal<Types.TInt, JitType.IntJitType>> locals, Scope scope) Emit bytecode to zero fill the given localsfinal booleanIndicates whether some other object is "equal to" this one.protected <N extends Emitter.Next>
Emitter<N> genExt(Emitter<N> em, JitCodeGenerator<?> gen, int defLegs, int legsOut, Opnd.Ext ext, Scope scope) Emit bytecode to extend the value stored in our legs.<N extends Emitter.Next>
Emitter<Emitter.Ent<N, Types.TInt>> genLoadLegToStack(Emitter<N> em, JitCodeGenerator<?> gen, JitType.MpIntJitType type, int leg, Opnd.Ext ext) Emit bytecode to load one leg of a multi-precision value from the varnode onto the JVM stack.<N extends Emitter.Next>
Emitter<Emitter.Ent<N, Types.TRef<int[]>>> genLoadToArray(Emitter<N> em, JitCodeGenerator<?> gen, JitType.MpIntJitType to, Opnd.Ext ext, Scope scope, int slack) Emit bytecode to load the varnode's value into an integer array in little-endian order, pushing its ref onto the JVM stack.<N extends Emitter.Next>
Emitter<Emitter.Ent<N, Types.TInt>> genLoadToBool(Emitter<N> em, JitCodeGenerator<?> gen) Emit bytecode to load the varnode's value, interpreted as a boolean, as an integer onto the JVM stack.<N extends Emitter.Next>
Opnd.OpndEm<JitType.MpIntJitType, N> genLoadToOpnd(Emitter<N> em, JitCodeGenerator<?> gen, JitType.MpIntJitType to, Opnd.Ext ext, Scope scope) Emit bytecode to load the varnode's value into several locals.<TT extends Types.BPrim<?>,TJT extends JitType.SimpleJitType<TT, TJT>, N extends Emitter.Next>
Emitter<Emitter.Ent<N, TT>> genLoadToStack(Emitter<N> em, JitCodeGenerator<?> gen, TJT to, Opnd.Ext ext) Emit bytecode to load the varnode's value onto the JVM stack.<N1 extends Emitter.Next,N0 extends Emitter.Ent<N1, Types.TRef<int[]>>>
Emitter<N1> genStoreFromArray(Emitter<N0> em, JitCodeGenerator<?> gen, JitType.MpIntJitType from, Opnd.Ext ext, Scope scope) Emit bytecode to store a varnode's value from an array of integer legs, in little endian order<N extends Emitter.Next>
Emitter<N> genStoreFromOpnd(Emitter<N> em, JitCodeGenerator<?> gen, Opnd<JitType.MpIntJitType> from, Opnd.Ext ext, Scope scope) Emit bytecode to store a varnode's value from several locals.<FT extends Types.BPrim<?>,FJT extends JitType.SimpleJitType<FT, FJT>, N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, FT>>
Emitter<N1> genStoreFromStack(Emitter<N0> em, JitCodeGenerator<?> gen, FJT from, Opnd.Ext ext, Scope scope) Emit bytecode to store a value into a variable from the JVM stack.final inthashCode()Returns a hash code value for this object.legs()Returns the value of thelegsrecord component.opnd()Returns the value of theopndrecord component.roOpnd()Returns the value of theroOpndrecord component.Create a handler for aPcodeOp.SUBPIECEof a value.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.vn()Returns the value of thevnrecord component.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.pcode.emu.jit.alloc.VarHandler
name
-
Constructor Details
-
AlignedMpIntHandler
public AlignedMpIntHandler(List<JvmLocal<Types.TInt, JitType.IntJitType>> legs, JitType.MpIntJitType type, Varnode vn) Preferred constructor- Parameters:
legs- the list o legs in little-endian ordertype- the type of the full muti-precision integer variablevn- the complete varnode accessible to this handler
-
AlignedMpIntHandler
public AlignedMpIntHandler(List<JvmLocal<Types.TInt, JitType.IntJitType>> legs, JitType.MpIntJitType type, Varnode vn, MpIntLocalOpnd opnd, MpIntLocalOpnd roOpnd) Creates an instance of aAlignedMpIntHandlerrecord class.
-
-
Method Details
-
genLoadToStack
public <TT extends Types.BPrim<?>,TJT extends JitType.SimpleJitType<TT, Emitter<Emitter.Ent<N,TJT>, N extends Emitter.Next> TT>> genLoadToStack(Emitter<N> em, JitCodeGenerator<?> gen, TJT to, Opnd.Ext ext) Description copied from interface:VarHandlerEmit bytecode to load the varnode's value onto the JVM stack.- Specified by:
genLoadToStackin interfaceVarHandler- Type Parameters:
TT- the JVM type of the value to load onto the stackTJT- the p-code type of the value to load onto the stackN- the incoming stack- Parameters:
em- the emitter typed with the incoming stackgen- the code generatorto- the p-code type of the value expected on the JVM stack by the proceeding bytecodeext- the kind of extension to apply when adjusting from JVM size to varnode size- Returns:
- the emitter typed with the resulting stack
-
genLoadToOpnd
public <N extends Emitter.Next> Opnd.OpndEm<JitType.MpIntJitType,N> genLoadToOpnd(Emitter<N> em, JitCodeGenerator<?> gen, JitType.MpIntJitType to, Opnd.Ext ext, Scope scope) Description copied from interface:VarHandlerEmit bytecode to load the varnode's value into several locals.- Specified by:
genLoadToOpndin interfaceVarHandler- Type Parameters:
N- the incoming stack- Parameters:
em- the emitter typed with the incoming stackgen- the code generatorto- the p-code type of the value expected on the JVM stack by the proceeding bytecodeext- the kind of extension to applyscope- a scope for generating temporary local storage- Returns:
- the operand containing the locals, and the emitter typed with the incoming stack
-
genLoadLegToStack
public <N extends Emitter.Next> Emitter<Emitter.Ent<N,Types.TInt>> genLoadLegToStack(Emitter<N> em, JitCodeGenerator<?> gen, JitType.MpIntJitType type, int leg, Opnd.Ext ext) Description copied from interface:VarHandlerEmit bytecode to load one leg of a multi-precision value from the varnode onto the JVM stack.- Specified by:
genLoadLegToStackin interfaceVarHandler- Type Parameters:
N- the incoming stack- Parameters:
em- the emitter typed with the incoming stackgen- the code generatortype- the p-code type of the complete multi-precision valueleg- the index of the leg to load, 0 being least significantext- the kind of extension to apply- Returns:
- the emitter typed with the resulting stack, i.e., having the int leg pushed onto it
-
genLoadToArray
public <N extends Emitter.Next> Emitter<Emitter.Ent<N,Types.TRef<int[]>>> genLoadToArray(Emitter<N> em, JitCodeGenerator<?> gen, JitType.MpIntJitType to, Opnd.Ext ext, Scope scope, int slack) Description copied from interface:VarHandlerEmit bytecode to load the varnode's value into an integer array in little-endian order, pushing its ref onto the JVM stack.- Specified by:
genLoadToArrayin interfaceVarHandler- Type Parameters:
N- the incoming stack- Parameters:
em- the emitter typed with the incoming stackgen- the code generatorto- the p-code type of the complete multi-precision valueext- the kind of extension to applyscope- a scope for generating temporary local storageslack- the number of additional, more significant, elements to allocate in the array- Returns:
- the emitter typed with the resulting stack, i.e., having the ref pushed onto it
-
genLoadToBool
public <N extends Emitter.Next> Emitter<Emitter.Ent<N,Types.TInt>> genLoadToBool(Emitter<N> em, JitCodeGenerator<?> gen) Description copied from interface:VarHandlerEmit bytecode to load the varnode's value, interpreted as a boolean, as an integer onto the JVM stack.- Specified by:
genLoadToBoolin interfaceVarHandler- Type Parameters:
N- the incoming stack- Parameters:
em- the emitter typed with the incoming stackgen- the code generator- Returns:
- the emitter typed with the resulting stack, i.e., having the int boolean pushed onto it
-
doGenStoreInt
protected <N1 extends Emitter.Next,N0 extends Emitter.Ent<N1, Emitter<N1> doGenStoreIntTypes.TInt>> (Emitter<N0> em, JitCodeGenerator<?> gen, JitType.IntJitType type, JvmLocal<Types.TInt, JitType.IntJitType> local, Opnd.Ext ext, Scope scope) Emit bytecode to store a JVM int from the stack into the given local- Type Parameters:
N1- the tail of the incoming stackN0- the incoming stack, having the int on top- Parameters:
em- the emitter typed with the incoming stackgen- the code generatortype- the p-code type of the int on the stacklocal- the local to receive the valueext- the kind of extension to applyscope- a scope for generating local storage- Returns:
- the emitter typed with the resulting stack, i.e., having popped the int
-
doGenStoreIntAndSign
protected <N1 extends Emitter.Next,N0 extends Emitter.Ent<N1, Emitter<Emitter.Ent<N1,Types.TInt>> Types.TInt>> doGenStoreIntAndSign(Emitter<N0> em, JitCodeGenerator<?> gen, JitType.IntJitType type, JvmLocal<Types.TInt, JitType.IntJitType> local, Scope scope) Emit bytecode to compute the sign of the int on the stack, and store that int into a given local.The int is copied and stored into the given local. Then, the sign of the int is computed and remains on the stack. Signed extension is assumed.
- Type Parameters:
N1- the tail of the incoming stackN0- the incoming stack, having the int on top- Parameters:
em- the emitter typed with the incoming stackgen- the code generatortype- the p-code type of the int on the stack. Note that this type determines the position of the sign bit.local- the local to receive the valuescope- a scope for generating local storage- Returns:
- the emitter typed with the resulting stack, i.e., having popped the int and pushed the sign
-
doGenStoreLong
protected <N1 extends Emitter.Next,N0 extends Emitter.Ent<N1, Emitter<N1> doGenStoreLongTypes.TLong>> (Emitter<N0> em, JitCodeGenerator<?> gen, JitType.LongJitType type, JvmLocal<Types.TInt, JitType.IntJitType> lower, JvmLocal<Types.TInt, JitType.IntJitType> upper, Opnd.Ext ext, Scope scope) Emit bytecode to store a JVM long from the stack into two given locals- Type Parameters:
N1- the tail of the incoming stackN0- the incoming stack, having the long on top- Parameters:
em- the emitter typed with the incoming stackgen- the code generatortype- the p-code type of the int on the stacklower- the local to receive the lower 32 bits of the valueupper- the local to receive the upper 32 bits of the valueext- the kind of extension to applyscope- a scope for generating local storage- Returns:
- the emitter typed with the resulting stack, i.e., having popped the long
-
doGenStoreLongAndSign
protected <N1 extends Emitter.Next,N0 extends Emitter.Ent<N1, Emitter<Emitter.Ent<N1,Types.TLong>> Types.TInt>> doGenStoreLongAndSign(Emitter<N0> em, JitCodeGenerator<?> gen, JitType.LongJitType type, JvmLocal<Types.TInt, JitType.IntJitType> lower, JvmLocal<Types.TInt, JitType.IntJitType> upper, Scope scope) Emit bytecode to compute the sign of the long on the stack, and store that long into two given locals.The long is copied and stored into the given local. Then, the sign of the long is computed and remains on the stack as an int. Signed extension is assumed.
- Type Parameters:
N1- the tail of the incoming stackN0- the incoming stack, having the long on top- Parameters:
em- the emitter typed with the incoming stackgen- the code generatortype- the p-code type of the long on the stack. Note that this type determines the position of the sign bit.lower- the local to receive the lower 32 bits of the valueupper- the local to receive the upper 32 bits of the valuescope- a scope for generating local storage- Returns:
- the emitter typed with the resulting stack, i.e., having popped the long and pushed the sign
-
doGenZeroFill
protected <N extends Emitter.Next> Emitter<N> doGenZeroFill(Emitter<N> em, JitCodeGenerator<?> gen, List<JvmLocal<Types.TInt, JitType.IntJitType>> locals, Scope scope) Emit bytecode to zero fill the given locals- Type Parameters:
N- the incoming stack- Parameters:
em- the emitter typed with the incoming stackgen- the code generatorlocals- the locals to zero fillscope- a scope for generating local storage- Returns:
- the emitter typed with the incoming stack
-
doGenSignFill
protected <N1 extends Emitter.Next,N0 extends Emitter.Ent<N1, Emitter<N1> doGenSignFillTypes.TInt>> (Emitter<N0> em, JitCodeGenerator<?> gen, List<JvmLocal<Types.TInt, JitType.IntJitType>> locals, Scope scope) Emit bytecode to sign fill the given locals- Type Parameters:
N1- the tail of the incoming stackN0- the incoming stack having the sign int on top- Parameters:
em- the emitter typed with the incoming stackgen- the code generatorlocals- the locals to sign fillscope- a scope for generating local storage- Returns:
- the emitter typed with the resulting stack, i.e., having popped the sign
-
genStoreFromStack
public <FT extends Types.BPrim<?>,FJT extends JitType.SimpleJitType<FT, Emitter<N1> genStoreFromStackFJT>, N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, FT>> (Emitter<N0> em, JitCodeGenerator<?> gen, FJT from, Opnd.Ext ext, Scope scope) Description copied from interface:VarHandlerEmit bytecode to store a value into a variable from the JVM stack.- Specified by:
genStoreFromStackin interfaceVarHandler- Type Parameters:
FT- the JVM type of the value on the stackFJT- the p-code type of the value on the stackN1- the tail of the incoming stackN0- the incoming stack having the value to store on top- Parameters:
em- the emitter typed with the incoming stackgen- the code generatorfrom- the p-code type of the value on the stackext- the kind of extension to applyscope- a scope for generating temporary local storage- Returns:
- the emitter typed with the resulting stack, i.e., having popped the value
-
genExt
protected <N extends Emitter.Next> Emitter<N> genExt(Emitter<N> em, JitCodeGenerator<?> gen, int defLegs, int legsOut, Opnd.Ext ext, Scope scope) Emit bytecode to extend the value stored in our legs.- Type Parameters:
N- the tail of the incoming stack- Parameters:
em- the emitter typed with the incoming stackgen- the code generatordefLegs- the number of legs having the input valuelegsOut- the number of legs to receive the output value. If this is less than or equal todefLegs, there is no extension to apply, so no code is emitted.ext- the kind of extension to applyscope- a scope for generating temporary local storage- Returns:
- the emitter typed with the incoming stack
-
genStoreFromOpnd
public <N extends Emitter.Next> Emitter<N> genStoreFromOpnd(Emitter<N> em, JitCodeGenerator<?> gen, Opnd<JitType.MpIntJitType> from, Opnd.Ext ext, Scope scope) Description copied from interface:VarHandlerEmit bytecode to store a varnode's value from several locals.- Specified by:
genStoreFromOpndin interfaceVarHandler- Type Parameters:
N- the incoming stack- Parameters:
em- the emitter typed with the incoming stackgen- the code generatorfrom- the operand whose locals contain the value to be storedext- the kind of extension to applyscope- a scope for generating temporary local storage- Returns:
- the emitter typed with the incoming stack
-
genStoreFromArray
public <N1 extends Emitter.Next,N0 extends Emitter.Ent<N1, Emitter<N1> genStoreFromArrayTypes.TRef<int[]>>> (Emitter<N0> em, JitCodeGenerator<?> gen, JitType.MpIntJitType from, Opnd.Ext ext, Scope scope) Description copied from interface:VarHandlerEmit bytecode to store a varnode's value from an array of integer legs, in little endian order- Specified by:
genStoreFromArrayin interfaceVarHandler- Type Parameters:
N1- the tail of the incoming stackN0- the incoming stack having the array ref on top- Parameters:
em- the emitter typed with the incoming stackgen- the code generatorfrom- the p-code type of the value on the stackext- the kind of extension to applyscope- a scope for generating temporary local storage- Returns:
- the emitter typed with the resulting stack, i.e., having popped the array
-
subpiece
Description copied from interface:VarHandlerCreate a handler for aPcodeOp.SUBPIECEof a value.To implement
subpiece, we could load the entire varnode and then extract the designated portion. Or, we could load only the designated portion, averting any code and execution cost of loading the un-designated portions. We accomplish this by re-writing the subpiece op and a load of the sub-varnode.- Specified by:
subpiecein interfaceVarHandler- Parameters:
endian- the endianness of the emulation targetbyteOffset- the number of least-significant bytes to removemaxByteSize- the maximum size of the resulting variable. In general, a subpiece should never exceed the size of the parent varnode, but if it does, this will truncate that excess.- Returns:
- the resulting subpiece handler
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
legs
Returns the value of thelegsrecord component.- Returns:
- the value of the
legsrecord component
-
type
Returns the value of thetyperecord component.- Specified by:
typein interfaceVarHandler- Returns:
- the value of the
typerecord component
-
vn
Returns the value of thevnrecord component.- Specified by:
vnin interfaceVarHandler- Returns:
- the value of the
vnrecord component
-
opnd
Returns the value of theopndrecord component.- Returns:
- the value of the
opndrecord component
-
roOpnd
Returns the value of theroOpndrecord component.- Returns:
- the value of the
roOpndrecord component
-