From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 4BD41BBBB for ; Wed, 25 Jan 2006 20:58:17 +0100 (CET) Received: from mrout3.yahoo.com (mrout3.yahoo.com [216.145.54.173]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0PJwGDP013041 for ; Wed, 25 Jan 2006 20:58:16 +0100 Received: from localhost.localdomain (raptors.corp.yahoo.com [207.126.231.163]) by mrout3.yahoo.com (8.13.4/8.13.4/y.out) with ESMTP id k0PJtiU6067055; Wed, 25 Jan 2006 11:55:45 -0800 (PST) DomainKey-Signature: a=rsa-sha1; s=serpent; d=yahoo-inc.com; c=nofws; q=dns; h=received:from:to:cc:subject:references: x-eric-conspiracy:date:in-reply-to:message-id:user-agent:mime-version:content-type; b=Tfjb++Fqh7DQIy5NgrG7tqnPbZc8TYe3KuN30WGVCp7eNxgL2K8aGX3/Cl3dVi4R Received: from raptors.corp.yahoo.com..ebourget.net (localhost.localdomain [127.0.0.1]) by localhost.localdomain (Postfix) with ESMTP id 59E0A20F0DD; Wed, 25 Jan 2006 11:54:00 -0800 (PST) From: Erik Bourget To: "Alexander Bottema" Cc: Subject: Re: [Caml-list] [patch] PIC on amd64 References: X-Eric-Conspiracy: There Is No Conspiracy Date: Wed, 25 Jan 2006 11:53:59 -0800 In-Reply-To: (Alexander Bottema's message of "Wed, 25 Jan 2006 08:26:32 -0500") Message-ID: <87y814xew8.fsf@raptors.corp.yahoo.com.> User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at concorde with ID 43D7D858.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 bug:01 ocamlopt:01 -fpic:01 -output-obj:01 pcre:01 cmxa:01 cmx:01 -shared:01 -lpcre:01 ocaml:01 runtime:01 writes:01 compile:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.9 required=5.0 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_WHOIS,FORGED_RCVD_HELO autolearn=disabled version=3.0.3 "Alexander Bottema" 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