GT-3223_emteere cache exec set only if needed. stop gap until memory

manager caches this
This commit is contained in:
emteere 2019-10-18 00:34:14 -04:00
parent dce20f28d5
commit 41efe77e53

View file

@ -19,15 +19,39 @@ import java.math.BigInteger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import ghidra.program.model.address.*; import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressIterator;
import ghidra.program.model.address.AddressOutOfBoundsException;
import ghidra.program.model.address.AddressOverflowException;
import ghidra.program.model.address.AddressSet;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataType;
import ghidra.program.model.data.PointerDataType; import ghidra.program.model.data.PointerDataType;
import ghidra.program.model.lang.*; import ghidra.program.model.lang.InstructionPrototype;
import ghidra.program.model.listing.*; import ghidra.program.model.lang.InsufficientBytesException;
import ghidra.program.model.mem.*; import ghidra.program.model.lang.Language;
import ghidra.program.model.lang.Register;
import ghidra.program.model.lang.RegisterValue;
import ghidra.program.model.lang.UnknownContextException;
import ghidra.program.model.lang.UnknownInstructionException;
import ghidra.program.model.listing.ContextChangeException;
import ghidra.program.model.listing.Data;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Instruction;
import ghidra.program.model.listing.Program;
import ghidra.program.model.listing.ProgramContext;
import ghidra.program.model.mem.ByteMemBufferImpl;
import ghidra.program.model.mem.DumbMemBufferImpl;
import ghidra.program.model.mem.MemBuffer;
import ghidra.program.model.mem.Memory;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.model.pcode.PcodeOp; import ghidra.program.model.pcode.PcodeOp;
import ghidra.program.model.symbol.*; import ghidra.program.model.symbol.FlowType;
import ghidra.program.util.ProgramContextImpl; import ghidra.program.model.symbol.RefType;
import ghidra.program.model.symbol.Reference;
import ghidra.program.model.symbol.Symbol;
import ghidra.program.model.symbol.SymbolType;
/** /**
* PseudoDisassembler.java * PseudoDisassembler.java
@ -81,8 +105,6 @@ public class PseudoDisassembler {
memory = program.getMemory(); memory = program.getMemory();
executeSet = memory.getExecuteSet();
this.language = program.getLanguage(); this.language = program.getLanguage();
pointerSize = program.getDefaultPointerSize(); pointerSize = program.getDefaultPointerSize();
@ -90,6 +112,18 @@ public class PseudoDisassembler {
this.programContext = program.getProgramContext(); 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 * Set the maximum number of instructions to check
* *
@ -767,8 +801,8 @@ public class PseudoDisassembler {
} }
} }
// if respecting execute flag on memory, test to make sure we did flow into non-execute memory // if respecting execute flag on memory, test to make sure we did flow into non-execute memory
if (respectExecuteFlag && !executeSet.isEmpty() && AddressSetView execSet = getExecuteSet();
!executeSet.contains(flows[j])) { if (respectExecuteFlag && !execSet.isEmpty() && !execSet.contains(flows[j])) {
if (!flows[j].isExternalAddress()) { if (!flows[j].isExternalAddress()) {
MemoryBlock block = memory.getBlock(flows[j]); MemoryBlock block = memory.getBlock(flows[j]);
// flowing into non-executable, but readable memory is bad // flowing into non-executable, but readable memory is bad
@ -868,7 +902,8 @@ public class PseudoDisassembler {
} }
// check that body does not wander into non-executable memory // check that body does not wander into non-executable memory
if (respectExecuteFlag && !executeSet.isEmpty() && !body.subtract(executeSet).isEmpty()) { AddressSetView execSet = getExecuteSet();
if (respectExecuteFlag && !execSet.isEmpty() && !body.subtract(execSet).isEmpty()) {
return false; return false;
} }