4 ms·
IMHO the "holy grail" of decompilation is to decompile the compiler, compile the decompiled decompiler, and get back a functioning decompiler that can also deco
by userbinator 9y ago
IMHO the "holy grail" of decompilation is to decompile the compiler, compile the decompiled decompiler, and get back a functioning decompiler that can also decompile itself ad infinitum. After several iterations, it may reach a fixed-point... this is essentially the exact opposite of what's customarily done with compilers: compile the compiler with itself, and repeat with the self-compiled compiler until a fixed-point is reached.
Thus, I naturally tried this one on itself, but that didn't work so well --- it spent several minutes analysing, then crashed.
Then I picked something slightly easier, upon which it did manage to decompile successfully, but the output is... not exactly what I expected. Copious void pointers of various levels of indirection (plenty of "three-star-programmer" code...) and reinterpret_cast sprinkled everywhere --- I have the original code and it was written in C, so it amusingly enough decided to automatically convert it to C++, along with the inability to recognise accesses to local variables leading to long sequences of -4-4-4-4+4-4-4+..., mean that for me it's not really all that better than reading the Asm directly.
The latter test was with a binary compiled with a very old compiler, so I suspect something with the newest optimising compilers will produce even more confounding output.
That said, it's great to see plenty of decompilers being written and released publicly; I remember around 2 decades ago when any mention of decompilation would be met with disdain and chants of "that's impossible!" Hex-Rays and IDA may have spurred a lot of this development; but speaking from experience, cracking groups have always written their own private decompiler-ish tools, mainly featuring dataflow analysis.