mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Merge remote-tracking branch 'origin/GP-1497_ghidra1_ExternalSafeguard' into Ghidra_10.1
This commit is contained in:
commit
471e915673
2 changed files with 23 additions and 3 deletions
|
@ -29,6 +29,7 @@ import ghidra.program.model.address.AddressSetView;
|
||||||
import ghidra.program.model.data.*;
|
import ghidra.program.model.data.*;
|
||||||
import ghidra.program.model.lang.PrototypeModel;
|
import ghidra.program.model.lang.PrototypeModel;
|
||||||
import ghidra.program.model.listing.*;
|
import ghidra.program.model.listing.*;
|
||||||
|
import ghidra.program.model.mem.MemoryBlock;
|
||||||
import ghidra.program.model.symbol.*;
|
import ghidra.program.model.symbol.*;
|
||||||
import ghidra.program.model.util.CodeUnitInsertionException;
|
import ghidra.program.model.util.CodeUnitInsertionException;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
|
@ -346,6 +347,9 @@ public class DemangledFunction extends DemangledObject {
|
||||||
* This method assumes preconditions test has been run.
|
* This method assumes preconditions test has been run.
|
||||||
*/
|
*/
|
||||||
private boolean shouldDisassemble(Program program, Address address, DemanglerOptions options) {
|
private boolean shouldDisassemble(Program program, Address address, DemanglerOptions options) {
|
||||||
|
if (!address.isMemoryAddress() || MemoryBlock.isExternalBlockAddress(address, program)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
CodeUnit codeUnit = program.getListing().getCodeUnitAt(address);
|
CodeUnit codeUnit = program.getListing().getCodeUnitAt(address);
|
||||||
return (codeUnit instanceof Data); // preconditions check guarantees data is undefined data.
|
return (codeUnit instanceof Data); // preconditions check guarantees data is undefined data.
|
||||||
}
|
}
|
||||||
|
@ -383,9 +387,7 @@ public class DemangledFunction extends DemangledObject {
|
||||||
// sure that the context is correctly set before that happens. Also, be sure to apply
|
// sure that the context is correctly set before that happens. Also, be sure to apply
|
||||||
// the function to the correct address.
|
// the function to the correct address.
|
||||||
|
|
||||||
//TODO revisit this in terms of external block addresses. Also shoul this check
|
if (address.isMemoryAddress()) {
|
||||||
// be moved into the PsuedoDisassembler???
|
|
||||||
if (!address.isExternalAddress()) {
|
|
||||||
address = PseudoDisassembler.setTargeContextForDisassembly(program, address);
|
address = PseudoDisassembler.setTargeContextForDisassembly(program, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import ghidra.program.model.listing.*;
|
||||||
import ghidra.program.model.mem.*;
|
import ghidra.program.model.mem.*;
|
||||||
import ghidra.program.model.pcode.PcodeOp;
|
import ghidra.program.model.pcode.PcodeOp;
|
||||||
import ghidra.program.model.symbol.*;
|
import ghidra.program.model.symbol.*;
|
||||||
|
import ghidra.util.Msg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PseudoDisassembler.java
|
* PseudoDisassembler.java
|
||||||
|
@ -387,6 +388,7 @@ public class PseudoDisassembler {
|
||||||
* The process function can control what flows are followed and when to stop.
|
* The process function can control what flows are followed and when to stop.
|
||||||
*
|
*
|
||||||
* @param entryPoint start address
|
* @param entryPoint start address
|
||||||
|
* @param maxInstr maximum number of instructions to evaluate
|
||||||
* @param processor processor to use
|
* @param processor processor to use
|
||||||
* @return the address set of instructions that were followed
|
* @return the address set of instructions that were followed
|
||||||
*/
|
*/
|
||||||
|
@ -402,6 +404,8 @@ public class PseudoDisassembler {
|
||||||
* The process function can control what flows are followed and when to stop.
|
* The process function can control what flows are followed and when to stop.
|
||||||
*
|
*
|
||||||
* @param entryPoint start address
|
* @param entryPoint start address
|
||||||
|
* @param procContext initial processor context for disassembly
|
||||||
|
* @param maxInstr maximum number of instructions to evaluate
|
||||||
* @param processor processor to use
|
* @param processor processor to use
|
||||||
* @return the address set of instructions that were followed
|
* @return the address set of instructions that were followed
|
||||||
*/
|
*/
|
||||||
|
@ -579,6 +583,10 @@ public class PseudoDisassembler {
|
||||||
|
|
||||||
public boolean checkValidSubroutine(Address entryPoint, PseudoDisassemblerContext procContext,
|
public boolean checkValidSubroutine(Address entryPoint, PseudoDisassemblerContext procContext,
|
||||||
boolean allowExistingInstructions, boolean mustTerminate) {
|
boolean allowExistingInstructions, boolean mustTerminate) {
|
||||||
|
|
||||||
|
if (!entryPoint.isMemoryAddress()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
AddressSet body = new AddressSet();
|
AddressSet body = new AddressSet();
|
||||||
AddressSet instrStarts = new AddressSet();
|
AddressSet instrStarts = new AddressSet();
|
||||||
AddressSetView execSet = memory.getExecuteSet();
|
AddressSetView execSet = memory.getExecuteSet();
|
||||||
|
@ -987,6 +995,11 @@ public class PseudoDisassembler {
|
||||||
* @return the correct address to disassemble at if it needs to be aligned
|
* @return the correct address to disassemble at if it needs to be aligned
|
||||||
*/
|
*/
|
||||||
public static Address setTargeContextForDisassembly(Program program, Address addr) {
|
public static Address setTargeContextForDisassembly(Program program, Address addr) {
|
||||||
|
if (!addr.isMemoryAddress()) {
|
||||||
|
Msg.error(PseudoDisassembler.class,
|
||||||
|
"Invalid attempt to adjust disassembler context at " + addr.toString(true));
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
Register lowBitCodeMode = program.getRegister(LOW_BIT_CODE_MODE_REGISTER_NAME);
|
Register lowBitCodeMode = program.getRegister(LOW_BIT_CODE_MODE_REGISTER_NAME);
|
||||||
if (lowBitCodeMode == null) {
|
if (lowBitCodeMode == null) {
|
||||||
return addr;
|
return addr;
|
||||||
|
@ -1016,6 +1029,11 @@ public class PseudoDisassembler {
|
||||||
|
|
||||||
public Address setTargeContextForDisassembly(PseudoDisassemblerContext procContext,
|
public Address setTargeContextForDisassembly(PseudoDisassemblerContext procContext,
|
||||||
Address addr) {
|
Address addr) {
|
||||||
|
if (!addr.isMemoryAddress()) {
|
||||||
|
Msg.error(this,
|
||||||
|
"Invalid attempt to adjust disassembler context at " + addr.toString(true));
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
Register lowBitCodeMode = program.getRegister(LOW_BIT_CODE_MODE_REGISTER_NAME);
|
Register lowBitCodeMode = program.getRegister(LOW_BIT_CODE_MODE_REGISTER_NAME);
|
||||||
if (lowBitCodeMode == null) {
|
if (lowBitCodeMode == null) {
|
||||||
return addr;
|
return addr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue