uxmal / reko

Reko is a binary decompiler.
https://uxmal.github.io/reko
GNU General Public License v2.0
2.09k stars 250 forks source link

Several bugs found: incorrect function argument order, double type value, and strings #1337

Closed yangzao closed 2 months ago

yangzao commented 2 months ago

Hello, I'm using the CLI version of Reko 0.11.5.0 on Linux and found some issues regarding the decompiled code. The executables and their corresponding source code, decompiled code, and compiler options are included in Reko.zip.

[*] Program 1:

original code: image decompiled code: image

The argument order of set_var() is recovered incorrectly. The order of qwLoc18_141 (corresponds to l_l) and dwLoc0C_144 (corresponds to i_l) gets reversed.

[*] Program 2:

issue 1: original code: image decompiled code: image

(double)(i_l) (i_l equals to 1) is recovered as 1e-45F

issue 2: decompiled code: image

The decompiled multiply is appended with an extra s.

[*] Program 3:

Reko does not generate any decompiled code in each function of this program.

[*] Program 4: original code: image image decompiled code: image image

str is a char * in the original code. But in decompiled code, it is defined as a word64 (I assume it's int64_t). And printf tries to access it with dereferencing.

[*] Program 5:

When the original code is compiled by GCC, Microsoft Visual C++ compiler (MSVC), Tiny C compiler, and Clang targeted for Mach-O, the string literals are not recovered in the decompiled code.

uxmal commented 2 months ago

@yangzao: thanks for reporting these errors. I've opened separate issues for each of them to make it easier to track and discuss.

uxmal commented 2 months ago

This has been fixed in commit 02e40b889c4a2f41b770857cdf094497f0d1b985.