Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Dynamic linking
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Dynamic linking
From: Jonathan Roewen <jonathan.roewen@gmail.com>

> We're trying to figure out how to provide some sort of dynamic linker
> for DST to load ocaml native code at runtime on an ocaml native code
> kernel.
> 
> Is there any document that details the format of .cmi/.cmx files;
> also, are these (esp .cmi) able to provide the necessary details on
> the symbols in the kernel for building a dynamic linker that can
> resolve symbols to kernel functions in ocaml code loaded at runtime?

No document that I know, but the code is clear enough.
You may have a look at Env.read_pers_struct for .cmi and
Compilenv.read_unit_info for .cmx.
However I'm not sure it would help you very much in practice.
There are at least two other problems before you can do dynamic linking
of native code in ocaml:
* the code generator is geared toward static code, which means that it
  cannot be handled by the runtime linker on many architectures
  (I only know of a patch for x86)
* some glue code is generated at link time
So this looks like a rather difficult task...

> I know Dynlink module doesn't work with native code, and if I'm
> correct, the unsupported Asmdynlink module provided a runtime
> environment for bytecode ocaml code in native code programs right?
> Which is not what we'd be looking for.

Yet another approach would be to use bytecode + JIT.
But this won't give you the performance of native code.

    Jacques