[comp.lang.c] C un-compiler ?

WAB1@NS.CC.LEHIGH.EDU (William Anthony Barry) (06/22/91)

Hello,
   Is it possible to disassemble an executable file back into its C
language source? If not completely possible, there must be certain
constructs that could be recognized, then the rest could be left in
assembly language. Are there any existing programs that do this?
                 Thanks for any comments,
                        Bill Barry
                             wab1@ns.cc.lehigh.edu

chaplin@keinstr.uucp (chaplin) (06/27/91)

In article <22069105.30.00WAB1@lehigh.bitnet> WAB1@NS.CC.LEHIGH.EDU (William Anthony Barry) writes:
>Hello,
>   Is it possible to disassemble an executable file back into its C
>language source? If not completely possible, there must be certain
>constructs that could be recognized, then the rest could be left in
>assembly language. Are there any existing programs that do this?
>                 Thanks for any comments,
>                        Bill Barry
>                             wab1@ns.cc.lehigh.edu

I don't know what's available, so I can't answer that part.  However, based
on my experience with various C compilers, it seems that an un-compiler
would have to have quite a bit of knowledge of the compiler which was used
to produce the executable.

For instance, the 68K assembly code produced for a switch statement by
a Greenhills cross compiler looks vastly different from the code
produced by a Microtec cross compiler.

Also, one of the optimizations which the Microtec compiler can perform
is the removal of duplicate code (I don't know the formal name for
this).  I discovered this feature when I was tracing execution using an
in-circuit emulator, and I noticed that large amounts of code seemed to
be "missing."  Obviously, an un-compiler would not be able to accurately
reconstruct the source code from an executable which has been so optimized.
-- 
Roger Chaplin / Instruments Division Engineering / "Though I'd been lost now I
chaplin@keinstr.uucp / CI$: 76307,3506          / felt I was found when He
#include <disclaimer.h>                        / looked at me with His
#include "disclaimer.h" /* cover all bases */ / forgiving eyes." - Michael Card