PIC is wasteful

Marc Glisse marc.glisse@inria.fr
Fri Jun 24 04:38:00 GMT 2011


On Thu, 23 Jun 2011, Ian Lance Taylor wrote:

> Agner Fog <agner@agner.org> writes:
>
>> I wonder why position-independent code (PIC) and global offset tables
>> (GOT) are used in shared objects (.so) when these features are wasting
>> resources and apparently unnecessary. The wasteful use of PIC and GOT
>> in Linux is apparent in the following questions:

Do you mean you would like -Bsymbolic to be the default ? (or maybe 
Solaris' -Bdirect)

> Symbol interposition means that the shared library is permit to define a
> function "malloc" and to call that function itself.  However, if the
> executable defines a function "malloc" itself, then all the calls in the
> shared library should call the implementation in the executable, rather
> than the implementation in the shared library.

Note that although symbols are interposable by default, functions are 
inlinable by default (at -O3) when their body is available, which can be 
surprising.

-- 
Marc Glisse



More information about the Gcc-help mailing list