diff --git a/manticore/core/cpu/arm.py b/manticore/core/cpu/arm.py index 47925af..cea1030 100644 --- a/manticore/core/cpu/arm.py +++ b/manticore/core/cpu/arm.py @@ -85,7 +85,7 @@ class Armv7Operand(Operand): # PC in this case has to be set to the instruction after next. PC at this point # is already pointing to next instruction; we bump it one more. if self.reg in ('PC', 'R15'): - value += cpu.instruction.size + value += self.cpu.instruction.size if self.is_shifted(): shift = self.op.shift value, carry = self.cpu._shift(value, shift.type, shift.value, carry) @@ -355,11 +355,11 @@ class Armv7Cpu(Cpu): return state def __setstate__(self, state): - super(Armv7Cpu, self).__setstate__(state) self._last_flags = state['_last_flags'] self._at_symbolic_conditional = state['at_symbolic_conditional'] self._it_conditional = state['_it_conditional'] self._mode = state['_mode'] + super(Armv7Cpu, self).__setstate__(state) @property def mode(self): diff --git a/tests/binaries/basic_linux_armv7 b/tests/binaries/basic_linux_armv7 new file mode 100755 index 0000000..0621e94 Binary files /dev/null and b/tests/binaries/basic_linux_armv7 differ diff --git a/tests/test_armv7cpu.py b/tests/test_armv7cpu.py index aaab69a..43252e2 100644 --- a/tests/test_armv7cpu.py +++ b/tests/test_armv7cpu.py @@ -1654,3 +1654,15 @@ class Armv7CpuInstructions(unittest.TestCase): # the cpu lives in self.cpu e.setstate(self, CS_MODE_THUMB) self.assertEqual(self.cpu.mode, CS_MODE_THUMB) + + @itest_setregs("R1=0x00000008") # pc/r15 is set to 0x1004 in _setupCpu() + @itest("add pc, pc, r1") + def test_add_to_pc(self): + self.assertEqual(self.rf.read('R15'), 0x1014) + + # Make sure a cpu will survive a round trip through pickling/unpickling + def test_arm_save_restore_cpu(self): + import pickle + dumped_s = pickle.dumps(self.cpu) + self.cpu = pickle.loads(dumped_s) + diff --git a/tests/test_binaries.py b/tests/test_binaries.py index a6f73be..a4c8aea 100644 --- a/tests/test_binaries.py +++ b/tests/test_binaries.py @@ -141,6 +141,17 @@ class IntegrationTest(unittest.TestCase): self._simple_cli_run('705.sol') os.chdir(old_cwd) + def test_basic_arm(self): + dirname = os.path.dirname(__file__) + filename = os.path.abspath(os.path.join(dirname, 'binaries/basic_linux_armv7')) + workspace = '%s/workspace' % self.test_dir + output = subprocess.check_output(['python', '-m', 'manticore', '--workspace', workspace, filename]) + + with open(os.path.join(workspace, "test_00000000.stdout")) as f: + self.assertIn("Message", f.read()) + with open(os.path.join(workspace, "test_00000001.stdout")) as f: + self.assertIn("Message", f.read()) + if __name__ == '__main__': unittest.main()