From 2b53b20272fa78b1da6c73db9f19f03c1bbdf8c6 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Tue, 24 Dec 2013 09:09:20 +0800 Subject: [PATCH] x86: patch in acc registers for xchg. bug reported by felixwilhelm --- arch/X86/X86IntelInstPrinter.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/X86/X86IntelInstPrinter.c b/arch/X86/X86IntelInstPrinter.c index c44451b3..9849e460 100644 --- a/arch/X86/X86IntelInstPrinter.c +++ b/arch/X86/X86IntelInstPrinter.c @@ -237,13 +237,15 @@ void X86_Intel_printInst(MCInst *MI, SStream *O, void *Info) char tmp[64]; if (get_first_op(O->buffer, tmp)) { int post; - char *acc_regs[] = {"al", "ax", "eax", "rax", NULL}; + char *acc_regs[] = { "al", "ax", "eax", "rax", NULL }; + int acc_regs_id[] = { X86_REG_AL, X86_REG_AX, X86_REG_EAX, X86_REG_RAX }; if (tmp[0] != 0 && ((post = str_in_list(acc_regs, tmp)) != -1)) { // set operand size following register size MI->pub_insn.x86.op_size = 1 << post; // tmp is a register - if (MI->pub_insn.x86.operands[0].type != X86_OP_INVALID && - MI->pub_insn.x86.operands[0].type != X86_OP_REG) { + if ((MI->pub_insn.x86.operands[0].type != X86_OP_INVALID) && + ((MI->pub_insn.x86.operands[0].type != X86_OP_REG) || + (MI->pub_insn.x86.operands[0].reg != acc_regs_id[post]))) { int i; for (i = MI->pub_insn.x86.op_count; i > 0; i--) { memcpy(&(MI->pub_insn.x86.operands[i]), &(MI->pub_insn.x86.operands[i - 1]),