Package ghidra.program.util
Class SimpleDiffUtility
java.lang.Object
ghidra.program.util.SimpleDiffUtility
- Direct Known Subclasses:
DiffUtility
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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, Set<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
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 otherFunction 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.
-
Constructor Details
-
SimpleDiffUtility
public SimpleDiffUtility()
-
-
Method Details
-
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
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
-
getEndOfDelaySlots
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
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:
addr
- 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
-
getSymbol
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, Set<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
Find the variable symbol in otherProgram which corresponds to the specified varSym.- Parameters:
symbol
- variable symbolotherProgram
- other program- Returns:
- the variable symbol or null
-
getVariableSymbol
-
getVariableSymbol
Find the variable symbol in otherFunction which corresponds to the specified varSym.- Parameters:
varSym
- variable symbolotherFunction
- other function- Returns:
- the variable symbol or null
-
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
- other symbol tablevar
- variableotherStorage
- other variable storageotherFunctionSymbol
- other function symbol- Returns:
- the overlapping variable or null
-