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 EF917BB9B for ; Wed, 5 Oct 2005 15:11:54 +0200 (CEST) Received: from smtp2.mathworks.com (smtp2.mathworks.com [144.212.95.218]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j95DBs3Q014232 for ; Wed, 5 Oct 2005 15:11:54 +0200 Received: from mail-vif.mathworks.com (fred-ce0.mathworks.com [144.212.95.18]) by smtp2.mathworks.com (8.12.11/8.12.11) with ESMTP id j95DBqIn009185 for ; Wed, 5 Oct 2005 09:11:52 -0400 (EDT) Received: from MESSAGE-AH.ad.mathworks.com (ex-01-ah.mathworks.com [144.212.95.156]) by mail-vif.mathworks.com (8.11.7/8.11.7) with ESMTP id j95DBqv00112 for ; Wed, 5 Oct 2005 09:11:52 -0400 (EDT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: [Caml-list] Dynamic linking Date: Wed, 5 Oct 2005 09:11:13 -0400 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [Caml-list] Dynamic linking Thread-Index: AcXJhN6pYqpxxnsxRAagN4WuYhGKwQAJodXw From: "Alexander Bottema" To: X-Miltered: at nez-perce with ID 4343D11A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 -fpic:01 gcc:01 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 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 I think we may attach different meanings to "position independent code." For me PIC includes PIC suitable for dynamic linking. (This is what the -fPIC option tells GCC to do.) -- Alexander -----Original Message----- From: skaller [mailto:skaller@users.sourceforge.net]=20 Sent: Wednesday, October 05, 2005 4:15 AM To: Alexander Bottema Cc: caml-list@yquem.inria.fr Subject: RE: [Caml-list] Dynamic linking 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.=20 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.=20 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=20 platforms. You can be sure Windows -- for the same processor -- uses a different dynamic linkage model .. :) --=20 John Skaller Felix, successor to C++: http://felix.sf.net