uxmal / reko

Reko is a binary decompiler.

Home Page:https://uxmal.github.io/reko

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hitachi H8 postincrement missing

systemloc opened this issue · comments

Short sample code in Hitachi H8 arch demonstrating that the generated pseudocode is missing a postincrement in a mov op that acts as a loop iterator

Bugreport.125.2.zip

The reason why this is happening is because Reko pessimistically assumes that after a call to an unknown procedure, all registers are trashed. In your sample binary, the call in question is an indirect call, and Reko has no way of determining its target address. So it assumes the worst, that all registers are trashed.

In most binaries generated by a compiler adhere to an ABI; sometimes hand-written assembler programs will violate ABI's. Sometimes a platform doesn't have a well-defined ABI (looking at you, MS-DOS). It seems that this should a user option Assume calls respect platform ABI.

Commit b1a6a2d exhibits that increment statement. Other issues have materialized but one thing at a time!