-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Description
According to PowerPC specification, bdzla (PPC_INS_BDZLA) is a bcla variant -- absolute branch. But it looks like Capstone (next branch) takes it as a relative branch -- PPC_OP_IMM operand value is address + imm instead of just imm.
The output of my Capstone dumper utility program (dumps everything capstone knows about an instruction) should be pretty self-explanatory:
$ capstone-dumper -a ppc -m 32 -e big -b 0x1000 -t "bdzla 0x1234"
Keystone input : bdzla 0x1234
Keystone output: 42 40 12 37
Capstone version: 1024 (major: 4, minor: 0)
#0
General info:
id : 34 (bdzla)
addr : 1000
size : 4
bytes : 42 40 12 37
mnem : bdzla
op str : 0x2234
Detail info:
R regs : 2
10 (ctr)
205 (rm)
W regs : 1
10 (ctr)
groups : 0
Architecture-dependent info:
branch code : PPC_BC_INVALID
branch hint : PPC_BH_INVALID
update cr0 : false
op count : 1
type : PPC_OP_IMM
imm : 0x2234
Instruction is at 0x1000 and ASM operand is 0x1234, but Capstone operand is 0x2234. I think it should be 0x1234.
The same thing for bdnzla (PPC_INS_BDNZLA) seems to be ok (operand is 0x1234):
$ capstone-dumper -a ppc -m 32 -e big -b 0x1000 -t "bdnzla 0x1234"
Keystone input : bdnzla 0x1234
Keystone output: 42 00 12 37
Capstone version: 1024 (major: 4, minor: 0)
#0
General info:
id : 28 (bdnzla)
addr : 1000
size : 4
bytes : 42 00 12 37
mnem : bdnzla
op str : 0x1234
Detail info:
R regs : 2
10 (ctr)
205 (rm)
W regs : 1
10 (ctr)
groups : 0
Architecture-dependent info:
branch code : PPC_BC_INVALID
branch hint : PPC_BH_INVALID
update cr0 : false
op count : 1
type : PPC_OP_IMM
imm : 0x1234