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: -fpic option


satyaakam goswami wrote:

>           I have a question  ,  When i create two libs with one with
> -fpic option and other without it and then include both to create a
> binary archive will the both libs work together?

Note that this is extremely platform specific, and you did not mention
what platform you are using.  You need to be much more specific.

On linux x86 and I believe Solaris on some arches, you can in fact
create shared libraries containing non-PIC code, and they will function,
but very poorly.  Instead of sharing one copy of the .so across each
process that uses it, every process will have to have its own copy in
memory because each copy will have to be modified for that process using
text relocs.  So you waste memory tremendously by doing this, depending
on how many processes use the library.  You might as well just link
statically if you want the speed increase that non-pic code gives you.

On just about every other platform (including x86_64 linux) either PIC
is on by default or trying to add non-PIC objects to a .so will fail
spectacularly.

If you're talking about static linking then PIC-ness shouldn't matter at
all.

Also note that the compiler has nothing to do with this, it's more a
function of the linker, so you should probably follow up on the binutils
mailing list.

Brian


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