Record Class ShiftedMpIntHandler
- Record Components:
parts- the list of locals spanned by the variable, in little-endian order.type- the type of the multi-precision integer variable (only considering the varnode, not the whole comprised of the spanned parts). In the diagram, this would beJitType.MpIntJitType(size=11).vn- the complete varnode accessible to this handler. NOTE: The handler must take care not to modify or permit access to portions of the parts at either end not actually part of its varnode. In the example, the lower 24 bits ofparts[0]and the upper 16 bits ofparts[3]cannot be accessed. Should a caller togenLoadToOpnd(Emitter, JitCodeGenerator, MpIntJitType, Ext, Scope)specify a type larger than 11 bytes, only the 11-byte value is loaded, then extended to the requested size. We do not load the more sigificant portion ofparts[3].byteShift- the number of least-significant bytes of the handler's least-significant part that are excluded from the variable's least-significant leg. I.e., the number of bytes to shift right when loading the value. In the example, this is 3.
- All Implemented Interfaces:
VarHandler
The below diagram is an example shifted allocation, whose byteShift value is 3, and whose
varnode size is 11 (admittedly pathological, but made to illustrate a complicated example).
+--*--*--*--+--*--*--*--+--*--*--*--+--*--*--*--+
| parts[3] | parts[2] | parts[1] | parts[0] |
+-----------+-----------+-----------+-----------+
+--*--*--+--*--*--*--+--*--*--*--+
| leg2 | leg1 | leg0 |
+--------+-----------+-----------+
In the unaligned case, all loads and stores require copying the shifted value into a series of temporary locals, representing the legs of the value. Because these are already temporary, the operator may freely use the legs as temporary storage.
-
Constructor Summary
ConstructorsConstructorDescriptionShiftedMpIntHandler(List<JvmLocal<Types.TInt, JitType.IntJitType>> parts, JitType.MpIntJitType type, Varnode vn, int byteShift) Creates an instance of aShiftedMpIntHandlerrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thebyteShiftrecord component.final booleanIndicates whether some other object is "equal to" this one.<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 type, 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> opnd, 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.parts()Returns the value of thepartsrecord 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
-
ShiftedMpIntHandler
public ShiftedMpIntHandler(List<JvmLocal<Types.TInt, JitType.IntJitType>> parts, JitType.MpIntJitType type, Varnode vn, int byteShift) Creates an instance of aShiftedMpIntHandlerrecord 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 type, 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 generatortype- 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
-
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
-
genStoreFromOpnd
public <N extends Emitter.Next> Emitter<N> genStoreFromOpnd(Emitter<N> em, JitCodeGenerator<?> gen, Opnd<JitType.MpIntJitType> opnd, Opnd.Ext ext, Scope scope) Emit bytecode to store a varnode's value from several locals.The general strategy is to load the source operand one leg at a time. In order to put each leg with the remaining portion of the previous leg in position, we use a long on the stack as a temporary. This eases "gluing" the legs together and then writing the shifted portion into each part.
- Specified by:
genStoreFromOpndin interfaceVarHandler- Type Parameters:
N- the incoming stack- Parameters:
em- the emitter typed with the incoming stackgen- the code generatoropnd- 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) Emit bytecode to store a varnode's value from an array of integer legs, in little endian orderThe strategy here is the same as for
genStoreFromOpnd(Emitter, JitCodeGenerator, Opnd, Ext, Scope)- 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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
parts
Returns the value of thepartsrecord component.- Returns:
- the value of the
partsrecord 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
-
byteShift
public int byteShift()Returns the value of thebyteShiftrecord component.- Returns:
- the value of the
byteShiftrecord component
-