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?
Asked
Active
Viewed 2.8k times
2
-
3Hi Tony, that isn't easily possible. It's called 'decompilation' and unfortunately it's not a simple process. – axblount Mar 21 '15 at 05:53
2 Answers
4
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:

Thomas Dickey
- 51,086
- 7
- 70
- 105
-
-
-1: Link-only answers are not seen as good answers on this side. Answers should be able to stand up on their own without any links which your answer does not. – fuz Nov 23 '17 at 13:18
-
-1
.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.

Achyuta Aich
- 569
- 1
- 5
- 13
-
1Bad 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. – bryc Dec 10 '17 at 01:18