2 msgVectorization in gcc 4.1.1
2 msgfor loop: different results on cygwin and on linux
2 msggcc and lcc
10 msgCan I force a word read-modify-write instread o...
1 msgmovdqa and movdqu
2 msggcc assembler
5 msgfpa glibc-2.2.5 for a native armv4l toolchain
16 msginstalled, compiled, how to link?
4 msgc++ template instanciation and dlls on win32
2 msglinking internal executible functions: 'undefin...
1 msginternal compiler error: Segmentation fault
2 msggcc binaries for Solaris 2.5
8 msgAre java executables standalone?
1 msgBootstrap problem on powerpc-ibm-aix5.1.0.0
2 msgProblem loading GCC 4.0 libraries into Java app
1 msgBi-Architecture build problem on Opteron
10 msgIs fastcall broken?
3 msggcc-4.1.1: ssp (stack smashing protector) for a...
2 msgtemplate function inlining in g++ version < 4.0

-fPIC and shared object
\ Olivier Delannoy (28 Jun 2007)
. \ Andrew Haley (28 Jun 2007)

Subject:Re: -fPIC and shared object
Group:Gcc-help
From:Andrew Haley
Date:28 Jun 2007


Olivier Delannoy writes:
> Hello,
>
> I am using linux and I would like to understand the role of -fPIC. I
> understand that it generate code where function address can be
> calculated indirectly after relocation of the .so in applications
> using it. My questions are :
>
> - Is it required to compile with -fPIC every object file packed in a
> dynamic shared object ?

Yes. (Well, kinda: there is a platform that allows relocation to be
performed on shared objects after loading, but it's inefficient and is
purely a backawards compatibility hack.)

> - Is is possible to integrate a static library in a .so safely
> (assuming the static library is not compiled using -fPIC)

No.

> - Is the answer to the previous question the same if the library is
> used only within the boundary of the .so (hidden to the rest of the
> application) ?

Yes.

Andrew.


© 2004-2008 readlist.com