Hello,
First of all, I would like to apologize if this topic is a duplicate of an existing one.
We are currently using nasm to compile one object to be used in a shared library compiled with gcc. When compiling on a 32bits platform, everything is working fine but now I need to compile this library on a 64bits platform and I can't get the nasm compiled object to link with the gcc compiled objects.
Platform:
- Ubuntu 11.04 64bits (with kernel 2.6.38-10)
- gcc 4.5.2 (Target: x86_64-linux-gnu)
- nasm 2.09.04
- libtool 2.2.6b
- autoconf 2.67-2
Command line:
compilation: nasm -d OBJ_FORMAT_ELF -f elf64 myobject.nasm -o myobject.o
linking: g++ -shared -nostdlib *.o myobject.o -Wl,-soname -Wl,mylib.so.1 -o mylib.so.1.0.0
All the gcc objects are compiled with the -fPIC option
extern printf
SEGMENT .data align=16
// Some macro definitions
SEGMENT .text
global myfunction
myfunction:
//Do whatever needed
ret
When compiling on the 64 bits platform, I get the following error message:
/usr/bin/ld: myobject.o: relocating R_X86_64_32 against '.data' can not be used when making a shared object; recompile with -fPIC
myobject.o: could not read symbols: Bad value
I would appreciate your help for solving this issue.
Thank you.
Cédric