Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Erik Bourget <ebourget@yahoo-inc.com>
To: "Alexander Bottema" <Alexander.Bottema@mathworks.com>
Cc: <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] [patch] PIC on amd64
Date: Wed, 25 Jan 2006 11:53:59 -0800	[thread overview]
Message-ID: <87y814xew8.fsf@raptors.corp.yahoo.com.> (raw)
In-Reply-To: <DB873318D1A41648BEAC4B5AAB63B3E10C556AD3@MESSAGE-AH.ad.mathworks.com> (Alexander Bottema's message of "Wed, 25 Jan 2006 08:26:32 -0500")

"Alexander Bottema" <Alexander.Bottema@mathworks.com> writes:

> Hasn't support for PIC/AMD64 been fixed in the latest release of OCaml
> (3.09.1)? Or have you found a bug in 3.09.1? I've tried to (native)
> compile a simple program on AMD64 as a shared library and it worked
> fine.

The problem is when you try to go beyond simple :)

ocamlopt -fPIC -output-obj -o hello.o pcre.cmxa hello.cmx
ld -shared --whole-archive -o hello.so hello.o -lpcre

You could make a shared library from ocaml if you assembled everything into
one object file as the assembler would be able to see all the functions.
amd64 linkers require you to look up functions in the GOT (which ld.so keeps
up to date when it loads new stuff) if they're not local.

ocaml 3.09.1:
  movq symbol(%rip), %r11  # add symbol to %rip and we know in memory where 
                           # it is.

With shared library patch:
  movq symbol@GOTPCREL(%rip), %r11  # get the address of the symbol in 
                                    # the table the linker has made for us,
  movq (%r11), %r11                 # and load it.  We have to do this because
                                    # we don't know the address of
                                    # symbol until runtime!

So, specifically, the aim of this patch is to allow the creation of shared
libraries that in turn pull in other libraries.  The amd64 ABI doc
(x86-64.org) goes into great detail about the different kinds of relocations
that are available - some are valid for shared objects and some are not.

- Erik


      reply	other threads:[~2006-01-25 19:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-25 13:26 Alexander Bottema
2006-01-25 19:53 ` Erik Bourget [this message]

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=87y814xew8.fsf@raptors.corp.yahoo.com. \
    --to=ebourget@yahoo-inc.com \
    --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