Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Shared objects+global variables?
@ 2002-11-14  3:21 Kelledin
  2002-11-14  6:55 ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Kelledin @ 2002-11-14  3:21 UTC (permalink / raw)
  To: axp-list

I recently ran into some problems compiling Linux-PAM, and I've 
traced it back to a deficiency in the current GNU toolchain for 
alpha (gcc-3.2, glibc-2.2.5, binutils-2.13).  Apparently, a 
shared object is not permitted to reference its own global 
variables; whenever I try to compile a library that does this, 
ld complains about "gp-relative relocations" and refuses to 
link.

Is this normal on alpha platforms?  It's most certainly not 
normal on x86...

-- 
Kelledin
"If a server crashes in a server farm and no one pings it, does 
it still cost four figures to fix?"




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Shared objects+global variables?
  2002-11-14  3:21 Shared objects+global variables? Kelledin
@ 2002-11-14  6:55 ` Richard Henderson
  2002-11-14 12:56   ` Kelledin
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2002-11-14  6:55 UTC (permalink / raw)
  To: axp-list

On Wed, Nov 13, 2002 at 10:21:28PM -0500, Kelledin wrote:
> ... whenever I try to compile a library that does this, 
> ld complains about "gp-relative relocations" and refuses to link.

You MUST use -fpic or -fPIC.

> Is this normal on alpha platforms?

Yes.  And IA-64, and Sparc, and PPC, and ...

> It's most certainly not normal on x86...

They got lucky.


r~




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Shared objects+global variables?
  2002-11-14  6:55 ` Richard Henderson
@ 2002-11-14 12:56   ` Kelledin
  2002-11-14 13:11     ` Kelledin
  0 siblings, 1 reply; 5+ messages in thread
From: Kelledin @ 2002-11-14 12:56 UTC (permalink / raw)
  To: axp-list

On Thursday 14 November 2002 12:55 am, Richard Henderson wrote:
> On Wed, Nov 13, 2002 at 10:21:28PM -0500, Kelledin wrote:
> > ... whenever I try to compile a library that does this,
> > ld complains about "gp-relative relocations" and refuses to
> > link.
>
> You MUST use -fpic or -fPIC.

I did that, no luck; it was one of the first things I tried.  
Also tried -mno-explicit-relocs. =(  Now I'm starting to think 
binutils is responsible...

> > Is this normal on alpha platforms?
>
> Yes.  And IA-64, and Sparc, and PPC, and ...
>
> > It's most certainly not normal on x86...
>
> They got lucky.

I understand that -fPIC isn't quite so necessary on x86 (I still 
specify it anyways).  This global variable convention needs to 
be supported, seeing as common apps like Linux-PAM rely on it.

-- 
Kelledin
"If a server crashes in a server farm and no one pings it, does 
it still cost four figures to fix?"




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Shared objects+global variables?
  2002-11-14 12:56   ` Kelledin
@ 2002-11-14 13:11     ` Kelledin
  2002-11-14 21:37       ` Ted Goodridge
  0 siblings, 1 reply; 5+ messages in thread
From: Kelledin @ 2002-11-14 13:11 UTC (permalink / raw)
  To: axp-list

On Thursday 14 November 2002 06:56 am, Kelledin wrote:
> On Thursday 14 November 2002 12:55 am, Richard Henderson wrote:
> > On Wed, Nov 13, 2002 at 10:21:28PM -0500, Kelledin wrote:
> > > ... whenever I try to compile a library that does this,
> > > ld complains about "gp-relative relocations" and refuses
> > > to link.
> >
> > You MUST use -fpic or -fPIC.
>
> I did that, no luck; it was one of the first things I tried.
> Also tried -mno-explicit-relocs. =(  Now I'm starting to think
> binutils is responsible...

Ummm.  Well...

It works now.  I'm not exactly sure why, but recompiling gcc 
seemed to fix the problem.  I wish I knew how that happened...

-- 
Kelledin
"If a server crashes in a server farm and no one pings it, does 
it still cost four figures to fix?"




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Shared objects+global variables?
  2002-11-14 13:11     ` Kelledin
@ 2002-11-14 21:37       ` Ted Goodridge
  0 siblings, 0 replies; 5+ messages in thread
From: Ted Goodridge @ 2002-11-14 21:37 UTC (permalink / raw)
  To: axp-list, Kelledin

> > > > ... whenever I try to compile a library that does this,
> > > > ld complains about "gp-relative relocations" and refuses
> > > > to link.
> > >
> > > You MUST use -fpic or -fPIC.
> >

<snip>

> Ummm.  Well...
>
> It works now.  I'm not exactly sure why, but recompiling gcc
> seemed to fix the problem.  I wish I knew how that happened...

So you recompiled GCC with -fPIC (from LFS), then you were able to compile 
Glib without problems? or is this related to another package?

Ted




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-11-14 21:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-14  3:21 Shared objects+global variables? Kelledin
2002-11-14  6:55 ` Richard Henderson
2002-11-14 12:56   ` Kelledin
2002-11-14 13:11     ` Kelledin
2002-11-14 21:37       ` Ted Goodridge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox