* building non-shared dynamic binaries on x86-64 linux-elf
@ 2009-04-22 11:57 Mathieu Lacage
2009-04-22 12:00 ` Andrew Haley
0 siblings, 1 reply; 7+ messages in thread
From: Mathieu Lacage @ 2009-04-22 11:57 UTC (permalink / raw)
To: gcc-help
hi,
The title pretty much says what I am trying to do: this works fine on
i386 but fails on x86-64. The compile-time error is:
"relocation R_X86_64_32 against `a local symbol' can not be used when
making a shared object; recompile with -fPIC".
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 ?
Mathieu
--
Mathieu Lacage <mathieu.lacage@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: building non-shared dynamic binaries on x86-64 linux-elf
2009-04-22 11:57 building non-shared dynamic binaries on x86-64 linux-elf Mathieu Lacage
@ 2009-04-22 12:00 ` Andrew Haley
2009-04-22 13:32 ` Ian Lance Taylor
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Haley @ 2009-04-22 12:00 UTC (permalink / raw)
To: Mathieu Lacage; +Cc: gcc-help
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.
Andrew.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: building non-shared dynamic binaries on x86-64 linux-elf
2009-04-22 12:00 ` Andrew Haley
@ 2009-04-22 13:32 ` Ian Lance Taylor
2009-04-22 14:44 ` Mathieu Lacage
2009-04-22 14:53 ` Andrew Haley
0 siblings, 2 replies; 7+ messages in thread
From: Ian Lance Taylor @ 2009-04-22 13:32 UTC (permalink / raw)
To: Andrew Haley; +Cc: Mathieu Lacage, gcc-help
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.
Ian
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: building non-shared dynamic binaries on x86-64 linux-elf
2009-04-22 13:32 ` Ian Lance Taylor
@ 2009-04-22 14:44 ` Mathieu Lacage
2009-04-22 14:51 ` Ian Lance Taylor
2009-04-22 14:53 ` Andrew Haley
1 sibling, 1 reply; 7+ messages in thread
From: Mathieu Lacage @ 2009-04-22 14:44 UTC (permalink / raw)
To: gcc-help
On Wed, Apr 22, 2009 at 3:32 PM, Ian Lance Taylor <iant@google.com> wrote:
> 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 does, indeed appear to work: it merely triggers an ICE for FC10's
(4.3.2) gcc with -O3 (-O0 works fine). gcc 4.4.0 works fine though.
Shall I report a bug for 4.3.2 ? (i.e., will there be further releases
of that compiler ?)
Mathieu
--
Mathieu Lacage <mathieu.lacage@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: building non-shared dynamic binaries on x86-64 linux-elf
2009-04-22 14:44 ` Mathieu Lacage
@ 2009-04-22 14:51 ` Ian Lance Taylor
0 siblings, 0 replies; 7+ messages in thread
From: Ian Lance Taylor @ 2009-04-22 14:51 UTC (permalink / raw)
To: Mathieu Lacage; +Cc: gcc-help
Mathieu Lacage <mathieu.lacage@gmail.com> writes:
> On Wed, Apr 22, 2009 at 3:32 PM, Ian Lance Taylor <iant@google.com> wrote:
>
>> 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 does, indeed appear to work: it merely triggers an ICE for FC10's
> (4.3.2) gcc with -O3 (-O0 works fine). gcc 4.4.0 works fine though.
>
> Shall I report a bug for 4.3.2 ? (i.e., will there be further releases
> of that compiler ?)
It is likely that there will be a 4.3.3 release. However, even if you
file a bug report, I wouldn't count on anybody actually fixing it,
unless perhaps you also track down the change that fixed it in 4.4.0. I
don't think that huge model support is high on anybody's priority list.
Ian
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: building non-shared dynamic binaries on x86-64 linux-elf
2009-04-22 13:32 ` Ian Lance Taylor
2009-04-22 14:44 ` Mathieu Lacage
@ 2009-04-22 14:53 ` Andrew Haley
2009-04-22 15:20 ` Mathieu Lacage
1 sibling, 1 reply; 7+ messages in thread
From: Andrew Haley @ 2009-04-22 14:53 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: Mathieu Lacage, gcc-help
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: building non-shared dynamic binaries on x86-64 linux-elf
2009-04-22 14:53 ` Andrew Haley
@ 2009-04-22 15:20 ` Mathieu Lacage
0 siblings, 0 replies; 7+ messages in thread
From: Mathieu Lacage @ 2009-04-22 15:20 UTC (permalink / raw)
To: Andrew Haley; +Cc: Ian Lance Taylor, gcc-help
On Wed, Apr 22, 2009 at 4:53 PM, Andrew Haley <aph@redhat.com> wrote:
>> 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.
I did get some of the performance improvement I was after, at least on
my reference microbenchmark (which, I hope, is at least partly
representative of my target application):
-O3 -fpic:
a=1.70445e+06 packets/s
b=3.4965e+06 packets/s
c=2.20897e+06 packets/s
d=894214 packets/s
-O3 -mcmodel=large:
a=1.96967e+06 packets/s
b=3.77216e+06 packets/s
c=2.45881e+06 packets/s
d=1.07423e+06 packets/s
-O3 [static link in final executable]:
a=2.12857e+06 packets/s
b=4.26076e+06 packets/s
c=2.77546e+06 packets/s
d=1.27861e+06 packets/s
So, a full static link is best, but -mcmodel=large is still better
than -fpic. I wonder if I am not going to ditch -fpic builds
altogether.
Mathieu
--
Mathieu Lacage <mathieu.lacage@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-04-22 15:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-22 11:57 building non-shared dynamic binaries on x86-64 linux-elf Mathieu Lacage
2009-04-22 12:00 ` Andrew Haley
2009-04-22 13:32 ` Ian Lance Taylor
2009-04-22 14:44 ` Mathieu Lacage
2009-04-22 14:51 ` Ian Lance Taylor
2009-04-22 14:53 ` Andrew Haley
2009-04-22 15:20 ` Mathieu Lacage
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).