I am working on Ocaml and I've some binaries that I need to figure out. The closest I've come to is converting OCaml byte code to C compiled code using ocamlcc
.
I don't wish to reverse engineer the C-code unless and until I know for sure that I won't be able to decompile OCaml code.
Question: Are there any traditional ways to decompile ML code for OCaml specifically?
(Apologies if the question is abstract.)
You can also use dumpobj
from the tools
directory of the distribution. It is installed on my Ubuntu linux under the name ocamldumpobj
, and will print the instructions contained in a bytecode file, in a format like:
...
131214 APPLY1
131215 PUSHCONST1
131216 LTINT
131217 BRANCHIF 131225
131219 ACC2
131220 BRANCHIFNOT 131225
131222 ACC3
...
You have to learn about OCaml bytecode to go further. There is no tool to go from bytecode to source files, as the bytecode does not contain enough information for that.