PIC is wasteful

Andrew Haley aph@redhat.com
Fri Jun 24 15:18:00 GMT 2011


On 06/24/2011 11:53 AM, Agner Fog wrote:
> On 24-06-2011 12:38, Andrew Haley wrote:
>> On 06/24/2011 11:19 AM, Agner Fog wrote:
>>> On 24-06-2011 10:23, Andrew Haley wrote:
>>>>
>>>>> Why does it make 32 bit absolute addresses when I specify
>>>>> -mcmodel=medium?
>>>> Small symbols are placed in the lower 2G.
>>> So I would have to replace all variables with very big arrays in order
>>> to prevent 32 bit addresses in 64 bit mode :-(
>> What problem are you trying to solve?  I don't get it.  Why would you
>> want to avoid 32-bit absolute addresses?
>>
> Because the linker complains whenever there is a 32 bit absolute 
> reference in a 64 bit shared object. I guess the .so can be loaded above 
> the 2G address limit.

Can you show us how you made a 64-bit absolute reference in a shared
object?  I don't quite understand how that could work.  Apart from
anything else, I don't think the x86_64 has instructions to do it.

> Apparently, the only way to avoid 32 bit addresses is compiling with 
> -fpic, which has the undesired effect of using GOT and PLT entries which 
> makes shared objects slower than static libraries. The seldom used 
> feature to override a symbol comes at a high price.

Its isn't seldom used.  It's used all the time.

If it weren't possible to override symbols in shared libraries, every
user of a library would be forbidden to use any of the symbols exported
by that library in their own programs.

Andrew.



More information about the Gcc-help mailing list