From c70442edc6de889dbf17c6e6385aa4fcecea2433 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Sun, 1 Jun 2014 11:35:34 +0700 Subject: [PATCH] arm: shift info associates with the right op in LDR instruction. bug reported by Daniel Colascione --- arch/ARM/ARMInstPrinter.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/ARM/ARMInstPrinter.c b/arch/ARM/ARMInstPrinter.c index 7f61a98c..d70bb1bb 100644 --- a/arch/ARM/ARMInstPrinter.c +++ b/arch/ARM/ARMInstPrinter.c @@ -177,8 +177,12 @@ static void printRegImmShift(MCInst *MI, SStream *O, ARM_AM_ShiftOpc ShOpc, //assert (!(ShOpc == ARM_AM_ror && !ShImm) && "Cannot have ror #0"); SStream_concat(O, ARM_AM_getShiftOpcStr(ShOpc)); - if (MI->csh->detail) - MI->flat_insn.arm.operands[MI->flat_insn.arm.op_count - 1].shift.type = (arm_shifter)ShOpc; + if (MI->csh->detail) { + if (MI->csh->doing_mem) + MI->flat_insn.arm.operands[MI->flat_insn.arm.op_count].shift.type = (arm_shifter)ShOpc; + else + MI->flat_insn.arm.operands[MI->flat_insn.arm.op_count - 1].shift.type = (arm_shifter)ShOpc; + } if (ShOpc != ARM_AM_rrx) { SStream_concat(O, " "); @@ -187,8 +191,12 @@ static void printRegImmShift(MCInst *MI, SStream *O, ARM_AM_ShiftOpc ShOpc, SStream_concat(O, "#%u", translateShiftImm(ShImm)); if (_UseMarkup) SStream_concat(O, ">"); - if (MI->csh->detail) - MI->flat_insn.arm.operands[MI->flat_insn.arm.op_count - 1].shift.value = translateShiftImm(ShImm); + if (MI->csh->detail) { + if (MI->csh->doing_mem) + MI->flat_insn.arm.operands[MI->flat_insn.arm.op_count].shift.value = translateShiftImm(ShImm); + else + MI->flat_insn.arm.operands[MI->flat_insn.arm.op_count - 1].shift.value = translateShiftImm(ShImm); + } } }