mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
05ee2c14b9
5 changed files with 134 additions and 35 deletions
|
@ -95,8 +95,6 @@ public class PseudoDisassembler {
|
|||
|
||||
private boolean respectExecuteFlag = false;
|
||||
|
||||
private AddressSetView executeSet;
|
||||
|
||||
/**
|
||||
* Create a pseudo disassembler for the given program.
|
||||
*/
|
||||
|
@ -111,18 +109,6 @@ public class PseudoDisassembler {
|
|||
|
||||
this.programContext = program.getProgramContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return cached addressSet of executable memory blocks
|
||||
*/
|
||||
private AddressSetView getExecuteSet() {
|
||||
if (executeSet != null) {
|
||||
return executeSet;
|
||||
}
|
||||
|
||||
executeSet = memory.getExecuteSet();
|
||||
return executeSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum number of instructions to check
|
||||
|
@ -617,6 +603,7 @@ public class PseudoDisassembler {
|
|||
boolean allowExistingInstructions, boolean mustTerminate) {
|
||||
AddressSet body = new AddressSet();
|
||||
AddressSet instrStarts = new AddressSet();
|
||||
AddressSetView execSet = memory.getExecuteSet();
|
||||
|
||||
if (hasLowBitCodeModeInAddrValues(program)) {
|
||||
entryPoint = setTargeContextForDisassembly(procContext, entryPoint);
|
||||
|
@ -801,7 +788,6 @@ public class PseudoDisassembler {
|
|||
}
|
||||
}
|
||||
// if respecting execute flag on memory, test to make sure we did flow into non-execute memory
|
||||
AddressSetView execSet = getExecuteSet();
|
||||
if (respectExecuteFlag && !execSet.isEmpty() && !execSet.contains(flows[j])) {
|
||||
if (!flows[j].isExternalAddress()) {
|
||||
MemoryBlock block = memory.getBlock(flows[j]);
|
||||
|
@ -902,8 +888,8 @@ public class PseudoDisassembler {
|
|||
}
|
||||
|
||||
// check that body does not wander into non-executable memory
|
||||
AddressSetView execSet = getExecuteSet();
|
||||
if (respectExecuteFlag && !execSet.isEmpty() && !body.subtract(execSet).isEmpty()) {
|
||||
AddressSetView execSet = memory.getExecuteSet();
|
||||
if (respectExecuteFlag && !execSet.isEmpty() && !execSet.contains(body)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -914,8 +900,9 @@ public class PseudoDisassembler {
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean canHaveOffcutEntry = hasLowBitCodeModeInAddrValues(program);
|
||||
AddressSet strictlyBody = body.subtract(starts);
|
||||
if (hasLowBitCodeModeInAddrValues(program)) {
|
||||
if (canHaveOffcutEntry) {
|
||||
strictlyBody.deleteRange(entry, entry.add(1));
|
||||
}
|
||||
AddressIterator addrIter =
|
||||
|
|
|
@ -57,11 +57,13 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
private AddressSet addrSet = new AddressSet();
|
||||
private AddressSet initializedLoadedAddrSet = new AddressSet();
|
||||
private AddressSet allInitializedAddrSet = new AddressSet();
|
||||
private AddressSetView executeSet = null;
|
||||
|
||||
private MemoryBlock lastBlock;// the last accessed block
|
||||
private LiveMemoryHandler liveMemory;
|
||||
|
||||
|
||||
// lazy hashmap of block names to blocks, must be reloaded if blocks are removed or added
|
||||
private HashMap<String,MemoryBlock> nameBlockMap = new HashMap<String, MemoryBlock>();
|
||||
private HashMap<String, MemoryBlock> nameBlockMap = new HashMap<String, MemoryBlock>();
|
||||
private final static MemoryBlock NoBlock = new MemoryBlockStub(); // placeholder for no block, not given out
|
||||
|
||||
Lock lock;
|
||||
|
@ -187,6 +189,7 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
blocks = newBlocks;
|
||||
addrMap.memoryMapChanged(this);
|
||||
nameBlockMap = new HashMap<>();
|
||||
executeSet = null;
|
||||
}
|
||||
|
||||
public void setLanguage(Language newLanguage) {
|
||||
|
@ -248,7 +251,7 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
|
||||
@Override
|
||||
public AddressSetView getAllInitializedAddressSet() {
|
||||
return allInitializedAddrSet;
|
||||
return new AddressSetViewAdapter(allInitializedAddrSet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -259,7 +262,7 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
if (liveMemory != null) {
|
||||
return this;//all memory is initialized!
|
||||
}
|
||||
return initializedLoadedAddrSet;
|
||||
return new AddressSetViewAdapter(initializedLoadedAddrSet);
|
||||
}
|
||||
|
||||
void checkMemoryWrite(MemoryBlockDB block, Address start, long length)
|
||||
|
@ -393,9 +396,12 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
if (program != null) {
|
||||
program.setChanged(ChangeManager.DOCR_MEMORY_BLOCK_CHANGED, block, null);
|
||||
}
|
||||
|
||||
|
||||
// name could have changed
|
||||
nameBlockMap = new HashMap<>();
|
||||
|
||||
// don't regenerate now, do lazily later if needed
|
||||
executeSet = null;
|
||||
}
|
||||
|
||||
void fireBytesChanged(Address addr, int count) {
|
||||
|
@ -1972,15 +1978,34 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
|
|||
*/
|
||||
@Override
|
||||
public AddressSetView getExecuteSet() {
|
||||
AddressSet set = new AddressSet();
|
||||
for (MemoryBlock block : blocks) {
|
||||
if (block.isExecute()) {
|
||||
set.addRange(block.getStart(), block.getEnd());
|
||||
}
|
||||
AddressSetView set = executeSet;
|
||||
|
||||
if (set == null) {
|
||||
set = computeExecuteSet();
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return executable address set
|
||||
*/
|
||||
private AddressSetView computeExecuteSet() {
|
||||
lock.acquire();
|
||||
try {
|
||||
AddressSet set = new AddressSet();
|
||||
for (MemoryBlock block : blocks) {
|
||||
if (block.isExecute()) {
|
||||
set.addRange(block.getStart(), block.getEnd());
|
||||
}
|
||||
}
|
||||
executeSet = new AddressSetViewAdapter(set);
|
||||
return executeSet;
|
||||
}
|
||||
finally {
|
||||
lock.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void memoryChanged(Address addr, int size) {
|
||||
fireBytesChanged(addr, size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue