Merge remote-tracking branch

'origin/GP-1078_ghidorahrex_ARMEmulation_no_thumb'

Conflicts:
	Ghidra/Processors/ARM/src/main/java/ghidra/program/emulation/ARMEmulateInstructionStateModifier.java
This commit is contained in:
ghidra1
2021-07-06 16:36:01 -04:00
4 changed files with 95 additions and 4 deletions

View File

@@ -36,11 +36,11 @@ public class ARMEmulateInstructionStateModifier extends EmulateInstructionStateM
public ARMEmulateInstructionStateModifier(Emulate emu) {
super(emu);
TModeReg = language.getRegister("TMode");
TBreg = language.getRegister("ISAModeSwitch");
TBreg = language.getRegister("ISAModeSwitch"); // generic register which mirrors TB register value
if (TModeReg != null) {
if (TBreg == null) {
throw new RuntimeException("Expected language " + language.getLanguageID() +
" to have TB register defined");
" to have ISAModeSwitch register defined");
}
tMode = new RegisterValue(TModeReg, BigInteger.ONE);
aMode = new RegisterValue(TModeReg, BigInteger.ZERO);
@@ -122,14 +122,15 @@ public class ARMEmulateInstructionStateModifier extends EmulateInstructionStateM
}
BigInteger tModeValue = BigInteger.ZERO;
if (contextRegisterValue != null) {
tModeValue = contextRegisterValue.getRegisterValue(TModeReg).getUnsignedValueIgnoreMask();
tModeValue =
contextRegisterValue.getRegisterValue(TModeReg).getUnsignedValueIgnoreMask();
}
if (!BigInteger.ZERO.equals(tModeValue)) {
tModeValue = BigInteger.ONE;
}
emu.getMemoryState().setValue(TBreg, tModeValue);
}
/**
* Handle odd addresses which may occur when jumping/returning indirectly
* to Thumb mode. It is assumed that language will properly handle

View File

@@ -0,0 +1,40 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.test.processors;
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
import junit.framework.Test;
public class ARMv5_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {
private static final String LANGUAGE_ID = "ARM:LE:32:v5";
private static final String COMPILER_SPEC_ID = "default";
private static final String[] REG_DUMP_SET = new String[] {};
public ARMv5_O0_EmulatorTest(String name) throws Exception {
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
}
@Override
protected String getProcessorDesignator() {
return "ARMv5_GCC_O0";
}
public static Test suite() {
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(ARM_O0_EmulatorTest.class);
}
}

View File

@@ -0,0 +1,40 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.test.processors;
import ghidra.test.processors.support.ProcessorEmulatorTestAdapter;
import junit.framework.Test;
public class ARMv5_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {
private static final String LANGUAGE_ID = "ARM:LE:32:v5";
private static final String COMPILER_SPEC_ID = "default";
private static final String[] REG_DUMP_SET = new String[] {};
public ARMv5_O3_EmulatorTest(String name) throws Exception {
super(name, LANGUAGE_ID, COMPILER_SPEC_ID, REG_DUMP_SET);
}
@Override
protected String getProcessorDesignator() {
return "ARMv5_GCC_O3";
}
public static Test suite() {
return ProcessorEmulatorTestAdapter.buildEmulatorTestSuite(ARM_O3_EmulatorTest.class);
}
}