ppc: fix target address of bdnz. issue #1468

This commit is contained in:
Nguyen Anh Quynh 2019-05-11 10:18:36 +08:00
parent b6924f4b86
commit 7ce9c792b1
2 changed files with 17 additions and 0 deletions

View File

@ -384,6 +384,11 @@ static char *printAliasBcc(MCInst *MI, SStream *OS, void *info)
return tmp;
}
static bool isBOCTRBranch(unsigned int op)
{
return ((op >= PPC_BDNZ) && (op <= PPC_BDZp));
}
void PPC_printInst(MCInst *MI, SStream *O, void *Info)
{
char *mnem;
@ -581,6 +586,14 @@ void PPC_printInst(MCInst *MI, SStream *O, void *Info)
MCOperand_setImm(MCInst_getOperand(MI, 2), bd);
}
if (isBOCTRBranch(MCInst_getOpcode(MI))) {
if (MCOperand_isImm(MCInst_getOperand(MI,0))) {
int64_t bd = MCOperand_getImm(MCInst_getOperand(MI, 0));
bd = SignExtend64(bd, 14);
MCOperand_setImm(MCInst_getOperand(MI, 0), bd);
}
}
mnem = printAliasBcc(MI, O, Info);
if (!mnem)
mnem = printAliasInstr(MI, O, Info);

View File

@ -1,3 +1,7 @@
!# issue 1468 PPC bdnz
!# CS_ARCH_PPC, CS_MODE_64 | CS_MODE_BIG_ENDIAN, None
0x101086c: 0x42,0x00,0xff,0xf8 == bdnz 0x1010864
!# issue PPC bdnzt
!# CS_ARCH_PPC, CS_MODE_64 | CS_MODE_BIG_ENDIAN, None
0x1000: 0x41,0x00,0xff,0xac == bdnzt lt, 0xfac