diff --git a/Ghidra/Extensions/SleighDevTools/pcodetest/pcode_defs.py b/Ghidra/Extensions/SleighDevTools/pcodetest/pcode_defs.py index c8cf6cc787..e061547313 100644 --- a/Ghidra/Extensions/SleighDevTools/pcodetest/pcode_defs.py +++ b/Ghidra/Extensions/SleighDevTools/pcodetest/pcode_defs.py @@ -47,6 +47,16 @@ PCodeTest({ 'language_id': 'ARM:LE:32:v7', }) +PCodeTest({ + 'name': 'ARMv5', + 'build_all': 1, + 'build_exe': 1, + 'qemu_command': 'qemu-arm', + 'toolchain': 'ARM/arm-eabi', + 'language_id': 'ARM:LE:32:v5', + 'ccflags': '-march=armv5 -L %(toolchain_dir)s/lib/gcc/arm-eabi/%(gcc_version)s -lgcc', +}) + PCodeTest({ 'name': 'ARM7', 'toolchain': 'ARM/arm-eabi', diff --git a/Ghidra/Processors/ARM/src/main/java/ghidra/program/emulation/ARMEmulateInstructionStateModifier.java b/Ghidra/Processors/ARM/src/main/java/ghidra/program/emulation/ARMEmulateInstructionStateModifier.java index 6ae2e7d387..f5ce6859d7 100644 --- a/Ghidra/Processors/ARM/src/main/java/ghidra/program/emulation/ARMEmulateInstructionStateModifier.java +++ b/Ghidra/Processors/ARM/src/main/java/ghidra/program/emulation/ARMEmulateInstructionStateModifier.java @@ -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 diff --git a/Ghidra/Processors/ARM/src/test.processors/java/ghidra/test/processors/ARMv5_O0_EmulatorTest.java b/Ghidra/Processors/ARM/src/test.processors/java/ghidra/test/processors/ARMv5_O0_EmulatorTest.java new file mode 100644 index 0000000000..f5d11b8af4 --- /dev/null +++ b/Ghidra/Processors/ARM/src/test.processors/java/ghidra/test/processors/ARMv5_O0_EmulatorTest.java @@ -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); + } +} diff --git a/Ghidra/Processors/ARM/src/test.processors/java/ghidra/test/processors/ARMv5_O3_EmulatorTest.java b/Ghidra/Processors/ARM/src/test.processors/java/ghidra/test/processors/ARMv5_O3_EmulatorTest.java new file mode 100644 index 0000000000..a4743a0a59 --- /dev/null +++ b/Ghidra/Processors/ARM/src/test.processors/java/ghidra/test/processors/ARMv5_O3_EmulatorTest.java @@ -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); + } +}