From 3a1c13fda967869befa4593f910467e20d9a70ac Mon Sep 17 00:00:00 2001 From: Eloi Sanfelix Date: Fri, 17 Jun 2016 13:46:34 +0200 Subject: [PATCH] Set thumb mode based on PC value in ARM. Mask off last bit of PC. --- qemu/target-arm/unicorn_arm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qemu/target-arm/unicorn_arm.c b/qemu/target-arm/unicorn_arm.c index 5dcd37c1..e1e933e1 100644 --- a/qemu/target-arm/unicorn_arm.c +++ b/qemu/target-arm/unicorn_arm.c @@ -106,8 +106,9 @@ int arm_reg_write(struct uc_struct *uc, unsigned int *regs, void* const* vals, i break; //case UC_ARM_REG_PC: case UC_ARM_REG_R15: - ARM_CPU(uc, mycpu)->env.pc = *(uint32_t *)value; - ARM_CPU(uc, mycpu)->env.regs[15] = *(uint32_t *)value; + ARM_CPU(uc, mycpu)->env.pc = (*(uint32_t *)value & ~1); + ARM_CPU(uc, mycpu)->env.thumb = (*(uint32_t *)value & 1); + ARM_CPU(uc, mycpu)->env.regs[15] = (*(uint32_t *)value & ~1); // force to quit execution and flush TB uc->quit_request = true; uc_emu_stop(uc);