Reputation: 5335
Is there any way to get the source code by using object file in C?
For example I have a source code simple.c
cc simple.c
Now I have a.out (object file). By this a.out whether can I get the source?
code of simple.c
Upvotes: 23
Views: 37519
Reputation: 1
you can extract the strings present in the executable with the command strings if you are using linux.
Upvotes: 0
Reputation: 35469
The words for the programs you are looking for are "disassembler" (turning the machine language in a.out into assembly language) and "decompiler" (turning assembly language into C, as explained by Dacav, it is much more difficult and the result is never satisfying).
But using a Web search engine with these words may yield results.
Upvotes: 1
Reputation: 14078
There are many useful tools to retrieve information from your executable. None of them is able to give you back the original source code (as some other user pointed out, it's impossible for C), but you can try some reverse engineering tools. My preferred one are:
With the first one you can actually get all the exported symbols and their relative executable code in terms of assembly (obviously this is true only for the .text
sections). The second one is aimed to work with intel architectures, but you will be able to analize every executable file and get information about the ELF sections and symbols.
Upvotes: 21
Reputation: 490178
No. Turning a cow into hamburger is fairly easy. Turning hamburger into a living cow, somewhat more difficult.
Upvotes: 68
Reputation: 523344
No.
With reverse engineering (reading the disassembly) one could reconstruct the logic, but the variable names, comments, etc. will usually be lost.
Upvotes: 0