building non-shared dynamic binaries on x86-64 linux-elf

Andrew Haley aph@redhat.com
Wed Apr 22 14:53:00 GMT 2009


Ian Lance Taylor wrote:
> Andrew Haley <aph@redhat.com> writes:
> 
>> Mathieu Lacage wrote:
>>
>>> What I am trying to do is generate a non-shared relocatable dynamic
>>> binary which means that I really don't want to use -fPIC and I was
>>> hoping that the dynamic linker would be able to finish relocating the
>>> final binary. Is this impossible on linux-elf-x86-64 ?
>> Yes, it is.  The fact that this works on 32-bit is something of an
>> historical accident.
> 
> I would reverse the sense of this: non PIC shared libraries does work on
> most processors (with some loss of efficiency), but not on x86_64
> because it uses a small model by default.  It might work if you use
> -mcmodel=large, but I haven't tried this.

It might well, but I would question the point.  Presumably the OP wants
non-PIC for performance's sake, but I wouldn't have thought he's going
to get it from the large model.  Benchmarks would be interesting.

Andrew.



More information about the Gcc-help mailing list