From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Alex Baretta <alex@baretta.com>
Cc: Ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Native executable symtable
Date: Thu, 11 Nov 2004 18:27:49 +0100 [thread overview]
Message-ID: <20041111172749.GA12790@yquem.inria.fr> (raw)
In-Reply-To: <41933C5E.2010008@baretta.com>
> We are writing a library implementing binary client-server protocol
> based on the Marshal module. In order to guarantee some degree of
> type-safety, during the handshaking phase of the communication we need
> the client to send the server the MD5 checksums of all relevant modules.
> [...]
> We have found that the md5sum can be fetced directly from the executable
> file associated to the process. This technique is documented nowhere, as
> far as I can see, but the source code of Symtable.init_toplevel is very
> informative as to how to do this for bytecode executables. What I would
> like to know is how to implement this technique for native code
> executables. Essentially, how am I supposed to parse the binary
> executable to extract the symtable information.
You cannot, because the checksums you mention (the digests of the
interfaces of the modules) are not included in ocamlopt-generated
executables. They are included only in ocamlc-generated executables (in
the CRCS section) for use with Dynlink and the toplevel.
At any rate, I think you're on the wrong tracks: the checksums you'll
find in the CRCS section of bytecode executable are those of module
interfaces, not of module implementations. To establish type
agreement between two processes communicating via
output_value/input_value, you really want the latter, not the former.
(Think of an abstract type implemented differently in the two
processes. For more details, see e.g. the ICFP'03 paper by Leifer,
Peskine, Sewell and Wansbrough.)
So, you're looking for convenient ways to collect checksums for module
implementations. An insight that might simplify your build process is
that while these checksums must be computed at compile-time (e.g. by
running md5sum on the source .ml files), they can be collected
together at run-time. For instance, you could preprocess the .ml
sources of interest so as to insert at the beginning
let _ = Registry.record_module "Modulename" "checksum"
where "Modulename" is the module name and "checksum" the outcome of
md5sum on the source file. The Registry.record_module function just
accumulates its arguments in a hashtable or association list, which
can then be consulted during the agreement phase of your protocol.
There are probably many other ways to do it. But I think your initial
idea (compute checksums of source files at compile-time) is the
correct one, it's just a question of implementing it in a way that
doesn't complicate your build process too much.
- Xavier Leroy
next prev parent reply other threads:[~2004-11-11 17:27 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-11 10:18 Alex Baretta
2004-11-11 10:39 ` [Caml-list] " Nicolas Cannasse
2004-11-11 11:09 ` Luca Pascali
2004-11-11 11:55 ` Keith Wansbrough
2004-11-11 12:09 ` Luca Pascali
2004-11-11 12:28 ` Keith Wansbrough
2004-11-11 12:42 ` Luca Pascali
2004-11-11 16:09 ` Richard Jones
2004-11-20 15:44 ` Luca Pascali
2004-11-20 16:03 ` malc
2004-11-20 18:01 ` Alex Baretta
2004-11-20 18:06 ` malc
2004-11-20 18:53 ` Alex Baretta
2004-11-20 19:17 ` malc
2004-11-20 20:07 ` Ritesh Kumar
2004-11-20 22:43 ` The madness of ignoring people Vincenzo Ciancia
2004-11-20 23:10 ` [Caml-list] " malc
2004-11-20 23:25 ` Vincenzo Ciancia
2004-11-21 12:51 ` skaller
2004-11-21 14:14 ` Vincenzo Ciancia
2004-11-21 14:30 ` malc
2004-11-21 3:37 ` [Caml-list] Native executable symtable skaller
2004-11-21 15:59 ` Richard Jones
2004-11-21 20:29 ` skaller
2004-11-21 20:39 ` malc
2004-11-21 23:30 ` Richard W.M. Jones
2004-11-22 3:25 ` skaller
2004-11-21 20:42 ` Jean-Marie Gaillourdet
2004-11-21 18:31 ` Ritesh Kumar
2004-11-21 23:33 ` Richard Jones
2004-11-21 21:15 ` skaller
2004-11-11 16:23 ` David Brown
2004-11-11 17:27 ` Xavier Leroy [this message]
2004-11-11 18:48 ` Alex Baretta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041111172749.GA12790@yquem.inria.fr \
--to=xavier.leroy@inria.fr \
--cc=alex@baretta.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox