2

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?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Tony
  • 65
  • 1
  • 1
  • 2
  • 3
    Hi 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 Answers2

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:

Reverse-compiling (decompiling) is much harder. Here are a few links to help:

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
-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
  • 1
    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. – bryc Dec 10 '17 at 01:18