From d7735487f7d9634d9c34f282d7039933b2aeebf2 Mon Sep 17 00:00:00 2001 From: Andrew Dutcher Date: Fri, 15 Sep 2017 08:18:38 -0700 Subject: [PATCH] Use the qemu helpers to get/set the x86 eflags (#878) --- qemu/target-i386/unicorn.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/qemu/target-i386/unicorn.c b/qemu/target-i386/unicorn.c index 8fc8c410..71b4a9f9 100644 --- a/qemu/target-i386/unicorn.c +++ b/qemu/target-i386/unicorn.c @@ -77,6 +77,7 @@ void x86_reg_reset(struct uc_struct *uc) env->eip = 0; env->eflags = 0; env->eflags0 = 0; + env->cc_op = CC_OP_EFLAGS; env->fpstt = 0; /* top of stack index */ env->fpus = 0; @@ -348,7 +349,7 @@ int x86_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int coun *(int32_t *)value = X86_CPU(uc, mycpu)->env.dr[regid - UC_X86_REG_DR0]; break; case UC_X86_REG_EFLAGS: - *(int32_t *)value = X86_CPU(uc, mycpu)->env.eflags; + *(int32_t *)value = cpu_compute_eflags(&X86_CPU(uc, mycpu)->env); break; case UC_X86_REG_EAX: *(int32_t *)value = X86_CPU(uc, mycpu)->env.regs[R_EAX]; @@ -495,7 +496,7 @@ int x86_reg_read(struct uc_struct *uc, unsigned int *regs, void **vals, int coun *(int64_t *)value = X86_CPU(uc, mycpu)->env.dr[regid - UC_X86_REG_DR0]; break; case UC_X86_REG_EFLAGS: - *(int64_t *)value = X86_CPU(uc, mycpu)->env.eflags; + *(int64_t *)value = cpu_compute_eflags(&X86_CPU(uc, mycpu)->env); break; case UC_X86_REG_RAX: *(uint64_t *)value = X86_CPU(uc, mycpu)->env.regs[R_EAX]; @@ -888,7 +889,7 @@ int x86_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, i X86_CPU(uc, mycpu)->env.dr[regid - UC_X86_REG_DR0] = *(uint32_t *)value; break; case UC_X86_REG_EFLAGS: - X86_CPU(uc, mycpu)->env.eflags = *(uint32_t *)value; + cpu_load_eflags(&X86_CPU(uc, mycpu)->env, *(uint32_t *)value, -1); X86_CPU(uc, mycpu)->env.eflags0 = *(uint32_t *)value; break; case UC_X86_REG_EAX: @@ -1042,7 +1043,7 @@ int x86_reg_write(struct uc_struct *uc, unsigned int *regs, void *const *vals, i X86_CPU(uc, mycpu)->env.dr[regid - UC_X86_REG_DR0] = *(uint64_t *)value; break; case UC_X86_REG_EFLAGS: - X86_CPU(uc, mycpu)->env.eflags = *(uint64_t *)value; + cpu_load_eflags(&X86_CPU(uc, mycpu)->env, *(uint64_t *)value, -1); X86_CPU(uc, mycpu)->env.eflags0 = *(uint64_t *)value; break; case UC_X86_REG_RAX: