Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why programs compiled with certain compilers can be decompiled and other's (practically) can't? [closed]

I used to think Java can be decompiled because it compiles into byte code and not object code. This is wrong because of the implicit assumption byte code is some how "more human readable" than object code. Why can programs written in Java be so easily decompiled and even have the same identifiers (variable names)? I heard in C/C++ it can only disassemble to assembly but no decompile to source code, why so?

like image 494
Celeritas Avatar asked Feb 20 '23 05:02

Celeritas


1 Answers

Java compilers keeps most of the original information and does very little optimisation when producing the byte code. The compilers task is to validate the code so it can be dynamically optimised. Note: Excelisor compiles to native code and imagine would be difficult to decompile (at least that what their marketing says ;)

C/C++ is compiled and optimised as much as possible, discarding a lot of the original information. (With the exception for debug information) This makes it much more difficult to untangle into sensible C or C++.

Note: these are features of the compilers common used for those languages. Not features of the languages themselves.

In terms of the difference in languages, all you can say is that Java is relatively feature poor compared with C++. Less features makes less compiled patterns to understand and reverse engineer.

like image 172
Peter Lawrey Avatar answered Feb 21 '23 20:02

Peter Lawrey