From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 11C72820A1 for ; Thu, 15 Aug 2013 09:04:25 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of evgenyr@cs.ubc.ca) identity=pra; client-ip=142.103.6.52; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="evgenyr@cs.ubc.ca"; x-sender="evgenyr@cs.ubc.ca"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of evgenyr@cs.ubc.ca) identity=mailfrom; client-ip=142.103.6.52; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="evgenyr@cs.ubc.ca"; x-sender="evgenyr@cs.ubc.ca"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@smtp.cs.ubc.ca) identity=helo; client-ip=142.103.6.52; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="evgenyr@cs.ubc.ca"; x-sender="postmaster@smtp.cs.ubc.ca"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlgCALx8DFKOZwY0lGdsb2JhbABbxDUWDgEBAQEJCwkJFAUjgiY/M0gTIQWIbJk5oEOQbYMFdwOJLY42AYYWjnc X-IPAS-Result: AlgCALx8DFKOZwY0lGdsb2JhbABbxDUWDgEBAQEJCwkJFAUjgiY/M0gTIQWIbJk5oEOQbYMFdwOJLY42AYYWjnc X-IronPort-AV: E=Sophos;i="4.89,883,1367964000"; d="scan'208";a="23978153" Received: from smtp.cs.ubc.ca ([142.103.6.52]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 15 Aug 2013 09:04:23 +0200 Received: from jade.home.test (d154-5-175-186.bchsia.telus.net [154.5.175.186] (may be forged)) (authenticated bits=0) by smtp.cs.ubc.ca (8.14.5/8.13.6) with ESMTP id r7F74FxR030902 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 15 Aug 2013 00:04:19 -0700 Date: Thu, 15 Aug 2013 00:04:36 -0700 From: Evgeny Roubinchtein To: caml-list@inria.fr Message-ID: <20130815070432.GA31041@jade.home.test> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Subject: [Caml-list] Callback.register equivalent before runtime is initialized? Hello, everyone, I am learning about run-time compilation, and using OCaml as a base for my experiments. So far, I have a really simple C primitive that just calls back into a simple OCaml wrapper around Toplevel.load_lambda (it passes a Lambda.lambda that has been marshalled to a string constant). Since the C primitive is in the run-time (libcamlrun) library, and the wrapper is in the Toplevel, I am using Callback.register to pass the address of the wrapper to the C primitive. That set-up works pretty well in the toplevel because I can call Callback.register when the toplevel is being initialized, i.e., before any code is read from the user. However, I am now trying to move to producing bytecode executables, so, if I stay with my current set-up I would need to do the equivalent of Callback.register (i.e., put the address of the wrapper into the hash table maintained by caml_callback_register) before any of the "user code" in the executable starts to run. I have been looking at the (bytecode) linker and also the caml_startup function to understand how the running of bytecode "gets started", and I have also modified tools/objinfo to print the contens of the SYMB section in bytecode executables and the relocations table in .cmo's to see if inspiration strikes ;-) -- but so far I am not quite seeing "how things work." I'll keep looking, but I though I'd ask for advice here in case someone has some advice to offer. -- Best, Evgeny