Re: effect of -fPIC on code speed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ian Lance Taylor <iant@xxxxxxxxxx> writes:
> There is a great deal one could say about -fPIC.  It's hard to know what
> should be said in the gcc docs.  To me it seems more appropriate in some
> document about what PIC really is.

Sure, then the gcc doc can say "(see <all-about-pic> for details)"... :)

> What happens here is that when using -fPIC symbol interposition is
> permitted for any globally visible symbol.  That is, the -fPIC code is
> presumed to wind up in a shared library.  An executable may override any
> function in a shared library.  The code in the shared library which
> calls that function is then expected to call the definition in the
> executable instead.  It follows that when using -fPIC the compiler may
> not inline any call to a globally visible function, because that would
> prevent symbol interposition.

Hmm, I guess this makes sense.

It would definitely be nice to have a more precise description in a
document somewhere though.

I'd think it would also be good to have a way of disabling this
particular side-effect -- e.g., for non-shared-library uses of shared
objects, like loadable modules/plugins etc, which presumably don't aim
to provide the same guarantees that shared libraries do.

[Is there more appropriate place to say these things than gcc-help, btw?]

-Miles

-- 
Run away!  Run away!



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux