Version française
Home     About     Download     Resources     Contact us    
Browse thread
Compiling a shared library on AMD64
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Erik Bourget <ebourget@y...>
Subject: Compiling a shared library on AMD64

I'm having trouble building a shared library using components from the ocaml
standard library on my x86_64 box.  I built ocaml 3.09.0 with:
BYTECCCOMPOPTS=-fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -fPIC
NATIVECCCOMPOPTS=-Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -fPIC
NATIVECCPROFOPTS=-Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT -fPIC
SUPPORTS_SHARED_LIBRARIES=true
BNG_ARCH=amd64

, but the standard library seems to still have some R_X86_64_32S relocations
in it.

I don't understand ELF very well so I'm kind of lost :) Can anyone give any
pointers?

- Erik

Story in transcript:

$ ocamlopt -ccopt "-fPIC -D_FILE_OFFSET_BITS=64 -D_REENTRANT" -fPIC -I /usr/lib/ocaml/site-packages/pcre -I /usr/local/lib/ocaml/site-lib/pcre -output-obj -fPIC -o camlcode.o unix.cmxa pcre.cmxa range_utils.cmx parser.cmx lexer.cmx memoize.cmx tinydns.cmx netmask.cmx admins.cmx netblocks.cmx evaluate.cmx range.cmx

$ ld -shared --whole-archive -o librange.so camlcode.o librange.o /usr/local/lib/ocaml/libunix.a /usr/local/lib/ocaml/libasmrun.a /usr/local/lib/ocaml/site-lib/pcre/libpcre_stubs.a /usr/lib64/libm.a /usr/lib64/libpcre.a /usr/lib64/libdl.a

ld: camlcode.o: relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC

$ objdump -r camlcode.o | grep R_X86_64_32S

000000000000377d R_X86_64_32S      .rodata
0000000000003be6 R_X86_64_32S      .rodata+0x000000000000008
... (20 more .rodata, but only .rodata, nothing else)

erik:~/src/packages/ocaml/ocaml-3.09.0/stdlib$ objdump -r scanf.o | grep 64_32
00000000000021de R_X86_64_32S      .rodata
0000000000002a53 R_X86_64_32S      .rodata+0x00000000000003e0
... ( more .rodata)

The pcre.o used to build pcre.cmxa also has some rodata's in it.