caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Alexander Bottema <Alexander.Bottema@mathworks.com>
Cc: caml-list@yquem.inria.fr
Subject: RE: [Caml-list] Dynamic linking
Date: Wed, 05 Oct 2005 00:47:43 +1000	[thread overview]
Message-ID: <1128437263.13074.44.camel@rosella> (raw)
In-Reply-To: <DB873318D1A41648BEAC4B5AAB63B3E10AC3ABDF@MESSAGE-AH.ad.mathworks.com>

On Tue, 2005-10-04 at 08:47 -0400, Alexander Bottema wrote:

> Now, as a developer it would be nice if it was possible to write certain
> parts in OCaml. The foreign language interface is good enough to be used
> in conjunction with C/C++, but the lack of support to use it in DLLs
> makes it impossible for us to have any OCaml code in our leaf product.
> 
> Nevertheless, I really tried to make it work (and I almost did). It's
> only Linux/AMD64 that I couldn't solve and I really tried to modify the
> AMD64 emitter.

I actually find this very strange. The x86 is incapable of
supporting position independent code without hackery or 
segmentation:

(a) there is no IP relative call instruction (only short branches)
(b) there is no IP relative data access (at all)

The amd64 (x86_64) on the other hand supports IP relative
calls and data access (with 32 bit offsets only, but
usually enough for all code and global data).


> > The only platform which I couldn't get to work was Linux AMD64. I
> tried
> > to modify the OCaml emitter for AMD64 to accommodate position
> > independent code using the offset tables, but it was too hard.

There is no need for offset tables. Just make sure all
'absolute' addresses accesses are changed to be RIP relative
and the assembler will do the rest automatically.

[There may be a problem on Windows, apparently the linker
can't add two offsets together due to a constraint in COFF
format, not sure about that though]

See section 2.2.5 of the AMD document 24592.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2005-10-04 14:47 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-04 12:47 Alexander Bottema
2005-10-04 14:47 ` skaller [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-06-18  4:18 Jeffrey Loren Shaw
2007-06-15 16:03 Alain Frisch
2007-06-15 16:47 ` [Caml-list] " Joel Reymont
2007-06-15 16:52 ` Brian Hurt
2007-06-15 18:24   ` Alain Frisch
2007-06-15 18:59     ` Jon Harrop
2007-06-15 20:57       ` Alain Frisch
2007-06-15 22:38     ` Quôc Peyrot
2007-06-16  7:23       ` Alain Frisch
2007-06-16 17:33     ` Jon Harrop
2007-06-16 17:59       ` skaller
2007-06-16 20:13         ` Christophe TROESTLER
2007-06-16 23:10         ` Philippe Wang
2007-06-15 22:37 ` skaller
2007-06-15 22:45   ` Christophe TROESTLER
2007-06-15 22:58     ` skaller
2007-06-20 13:40 ` Alain Frisch
2007-06-24 11:35 ` Jon Harrop
2005-10-05 13:11 Alexander Bottema
2005-10-04 15:56 Alexander Bottema
2005-10-05  8:14 ` skaller
2005-09-28 12:44 Alexander Bottema
2005-09-26  3:09 Jonathan Roewen
2005-09-26  4:26 ` skaller
2005-09-26  5:14 ` Jacques Garrigue
2005-09-26  5:20   ` Jonathan Roewen
2005-09-28  9:05   ` Jacques Garrigue
2005-04-05 21:12 Emir Pasalic
2005-04-05 22:02 ` [Caml-list] " Igor Pechtchanski

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=1128437263.13074.44.camel@rosella \
    --to=skaller@users.sourceforge.net \
    --cc=Alexander.Bottema@mathworks.com \
    --cc=caml-list@yquem.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).