This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: When to generate PIC?


Erik Leunissen <e.leunissen@hccnet.nl> writes:

> I am developing a library that needs to be dynamically loaded into an
> application.
> 
> I am unsure whether or not to generate position independent code for
> this library. I just don't know which considerations are relevant for
> such a decision.
> 
> Could anybody enlighten me (or point me to information where I could
> enlighten myself)?

It is normally more efficient to use -fPIC when compiling any code
that is going to be linked into any shared library.  So you should use
-fPIC.

It is more efficient because with -fPIC code the dynamic linker
(including dlopen) has to apply fewer dynamic relocations at run time.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]