retdec icon indicating copy to clipboard operation
retdec copied to clipboard

[capstone2llvmir]: unhandled branch instruction format #1

Open mako2580 opened this issue 3 years ago • 2 comments

I have raw binary firmware file from PowerPC e200z4, which is 32bit PowerPC big endian CPU. And when I ran retdec-decompiler.py I got output

Running phase: Initialization ( 0.01s )
Running phase: LLVM ( 0.01s )
Running phase: Providers initialization ( 0.01s )
Running phase: Input binary to LLVM IR decoding ( 0.11s )
[capstone2llvmir]: unhandled branch instruction format #1
Error: Decompilation to LLVM IR failed

If it helps, then this is the list of bd* instructions I got from powerpc-linux-gnu-objdump -m powerpc -M e200z4 -D -b binary -EB firmware.bin on that file

bdnz+
bdnz-
bdnza-
bdnzf+
bdnzf-
bdnzfa+
bdnzfa-
bdnzfl+
bdnzfl-
bdnzfla+
bdnzfla-
bdnzt+
bdnzt-
bdnzta+
bdnzta-
bdnztl+
bdnztl-
bdnztla+
bdnztla-
bdza-
bdzf+
bdzf-
bdzfa+
bdzfa-
bdzfl+
bdzfl-
bdzfla+
bdzfla-
bdzt+
bdzt-
bdzta+
bdzta-
bdztl+
bdztl-
bdztla+
bdztla-

Lot of them could be just data interpreted as instructions. I cannot insert full file, but I can send some parts. Thanks in advance

mako2580 avatar Jun 27 '21 09:06 mako2580

Thanks, based on that error, I'm able to identify the line of code that causes this. But the error message, in this case, is still not that good - it would help to know the ASM address so that you could send us the instruction bytes on it. It would help a lot, because I used these kinds of errors when I was not sure how to implement an instruction and without a real example, it would be very hard to fix it.

I will add more into to the error message, let you know, and then you hopefully send me the bytes in there.

PeterMatula avatar Jul 12 '21 05:07 PeterMatula

It turned out I used wrong objdump. The correct one is powerpc-eabivle-objdump from NXP and branch instructions list is

e_b
e_bdnz
e_bdz
e_bdzl
e_beq
e_bge
e_bgt
e_bl
e_ble
e_blt
e_bne
se_b
se_bclri
se_bctr
se_bctrl
se_beq
se_bge
se_bgeni
se_bgt
se_bl
se_ble
se_blr
se_blrl
se_blt
se_bmaski
se_bne
se_bns
se_bseti
se_bso
se_btsti

EDIT: Here is programmer reference with instructions details: https://www.st.com/resource/en/reference_manual/cd00164807-programmers-reference-manual-for-book-e-processors-stmicroelectronics.pdf

mako2580 avatar Oct 15 '21 20:10 mako2580