Newsgroups: fa.caml
From: Xavier Clerc <xcfo...@free.fr>
Date: Wed, 15 Nov 2006 13:56:59 UTC
Local: Wed, Nov 15 2006 8:56 am
Subject: Re: [Caml-list] Bytecode object files structure
Le 13 nov. 06 à 16:50, Pierre-Etienne Meunier a écrit : > Hello, If you are working on a compiler that should output files to be > I'd like to write an assembler, to be able to understand how the vm executed by the ocaml runtime, it does not seem necessary to handle cmo/cmi files as the format of bytecode file should be sufficient to code your compiler. Unless you have to link with ocaml modules. > I've understood that the data part, after the code itself, was This fonction is used by the Marshal module. It transforms any non- > generated using > output_value (I didn't know this function before). abstract value into a chain of bytes. The format of marshalling can be understood from the extern_rec function of the byterun/extern.c file. > What I don't get now are You should remember that cmo files are parts that will be put > the cu_reloc, cu_primitives and cu_imports fields of the > compilation_unit > type. together (linked) in order to create a bytecode file. Given this context : - cu_imports lists the name of imported (used) modules the current cmo should be linked with in order to produce a bytecode file (the digest of the imported modules is also kept to ensure that you link with the same version you compiled against) ; - cu_primitives lists the primitives declared by the current module (each 'external f : type1 -> type2 = "primitive" ' will result in a "primitive" entry of this list), needed to ensure that all required C primitives are provided ; - cu_reloc : as each module is compiled independently, it can declare some elements (e.g. global variables) and use them using a 0- based index ; thus, when you link several modules together, you have to relocate this information to ensure that the first module uses indexes from 0 to n, the second module uses indexes from n+1 to n+m and so on ... Hope this helps, Xavier Clerc PS : I am working on some documents describing marshalling format, > If you can help on this, > On Monday 13 November 2006 11:53, you wrote: >> As I read a substancial part of the ocaml source code, I may help you >> May I also ask you what you are trying to do using these elements ? >> Cordially, >> Xavier Clerc >> Le 12 nov. 06 à 15:42, Pierre-Etienne Meunier a écrit : >>> I'm trying to decrypt .cmo files produced by simple programs, >>> According to the source of Ocaml, there's something called the >>> Then, there's the address of what seems to be the last bytecode >>> After that, I can't understand anything : there vaguely seems to be >>> Thanks, >>> _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||