mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-22 01:52:01 +08:00
GP-1063 corrected ARMv5 emulation issue
This commit is contained in:
+13
-8
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package ghidra.program.emulation;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import ghidra.pcode.emulate.Emulate;
|
||||
import ghidra.pcode.emulate.EmulateInstructionStateModifier;
|
||||
import ghidra.pcode.emulate.callother.CountLeadingZerosOpBehavior;
|
||||
@@ -24,8 +26,6 @@ import ghidra.program.model.lang.Register;
|
||||
import ghidra.program.model.lang.RegisterValue;
|
||||
import ghidra.program.model.pcode.PcodeOp;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class ARMEmulateInstructionStateModifier extends EmulateInstructionStateModifier {
|
||||
|
||||
private Register TModeReg;
|
||||
@@ -37,12 +37,14 @@ public class ARMEmulateInstructionStateModifier extends EmulateInstructionStateM
|
||||
super(emu);
|
||||
TModeReg = language.getRegister("TMode");
|
||||
TBreg = language.getRegister("ISAModeSwitch");
|
||||
if (TModeReg != null && TBreg == null) {
|
||||
throw new RuntimeException("Expected language " + language.getLanguageID() +
|
||||
" to have TB register defined");
|
||||
if (TModeReg != null) {
|
||||
if (TBreg == null) {
|
||||
throw new RuntimeException("Expected language " + language.getLanguageID() +
|
||||
" to have TB register defined");
|
||||
}
|
||||
tMode = new RegisterValue(TModeReg, BigInteger.ONE);
|
||||
aMode = new RegisterValue(TModeReg, BigInteger.ZERO);
|
||||
}
|
||||
tMode = new RegisterValue(TModeReg, BigInteger.ONE);
|
||||
aMode = new RegisterValue(TModeReg, BigInteger.ZERO);
|
||||
|
||||
registerPcodeOpBehavior("count_leading_zeroes", new CountLeadingZerosOpBehavior());
|
||||
|
||||
@@ -115,6 +117,9 @@ public class ARMEmulateInstructionStateModifier extends EmulateInstructionStateM
|
||||
*/
|
||||
@Override
|
||||
public void initialExecuteCallback(Emulate emulate, Address current_address, RegisterValue contextRegisterValue) throws LowlevelError {
|
||||
if (TModeReg == null) {
|
||||
return; // Thumb mode not supported
|
||||
}
|
||||
BigInteger tModeValue = BigInteger.ZERO;
|
||||
if (contextRegisterValue != null) {
|
||||
tModeValue = contextRegisterValue.getRegisterValue(TModeReg).getUnsignedValueIgnoreMask();
|
||||
@@ -136,7 +141,7 @@ public class ARMEmulateInstructionStateModifier extends EmulateInstructionStateM
|
||||
PcodeOp[] lastExecutePcode, int lastPcodeIndex, Address currentAddress)
|
||||
throws LowlevelError {
|
||||
if (TModeReg == null) {
|
||||
return;
|
||||
return; // Thumb mode not supported
|
||||
}
|
||||
if (lastPcodeIndex < 0) {
|
||||
// ignore fall-through condition
|
||||
|
||||
Reference in New Issue
Block a user