Package ghidra.program.model.pcode
Class DynamicHash
java.lang.Object
ghidra.program.model.pcode.DynamicHash
A hash utility to uniquely identify a temporary Varnode in data-flow
Most Varnodes can be identified within the data-flow graph by their storage address
and the address of the PcodeOp that defines them. For temporary registers,
this does not work because the storage address is ephemeral. This class allows
Varnodes like temporary registers (and constants) to be robustly identified
by hashing details of the local data-flow.
This class, when presented with a Varnode (via constructor), calculates a hash (getHash())
and an address (getAddress()) of the PcodeOp most closely associated with the Varnode,
either the defining op or the op directly reading the Varnode.
There are actually four hash variants that can be calculated, labeled 0, 1, 2, or 3,
which incrementally hash in a larger portion of data-flow.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDynamicHash
(PcodeOp op, int inputIndex) Construct a level 0 hash on the input Varnode to the given PcodeOp The PcodeOp can be raw, no linked into a PcodeSyntaxTreeDynamicHash
(PcodeOp op, int slot, PcodeSyntaxTree fd) Construct a unique hash that allows recovery of a specific PcodeOp and slot from the syntax tree.DynamicHash
(Varnode root, int method) Construct a hash of the given Varnode with a specific hash method.DynamicHash
(Varnode root, PcodeSyntaxTree fd) Construct a unique hash for the given Varnode, which must be in a syntax tree. -
Method Summary
Modifier and TypeMethodDescriptionstatic long[]
calcConstantHash
(Instruction instr, long value) Given a constant value accessed as an operand by a particular instruction, calculate a (level 0) hash for (any) corresponding constant varnodestatic long
clearTotalPosition
(long h) static PcodeOp
findOp
(PcodeSyntaxTree fd, Address addr, long h) static Varnode
findVarnode
(PcodeSyntaxTree fd, Address addr, long h) static void
gatherFirstLevelVars
(ArrayList<Varnode> varlist, PcodeSyntaxTree fd, Address addr, long h) static void
gatherOpsAtAddress
(ArrayList<PcodeOp> oplist, PcodeSyntaxTree fd, Address addr) static int
getComparable
(long h) long
getHash()
static boolean
getIsNotAttached
(long h) static int
getMethodFromHash
(long h) static int
getOpCodeFromHash
(long h) static int
getPositionFromHash
(long h) static int
getSlotFromHash
(long h) static int
getTotalFromHash
(long h)
-
Field Details
-
transtable
public static final int[] transtable
-
-
Constructor Details
-
DynamicHash
Construct a hash of the given Varnode with a specific hash method.- Parameters:
root
- is the given Varnodemethod
- is the method (0, 1, 2, 3)
-
DynamicHash
Construct a unique hash for the given Varnode, which must be in a syntax tree. The hash method is cycled until a uniquely identifying one is found.- Parameters:
root
- is the given Varnodefd
- is the PcodeSyntaxTree containing the Varnode
-
DynamicHash
Construct a unique hash that allows recovery of a specific PcodeOp and slot from the syntax tree. The hash method is cycled until a uniquely identifying one is found.- Parameters:
op
- is the specific PcodeOp to hashslot
- is the specific slot (-1 is the output, >=0 is an input)fd
- is the PcodeSyntaxTree containing the PcodeOp
-
DynamicHash
Construct a level 0 hash on the input Varnode to the given PcodeOp The PcodeOp can be raw, no linked into a PcodeSyntaxTree- Parameters:
op
- is the given PcodeOpinputIndex
- is the index of the input Varnode to hash
-
-
Method Details
-
getHash
public long getHash() -
getAddress
-
findVarnode
-
findOp
-
gatherOpsAtAddress
-
gatherFirstLevelVars
public static void gatherFirstLevelVars(ArrayList<Varnode> varlist, PcodeSyntaxTree fd, Address addr, long h) -
getSlotFromHash
public static int getSlotFromHash(long h) -
getMethodFromHash
public static int getMethodFromHash(long h) -
getOpCodeFromHash
public static int getOpCodeFromHash(long h) -
getPositionFromHash
public static int getPositionFromHash(long h) -
getTotalFromHash
public static int getTotalFromHash(long h) -
getIsNotAttached
public static boolean getIsNotAttached(long h) -
clearTotalPosition
public static long clearTotalPosition(long h) -
getComparable
public static int getComparable(long h) -
calcConstantHash
Given a constant value accessed as an operand by a particular instruction, calculate a (level 0) hash for (any) corresponding constant varnode- Parameters:
instr
- is the instruction referencing the constantvalue
- of the constant- Returns:
- array of hash values (may be zero length)
-