mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-31 09:20:06 +08:00
GT-2880 set thumb on mem; fix exception handling under thumb
This commit is contained in:
@@ -473,14 +473,21 @@ public class PeLoader extends AbstractPeDebugLoader {
|
|||||||
private void setProcessorContext(FileHeader fileHeader, Program program, TaskMonitor monitor,
|
private void setProcessorContext(FileHeader fileHeader, Program program, TaskMonitor monitor,
|
||||||
MessageLog log) {
|
MessageLog log) {
|
||||||
|
|
||||||
String machineName = fileHeader.getMachineName();
|
try {
|
||||||
if ("450".equals(machineName) || "452".equals(machineName)) {
|
String machineName = fileHeader.getMachineName();
|
||||||
Register tmodeReg = program.getProgramContext().getRegister("TMode");
|
if ("450".equals(machineName) || "452".equals(machineName)) {
|
||||||
if (tmodeReg == null) {
|
Register tmodeReg = program.getProgramContext().getRegister("TMode");
|
||||||
return;
|
if (tmodeReg == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
RegisterValue thumbMode = new RegisterValue(tmodeReg, BigInteger.ONE);
|
||||||
|
AddressSpace space = program.getAddressFactory().getDefaultAddressSpace();
|
||||||
|
program.getProgramContext().setRegisterValue(space.getMinAddress(),
|
||||||
|
space.getMaxAddress(), thumbMode);
|
||||||
}
|
}
|
||||||
RegisterValue thumbMode = new RegisterValue(tmodeReg, BigInteger.ONE);
|
}
|
||||||
program.getProgramContext().setDefaultDisassemblyContext(thumbMode);
|
catch (ContextChangeException e) {
|
||||||
|
throw new AssertException("instructions should not exist");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
@@ -17,6 +17,7 @@ package ghidra.app.cmd.data;
|
|||||||
|
|
||||||
import ghidra.app.cmd.disassemble.DisassembleCommand;
|
import ghidra.app.cmd.disassemble.DisassembleCommand;
|
||||||
import ghidra.app.cmd.function.CreateFunctionCmd;
|
import ghidra.app.cmd.function.CreateFunctionCmd;
|
||||||
|
import ghidra.app.util.PseudoDisassembler;
|
||||||
import ghidra.app.util.datatype.microsoft.DataApplyOptions;
|
import ghidra.app.util.datatype.microsoft.DataApplyOptions;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.address.AddressOutOfBoundsException;
|
import ghidra.program.model.address.AddressOutOfBoundsException;
|
||||||
@@ -323,6 +324,8 @@ public class EHDataTypeUtilities {
|
|||||||
public static boolean createFunctionIfNeeded(Program program, Address functionAddress) {
|
public static boolean createFunctionIfNeeded(Program program, Address functionAddress) {
|
||||||
// If there isn't an instruction at the function address yet, then disassemble there.
|
// If there isn't an instruction at the function address yet, then disassemble there.
|
||||||
Listing listing = program.getListing();
|
Listing listing = program.getListing();
|
||||||
|
functionAddress =
|
||||||
|
PseudoDisassembler.getNormalizedDisassemblyAddress(program, functionAddress);
|
||||||
Instruction inst = listing.getInstructionAt(functionAddress);
|
Instruction inst = listing.getInstructionAt(functionAddress);
|
||||||
if (inst == null) {
|
if (inst == null) {
|
||||||
DisassembleCommand cmd = new DisassembleCommand(functionAddress, null, true);
|
DisassembleCommand cmd = new DisassembleCommand(functionAddress, null, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user