I'm sure there's a way. I'm new to C and my research on this led me nowhere. Is there a command that can convert a .o file to .c?
2 Answers
Usually you can only determine the assembly language for the object file, using a disassembler. Here are a few links to discussion on that topic, e.g., for objdump:
- objdump - GNU Binary Utilities
- Disassembling a binary in Linux
- Using GCC to produce readable assembly?
- Linux Interactive DisAssembler
Reverse-compiling (decompiling) is much harder. Here are a few links to help:
.o file has object code and cannot be converted back to its original .c file having high level code . It is just like the fact that chewed food cannot be converted back to its solid form.
1 Comment
bryc
Bad analogy. It's more like IKEA furniture. With a full understanding of the assembly language (manual), compiled code can be manually rebuilt to perform the same task. It is quite difficult work, and it won't be the exact C code (since compilers do lots of optimizing) but it will be functionally equivalent.