caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Evgeny Roubinchtein <evgenyr@cs.ubc.ca>
To: caml-list@inria.fr
Subject: [Caml-list] Callback.register equivalent before runtime is initialized?
Date: Thu, 15 Aug 2013 00:04:36 -0700	[thread overview]
Message-ID: <20130815070432.GA31041@jade.home.test> (raw)

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


             reply	other threads:[~2013-08-15  7:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-15  7:04 Evgeny Roubinchtein [this message]
2013-08-15  7:33 ` David Allsopp
2013-08-22  5:47 ` [Caml-list] Callback.register equivalent before runtime is oleg
2013-08-23 20:39   ` Evgeny Roubinchtein

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=20130815070432.GA31041@jade.home.test \
    --to=evgenyr@cs.ubc.ca \
    --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;
as well as URLs for NNTP newsgroup(s).