Closed
Description
In some cases, branch codes are not properly set by Capstone (next
branch). For example, instructions bdnzt lt, 0x4bc
and bdnzt eq, 0x4bc
are undistinguishable from each other -- branch code is PPC_BC_INVALID
, there is no PPC_OP_CRX
operand.
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 0x10000510 -t "bdnzt lt, 0x4bc"
Keystone input : bdnzt lt, 0x4bc
Keystone output: 41 00 ff ac
Capstone version: 1024 (major: 4, minor: 0)
#0
General info:
id : 1062 (bdnzt)
addr : 10000510
size : 4
bytes : 41 00 ff ac
mnem : bdnzt
op str : lt, 0x100004bc
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 : 100004bc
$ capstone-dumper -a ppc -m 32 -e big -b 0x10000510 -t "bdnzt eq, 0x4bc"
Keystone input : bdnzt eq, 0x4bc
Keystone output: 41 02 ff ac
Capstone version: 1024 (major: 4, minor: 0)
#0
General info:
id : 1062 (bdnzt)
addr : 10000510
size : 4
bytes : 41 02 ff ac
mnem : bdnzt
op str : eq, 0x100004bc
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 : 100004bc
This seems to happen when branches work with flags in CR0
. When I use some other condition register, another operand of PPC_OP_CRX
type is present and it is ok:
$ capstone-dumper -a ppc -m 32 -e big -b 0x10000510 -t "bdnzt 4*cr4+lt, 0x4bc"
Keystone input : bdnzt 4*cr4+lt, 0x4bc
Keystone output: 41 10 ff ac
Capstone version: 1024 (major: 4, minor: 0)
#0
General info:
id : 1062 (bdnzt)
addr : 10000510
size : 4
bytes : 41 10 ff ac
mnem : bdnzt
op str : 4*cr4+lt, 0x100004bc
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_PLUS
update cr0 : false
op count : 2
type : PPC_OP_CRX
scale : 4
reg : 6 (cr4)
br cnd : PPC_BC_LT
type : PPC_OP_IMM
imm : 100004bc