Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C decompiler...any good?

Status
Not open for further replies.

alqsp

Programmer
Dec 12, 2001
9
AU
I have an executable program that I believe to be a C program. Unfortunately I don't have the source code.

I believe this program was compiled on a HP-UX machine, but now needs to be run on a Sun-Solaris box..it doesn't run.

My question is this - Does anyone know if a decompiler would assist me in trying to sort this out? If so can anyone suggest a C decompiler?

Cheers
 
Dont think one exists. All i know of is a decompiler to assembly.

Matt
 
There's a good reason for that: by rights an exe file doesn't contain enough information to convert to a C file. Obviously, for instance, no necessity of containing variable names, data structures etc. In fact the C syntax definition doesn't limit how a compiler goes about making it work. It can't, because otherwise C would become platform specific... There's no hard and fast rule that says a computer must have its memory arranged in a certain way, or a byte-size of 8 bits, or whatever, yet any machine should be able to run a C compiler if someone cares to write one.

Therefore it would be very hard to write a C decompiler, because the piece of code resulting from a C statement might not be the same from all compilers. In fact a C compiler could happily make a runnable exe file that could equally well have been generated by a fortran compiler.

And the original author might have used any number of commercially available libraries etc.

Any good author will have laid out their program according to some sort of good practice, but this reflects only in the readability (and bug content!) of the program, not in the final compiled code. Therefore a decompiler would need to play at psychology to guess how the original might have been written.

I suppose you could, in theory, write some sort of C decompiler, but it would probably produce really nasty code that's hard to read. Frankly, I think most people use disassemblers not to produce compilable assembly code, but to see what their compiler is making of code they already wrote, or suchlike poking around.

Wouldn't it be nice to be able to decompile, though!

Sorry to have such a lengthy rant, but this question has come up a few times before, so I thought it deserved more typing than normal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top