From 6756eddee508c145ecff7cf0f302a463202acdfd Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Mon, 29 Sep 2014 23:32:14 +0800 Subject: [PATCH] ppc: alias instructions handled by printAliasInstrEx() miss CR* registers in detail mode. fixed --- arch/PowerPC/PPCInstPrinter.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/arch/PowerPC/PPCInstPrinter.c b/arch/PowerPC/PPCInstPrinter.c index 917ca95c..f9f56250 100644 --- a/arch/PowerPC/PPCInstPrinter.c +++ b/arch/PowerPC/PPCInstPrinter.c @@ -705,9 +705,18 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O) static void op_addImm(MCInst *MI, int v) { if (MI->csh->detail) { - MI->flat_insn->detail->arm.operands[MI->flat_insn->detail->arm.op_count].type = ARM_OP_IMM; - MI->flat_insn->detail->arm.operands[MI->flat_insn->detail->arm.op_count].imm = v; - MI->flat_insn->detail->arm.op_count++; + MI->flat_insn->detail->ppc.operands[MI->flat_insn->detail->ppc.op_count].type = PPC_OP_IMM; + MI->flat_insn->detail->ppc.operands[MI->flat_insn->detail->ppc.op_count].imm = v; + MI->flat_insn->detail->ppc.op_count++; + } +} + +static void op_addReg(MCInst *MI, unsigned int reg) +{ + if (MI->csh->detail) { + MI->flat_insn->detail->ppc.operands[MI->flat_insn->detail->ppc.op_count].type = PPC_OP_REG; + MI->flat_insn->detail->ppc.operands[MI->flat_insn->detail->ppc.op_count].reg = reg; + MI->flat_insn->detail->ppc.op_count++; } } @@ -824,30 +833,37 @@ static char *printAliasInstrEx(MCInst *MI, SStream *OS, void *info) switch(cr) { case PPC_CR1: SStream_concat0(&ss, " cr1"); + op_addReg(MI, PPC_REG_CR1); needComma = 1; break; case PPC_CR2: SStream_concat0(&ss, " cr2"); + op_addReg(MI, PPC_REG_CR2); needComma = 1; break; case PPC_CR3: SStream_concat0(&ss, " cr3"); + op_addReg(MI, PPC_REG_CR3); needComma = 1; break; case PPC_CR4: SStream_concat0(&ss, " cr4"); + op_addReg(MI, PPC_REG_CR4); needComma = 1; break; case PPC_CR5: SStream_concat0(&ss, " cr5"); + op_addReg(MI, PPC_REG_CR5); needComma = 1; break; case PPC_CR6: SStream_concat0(&ss, " cr6"); + op_addReg(MI, PPC_REG_CR6); needComma = 1; break; case PPC_CR7: SStream_concat0(&ss, " cr7"); + op_addReg(MI, PPC_REG_CR7); needComma = 1; break; default: