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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id B903ABB94 for ; Tue, 4 Oct 2005 16:47:54 +0200 (CEST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j94Elqd6025208 for ; Tue, 4 Oct 2005 16:47:53 +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 j94ElhOr063370; Wed, 5 Oct 2005 00:17:44 +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 00:47:43 +1000 Message-Id: <1128437263.13074.44.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 43429618.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 dlls:01 ocaml:01 hackery:01 wrote:01 sourceforge:01 short:01 constraint:01 data:02 data:02 segmentation:02 assembler:02 alexander:02 linking:03 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 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 Felix, successor to C++: http://felix.sf.net