From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id ADABBBB9A for ; Wed, 5 Oct 2005 10:14:59 +0200 (CEST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j958Evmb015975 for ; Wed, 5 Oct 2005 10:14:58 +0200 Received: from rosella (ppp2-148.lns1.syd7.internode.on.net [59.167.2.148]) by smtp1.adl2.internode.on.net (8.12.9/8.12.6) with ESMTP id j958El8J063437; Wed, 5 Oct 2005 17:44:48 +0930 (CST) (envelope-from skaller@users.sourceforge.net) Subject: RE: [Caml-list] Dynamic linking From: skaller To: Alexander Bottema Cc: caml-list@yquem.inria.fr In-Reply-To: References: Content-Type: text/plain Date: Wed, 05 Oct 2005 18:14:47 +1000 Message-Id: <1128500087.16267.75.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 43438B81.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 gcc:01 -fpic:01 ocaml:01 foo:01 ocaml:01 trivial:01 load-time:01 model:01 'small:98 wrote:01 sourceforge:01 compile:01 emit:01 emit: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.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Tue, 2005-10-04 at 11:56 -0400, Alexander Bottema wrote: > But the problem with a DLL is that you never now what address will be > allocated for your executable. It can be located anywhere between 0 and > 2^64-1. Not on current versions of Linux/x86_64. They only support 48 bit code addresses (I think it is 48 bits), this is the so-called 'small model'. > Thus, when a DLL calls another DLL a 64-bit call is potentially > required. AMD64 supports global address tables that enable you to > translate a 32-bit call into a 64-bit one (likewise with data access). > If you compile a C file with gcc (-fPIC -S) you'll get code that looks > like this: I know ..but it has NOTHING to do with position independent code. > For OCaml to work you need to emit instructions of type 'call foo@PLT' > and 'movl xyzzy@GOT(%ebx)'. Currently, the OCaml does not do this for > AMD64, which is the heart of the problem. If you think this is trivial > to fix, please go head and do it; I'd be very happy. This has nothing to do with making the *code* position independent. It is to do with supporting elf/ld.so dynamic loading. This is another issue entirely. Clearly, to access a symbol of an 'unknown' address, you put the address into a known table slot instead, when the library is loaded, and access indirectly. In any case, this doesn't solve the problem, but it does identify it correctly: the problem is to emit instructions to bind to load-time linked libraries on Linux/Elf/ld.so platforms. You can be sure Windows -- for the same processor -- uses a different dynamic linkage model .. :) -- John Skaller Felix, successor to C++: http://felix.sf.net