English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Compiling shared library with libasmrun.a
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-12-27 (10:16)
From: Eric M. Hielscher <hielscher@g...>
Subject: Fwd: Compiling shared library with libasmrun.a
Hi all,

As discussed in a few places on this list, I'm trying to compile a
shared library which includes both C and OCaml code.  Specifically,
I'm trying to do the following:

- I have a proprietary language X's interpreter which allows me to
link into it C shared libraries
- I've written C wrappers for OCaml functions which expose the OCaml
functions to X via X's library interface
- I've written OCaml functions which do the meat of what I want

Thus the pipeline is: Ocaml + C = shared library, and then shared
library gets linked into X.

The problem I'm having, on an AMD64 architecture, is that I can't seem
to create a shared library which links to libasmrun.a as the default
setup compiles libasmrun.a without the -fPIC option, and thus the
resultant library has non-position-independent code.

In discussions with another guy who's had the same problem, I've tried
altering the Makefile in the asmrun directory to have the -fPIC option
included as well as inserting PLT directives in some places in the
amd64.S file, but I'm still getting the error that libasmrun.a
contains non-position-independent code.  The error message looks like

/usr/bin/ld: ../ocaml/lib/ocaml/libasmrun.a(amd64.o): relocation
R_X86_64_PC32 against `caml_last_return_address' can not be used when
making a shared object; recompile with -fPIC

which makes it seem as though amd64.o includes the bad code, though I
verified that amd64.o was compiled as follows:

gcc -c -fPIC -DSYS_linux -o amd64.o amd64.S

Any ideas on how to get a working libasmrun.a for my situation?

Eric Hielscher