Position Independent Code usage on x86-64

Alexey Skidanov alexey-s@orbotech.com
Wed Dec 16 14:58:00 GMT 2009


Hi,

We ported our code to 64 bit (CentOS 5.2 64 bit). We have some static
library that linked with some shared library. In 32 bit version, the
shared library was successfully created. Trying to create it in with 64
bit version compiler, we get the error: 

/usr/bin/ld: .//libstatic.a(static.o): relocation R_X86_64_32 against
`__gxx_personality_v0' can not be used when making a shared object;
recompile with -fPIC
.//libstatic.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

We also found that if static library is linked with shared library then
it should be compiled with -fPIC option. But if the static library is
linked with ELF executable it shouldn't.

The questions are:
1. Does it make sense that we need to know about static library exact
usage? 
2. Is there an option of gcc that "generate" backward compatible (with
32 bit version) compilation/linking process? 

We found some explanation here
http://www.technovelty.org/code/c/amd64-pic.html

Thank you in advance,
Alexey



More information about the Gcc-help mailing list