Package ghidra.program.util
Class SimpleDiffUtility
- java.lang.Object
-
- ghidra.program.util.SimpleDiffUtility
-
- Direct Known Subclasses:
DiffUtility
public class SimpleDiffUtility extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description SimpleDiffUtility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AddressSetView
expandAddressSetToIncludeFullDelaySlots(Program program, AddressSetView originalSet)
Expand a specified address set to include complete delay slotted instructions which may be included at the start or end of each range within the specified address set.static Address
getCompatibleAddress(Program program, Address addr, Program otherProgram)
Convert an address from the specified program to a comparable address in the specified otherProgram.static AddressSpace
getCompatibleAddressSpace(AddressSpace addrSpace, Program otherProgram)
static VariableStorage
getCompatibleVariableStorage(Program program, VariableStorage storage, Program otherProgram)
Convert a variable storage object from the specified program to a comparable variable storage object in the specified otherProgram.static Varnode
getCompatibleVarnode(Program program, Varnode varnode, Program otherProgram)
Convert a varnode from the specified program to a comparable varnode in the specified otherProgram.static Address
getEndOfDelaySlots(Instruction instr)
If the specified instruction is contained within a delay slot, or has delay slots, the maximum address of the last delay slot instruction will be returned.static ExternalLocation
getMatchingExternalLocation(Program program, ExternalLocation externalLocation, Program otherProgram)
Given an external location for a specified program, get the corresponding external location, which has the same name and path, from the specified otherProgram.
Note: The type of the returned external location may be different than the type of the original external location.static Symbol
getMatchingExternalSymbol(Program program, Symbol symbol, Program otherProgram, java.util.Set<java.lang.Long> otherRestrictedSymbolIds)
Given an external symbol for a specified program, get the corresponding symbol, which has the same name and path, from the specified otherProgram.
Note: The type of the returned symbol may be different than the type of the symbolprotected static Variable
getOverlappingVariable(SymbolTable otherSymTable, Variable var, VariableStorage otherStorage, Symbol otherFunctionSymbol)
Find overlapping variable which meets the following conditions 1.static Address
getStartOfDelaySlots(Instruction instr)
static Symbol
getSymbol(Symbol symbol, Program otherProgram)
Given a symbol for a specified program, get the corresponding symbol from the specified otherProgram.protected static Symbol
getVariableSymbol(Symbol varSym, Function otherFunction)
Find the variable symbol in otherProgram which corresponds to the specified varSym.static Symbol
getVariableSymbol(Symbol symbol, Program otherProgram)
Find the variable symbol in otherProgram which corresponds to the specified varSym.protected static Symbol
getVariableSymbol(Symbol varSym, Program otherProgram, Namespace otherNamespace)
protected static Address
translateMemoryAddress(Address addr, Program otherProgram, boolean exactMatchOnly)
Convert an address from the specified program to a comparable address in the specified otherProgram.
-
-
-
Method Detail
-
getCompatibleVariableStorage
public static VariableStorage getCompatibleVariableStorage(Program program, VariableStorage storage, Program otherProgram)
Convert a variable storage object from the specified program to a comparable variable storage object in the specified otherProgram. Certain variable storage (UNIQUE/HASH-based) will always produce a null return object.- Parameters:
program
- program which contains the specified address instancestorage
- variable storage in programotherProgram
- other program- Returns:
- storage for otherProgram or null if storage can not be mapped to other program
-
getCompatibleVarnode
public static Varnode getCompatibleVarnode(Program program, Varnode varnode, Program otherProgram)
Convert a varnode from the specified program to a comparable varnode in the specified otherProgram. Certain varnode addresses spaces (UNIQUE, HASH) will always produce a null return varnode.- Parameters:
program
- program which contains the specified address instancevarnode
- varnode in programotherProgram
- other program- Returns:
- varnode for otherProgram or null if varnode can not be mapped to other program
-
getStartOfDelaySlots
public static Address getStartOfDelaySlots(Instruction instr)
-
getEndOfDelaySlots
public static Address getEndOfDelaySlots(Instruction instr)
If the specified instruction is contained within a delay slot, or has delay slots, the maximum address of the last delay slot instruction will be returned. If a normal instruction is specified the instructions maximum address is returned.- Parameters:
instr
-- Returns:
- maximum address of instruction or its last delay slot
-
expandAddressSetToIncludeFullDelaySlots
public static AddressSetView expandAddressSetToIncludeFullDelaySlots(Program program, AddressSetView originalSet)
Expand a specified address set to include complete delay slotted instructions which may be included at the start or end of each range within the specified address set.- Parameters:
program
- programoriginalSet
- original address set- Returns:
- expanded address set
-
getCompatibleAddress
public static Address getCompatibleAddress(Program program, Address addr, Program otherProgram)
Convert an address from the specified program to a comparable address in the specified otherProgram.- Parameters:
program
- program which contains the specified address instanceaddr
- address in programotherProgram
- other program- Returns:
- address for otherProgram or null if no such address exists.
-
translateMemoryAddress
protected static Address translateMemoryAddress(Address addr, Program otherProgram, boolean exactMatchOnly)
Convert an address from the specified program to a comparable address in the specified otherProgram.- Parameters:
program
- program which contains the specified address instanceaddr
- address in programotherProgram
- other programexactMatchOnly
- if false and addr is an overlay address, a closest match will be returned if possible- Returns:
- address for otherProgram or null if no such address exists.
-
getCompatibleAddressSpace
public static AddressSpace getCompatibleAddressSpace(AddressSpace addrSpace, Program otherProgram)
-
getSymbol
public static Symbol getSymbol(Symbol symbol, Program otherProgram)
Given a symbol for a specified program, get the corresponding symbol from the specified otherProgram.- Parameters:
symbol
- symbol to look forotherProgram
- other program- Returns:
- corresponding symbol for otherProgram or null if no such symbol exists.
-
getMatchingExternalSymbol
public static Symbol getMatchingExternalSymbol(Program program, Symbol symbol, Program otherProgram, java.util.Set<java.lang.Long> otherRestrictedSymbolIds)
Given an external symbol for a specified program, get the corresponding symbol, which has the same name and path, from the specified otherProgram.
Note: The type of the returned symbol may be different than the type of the symbol- Parameters:
program
- program which contains the specified symbol instancesymbol
- symbol to look forotherProgram
- other programotherRestrictedSymbolIds
- an optional set of symbol ID's from the other program which will be treated as the exclusive set of candidate symbols to consider.- Returns:
- corresponding external symbol for otherProgram or null if no such symbol exists.
-
getMatchingExternalLocation
public static ExternalLocation getMatchingExternalLocation(Program program, ExternalLocation externalLocation, Program otherProgram)
Given an external location for a specified program, get the corresponding external location, which has the same name and path, from the specified otherProgram.
Note: The type of the returned external location may be different than the type of the original external location.- Parameters:
program
- program which contains the specified external location instanceexternalLocation
- external location to look forotherProgram
- other program- Returns:
- corresponding external location for otherProgram or null if no such external location exists.
-
getVariableSymbol
public static Symbol getVariableSymbol(Symbol symbol, Program otherProgram)
Find the variable symbol in otherProgram which corresponds to the specified varSym.- Parameters:
varSym
- variable symbolotherProgram
-
-
getVariableSymbol
protected static Symbol getVariableSymbol(Symbol varSym, Program otherProgram, Namespace otherNamespace)
-
getVariableSymbol
protected static Symbol getVariableSymbol(Symbol varSym, Function otherFunction)
Find the variable symbol in otherProgram which corresponds to the specified varSym.- Parameters:
varSym
- variable symbolotherProgram
-
-
getOverlappingVariable
protected static Variable getOverlappingVariable(SymbolTable otherSymTable, Variable var, VariableStorage otherStorage, Symbol otherFunctionSymbol)
Find overlapping variable which meets the following conditions 1. First use offset matches 2. Ordinal matches (for parameters only) 3. Minimum or maximum address matches- Parameters:
otherSymTable
-var
-otherStorage
-otherFunc
-- Returns:
-
-