public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: linker problem: relocation truncated to fit
       [not found]     ` <20010916153857.H22750@cyberhqz.com>
@ 2001-09-16 15:50       ` H . J . Lu
  2001-09-16 18:55         ` Ralf Baechle
                           ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: H . J . Lu @ 2001-09-16 15:50 UTC (permalink / raw)
  To: Ryan Murray; +Cc: linux-mips, binutils, gcc

On Sun, Sep 16, 2001 at 03:38:57PM -0700, Ryan Murray wrote:
> On Mon, Sep 17, 2001 at 12:07:19AM +0200, Petter Reinholdtsen wrote:
> > [Wilbern Cobb]
> > > This is a `feature' of the MIPS toolchain. Global and static items <= n
> > > bytes are placed into the small data or small bss sections instead of
> > > the normal data or bss sections as an optimization. Excess items would
> > > cause these linker errors.
> > > 
> > > Pass the compiler the -Gn flag (default is 8 bytes), ie. -G4 should work
> > > for most purposes.
> > 
> > I tried -G4, -G2 and -G1 without any luck.  Even with -G1 there are still
> 
> I don't think -G is the problem here.  The problem is that the GOT
> needs to be bigger than a 16 bit value.  The only way to do this is to
> recompile everything that is going to be linked in statically
> (libc_noshared.a and libgcc.a included) with -Wa,-xgot This problem
> currently affects openh323 and mozilla, among other things.
> 

I don't think mips is the only platform which has this problem. Do
Alpha, PowerPC and Sparc have similar problems like that? What are
the solutions for them?

BTW, it sounds like the -fpic vs. -fPIC issue. 


H.J.

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

* Re: linker problem: relocation truncated to fit
  2001-09-16 15:50       ` linker problem: relocation truncated to fit H . J . Lu
@ 2001-09-16 18:55         ` Ralf Baechle
  2001-09-17 15:41           ` Richard Henderson
  2001-09-17 15:47         ` Richard Henderson
  2001-09-26  3:08         ` Erik Corry
  2 siblings, 1 reply; 13+ messages in thread
From: Ralf Baechle @ 2001-09-16 18:55 UTC (permalink / raw)
  To: H . J . Lu; +Cc: Ryan Murray, linux-mips, binutils, gcc

On Sun, Sep 16, 2001 at 03:50:03PM -0700, H . J . Lu wrote:

> I don't think mips is the only platform which has this problem. Do
> Alpha, PowerPC and Sparc have similar problems like that? What are
> the solutions for them?
> 
> BTW, it sounds like the -fpic vs. -fPIC issue. 

It is.  Yet I wouldn't like to assign a different meaning to -fpic and
-fPIC as most makefiles make little difference between these two options,
so that would imply quite some overhead.

  Ralf

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

* Re: linker problem: relocation truncated to fit
  2001-09-16 18:55         ` Ralf Baechle
@ 2001-09-17 15:41           ` Richard Henderson
  2001-09-17 15:53             ` H . J . Lu
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Henderson @ 2001-09-17 15:41 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: H . J . Lu, Ryan Murray, linux-mips, binutils, gcc

On Mon, Sep 17, 2001 at 03:55:09AM +0200, Ralf Baechle wrote:
> It is.  Yet I wouldn't like to assign a different meaning to -fpic and
> -fPIC as most makefiles make little difference between these two options,
> so that would imply quite some overhead.

There is already such a difference.  Sparc uses 13-bit GOT offsets
with -fpic and 32-bit offsets with -fPIC.  I'm considering changes
to Alpha to use a 16/32 split for pic/PIC.


r~

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

* Re: linker problem: relocation truncated to fit
  2001-09-16 15:50       ` linker problem: relocation truncated to fit H . J . Lu
  2001-09-16 18:55         ` Ralf Baechle
@ 2001-09-17 15:47         ` Richard Henderson
  2001-09-17 15:52           ` Jakub Jelinek
  2001-09-20 15:33           ` Geoff Keating
  2001-09-26  3:08         ` Erik Corry
  2 siblings, 2 replies; 13+ messages in thread
From: Richard Henderson @ 2001-09-17 15:47 UTC (permalink / raw)
  To: H . J . Lu; +Cc: Ryan Murray, linux-mips, binutils, gcc

On Sun, Sep 16, 2001 at 03:50:03PM -0700, H . J . Lu wrote:
> I don't think mips is the only platform which has this problem. Do
> Alpha, PowerPC and Sparc have similar problems like that? What are
> the solutions for them?

Alpha has a complicated scheme by which every input object file may
be assigned to a different GOT, each of which is limited to 64k.  The
other reason this works is that variables assigned to .sdata/.sbss 
are _not_ treated differently wrt code generation.  Instead, this is
optimized via linker relaxation.

IA-64 will overflow its small data area at 22 bits.

PowerPC and Sparc do not use .sdata/.sbss.


r~

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

* Re: linker problem: relocation truncated to fit
  2001-09-17 15:47         ` Richard Henderson
@ 2001-09-17 15:52           ` Jakub Jelinek
  2001-09-20 15:33           ` Geoff Keating
  1 sibling, 0 replies; 13+ messages in thread
From: Jakub Jelinek @ 2001-09-17 15:52 UTC (permalink / raw)
  To: Richard Henderson, H . J . Lu, Ryan Murray, linux-mips, binutils, gcc

On Mon, Sep 17, 2001 at 03:47:54PM -0700, Richard Henderson wrote:
> PowerPC and Sparc do not use .sdata/.sbss.

Minor correction: PowerPC uses .sdata/.sbss, Sparc does not.

	Jakub

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

* Re: linker problem: relocation truncated to fit
  2001-09-17 15:41           ` Richard Henderson
@ 2001-09-17 15:53             ` H . J . Lu
  2001-09-17 15:56               ` Richard Henderson
  2001-09-17 15:57               ` Jakub Jelinek
  0 siblings, 2 replies; 13+ messages in thread
From: H . J . Lu @ 2001-09-17 15:53 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Ralf Baechle, Ryan Murray, linux-mips, binutils, gcc

On Mon, Sep 17, 2001 at 03:40:01PM -0700, Richard Henderson wrote:
> On Mon, Sep 17, 2001 at 03:55:09AM +0200, Ralf Baechle wrote:
> > It is.  Yet I wouldn't like to assign a different meaning to -fpic and
> > -fPIC as most makefiles make little difference between these two options,
> > so that would imply quite some overhead.
> 
> There is already such a difference.  Sparc uses 13-bit GOT offsets
> with -fpic and 32-bit offsets with -fPIC.  I'm considering changes
> to Alpha to use a 16/32 split for pic/PIC.

Can you mix object files compiled with -fPIC/-fpic on Sparc/Alpha?


H.J.

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

* Re: linker problem: relocation truncated to fit
  2001-09-17 15:53             ` H . J . Lu
@ 2001-09-17 15:56               ` Richard Henderson
  2001-09-17 16:06                 ` H . J . Lu
  2001-09-17 15:57               ` Jakub Jelinek
  1 sibling, 1 reply; 13+ messages in thread
From: Richard Henderson @ 2001-09-17 15:56 UTC (permalink / raw)
  To: H . J . Lu; +Cc: Ralf Baechle, Ryan Murray, linux-mips, binutils, gcc

On Mon, Sep 17, 2001 at 03:53:25PM -0700, H . J . Lu wrote:
> Can you mix object files compiled with -fPIC/-fpic on Sparc/Alpha?

Yes, but of course the total GOT/small data area is constrained
by the size allowed by -fpic.


r~

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

* Re: linker problem: relocation truncated to fit
  2001-09-17 15:53             ` H . J . Lu
  2001-09-17 15:56               ` Richard Henderson
@ 2001-09-17 15:57               ` Jakub Jelinek
  2001-09-18  6:33                 ` Marc Espie
  1 sibling, 1 reply; 13+ messages in thread
From: Jakub Jelinek @ 2001-09-17 15:57 UTC (permalink / raw)
  To: H . J . Lu
  Cc: Richard Henderson, Ralf Baechle, Ryan Murray, linux-mips, binutils, gcc

On Mon, Sep 17, 2001 at 03:53:25PM -0700, H . J . Lu wrote:
> Can you mix object files compiled with -fPIC/-fpic on Sparc/Alpha?

At least on the Sparc, you can mix them as you want, if you don't
overflow the signed 13bit relocs in -fpic objects. The linker will tell
you...

	Jakub

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

* Re: linker problem: relocation truncated to fit
  2001-09-17 15:56               ` Richard Henderson
@ 2001-09-17 16:06                 ` H . J . Lu
  0 siblings, 0 replies; 13+ messages in thread
From: H . J . Lu @ 2001-09-17 16:06 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Ralf Baechle, Ryan Murray, linux-mips, binutils, gcc

On Mon, Sep 17, 2001 at 03:56:16PM -0700, Richard Henderson wrote:
> On Mon, Sep 17, 2001 at 03:53:25PM -0700, H . J . Lu wrote:
> > Can you mix object files compiled with -fPIC/-fpic on Sparc/Alpha?
> 
> Yes, but of course the total GOT/small data area is constrained
> by the size allowed by -fpic.

It doesn't help much if you do need -fPIC on some Qt code. Since I
don't use Qt on mips, I will let others work on it.


H.J.

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

* Re: linker problem: relocation truncated to fit
  2001-09-17 15:57               ` Jakub Jelinek
@ 2001-09-18  6:33                 ` Marc Espie
  2001-09-18 10:02                   ` Richard Henderson
  0 siblings, 1 reply; 13+ messages in thread
From: Marc Espie @ 2001-09-18  6:33 UTC (permalink / raw)
  To: jakub; +Cc: gcc

In article < 20010918010107.G2189@sunsite.ms.mff.cuni.cz > you write:
>On Mon, Sep 17, 2001 at 03:53:25PM -0700, H . J . Lu wrote:
>> Can you mix object files compiled with -fPIC/-fpic on Sparc/Alpha?
>
>At least on the Sparc, you can mix them as you want, if you don't
>overflow the signed 13bit relocs in -fpic objects. The linker will tell
>you...

Depends on sparc linkers. Historically, some older linkers don't allow the
mix. This is usually easy to fix.  The next step would be to try and reorder
relocations so that the -fpic stuff is nearer the GOT. Then the -fPIC stuff
can overflow without harming the -fpic part.

Of course, I haven't checked the gnu linker recently. Maybe it already
implements that ?

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

* Re: linker problem: relocation truncated to fit
  2001-09-18  6:33                 ` Marc Espie
@ 2001-09-18 10:02                   ` Richard Henderson
  0 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2001-09-18 10:02 UTC (permalink / raw)
  To: Marc Espie; +Cc: jakub, gcc

On Tue, Sep 18, 2001 at 03:32:33PM +0200, Marc Espie wrote:
> The next step would be to try and reorder relocations so that the
> -fpic stuff is nearer the GOT. Then the -fPIC stuff can overflow
> without harming the -fpic part.
> 
> Of course, I haven't checked the gnu linker recently. Maybe it already
> implements that ?

Nope.


r~

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

* Re: linker problem: relocation truncated to fit
  2001-09-17 15:47         ` Richard Henderson
  2001-09-17 15:52           ` Jakub Jelinek
@ 2001-09-20 15:33           ` Geoff Keating
  1 sibling, 0 replies; 13+ messages in thread
From: Geoff Keating @ 2001-09-20 15:33 UTC (permalink / raw)
  To: rth; +Cc: hjl, rmurray, linux-mips, binutils, gcc

> Date: Mon, 17 Sep 2001 15:47:54 -0700
> From: Richard Henderson <rth@redhat.com>
> Cc: Ryan Murray <rmurray@cyberhqz.com>, linux-mips@oss.sgi.com,
>         binutils@sourceware.cygnus.com, gcc@gcc.gnu.org

> On Sun, Sep 16, 2001 at 03:50:03PM -0700, H . J . Lu wrote:
> > I don't think mips is the only platform which has this problem. Do
> > Alpha, PowerPC and Sparc have similar problems like that? What are
> > the solutions for them?
> 
> Alpha has a complicated scheme by which every input object file may
> be assigned to a different GOT, each of which is limited to 64k.  The
> other reason this works is that variables assigned to .sdata/.sbss 
> are _not_ treated differently wrt code generation.  Instead, this is
> optimized via linker relaxation.
> 
> IA-64 will overflow its small data area at 22 bits.
> 
> PowerPC and Sparc do not use .sdata/.sbss.

Actually, powerpc could use .sdata/.sbss for shared libraries, but it
never got implemented, and it would have the disadvantage that such
code can't be linked into non-shared objects.

It would be a significant speed/space win for certain objects, most
notably libm.

-- 
- Geoffrey Keating <geoffk@geoffk.org>

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

* Re: linker problem: relocation truncated to fit
  2001-09-16 15:50       ` linker problem: relocation truncated to fit H . J . Lu
  2001-09-16 18:55         ` Ralf Baechle
  2001-09-17 15:47         ` Richard Henderson
@ 2001-09-26  3:08         ` Erik Corry
  2 siblings, 0 replies; 13+ messages in thread
From: Erik Corry @ 2001-09-26  3:08 UTC (permalink / raw)
  To: H . J . Lu; +Cc: Ryan Murray, linux-mips, binutils, gcc

On Sun, Sep 16, 2001 at 03:50:03PM -0700, H . J . Lu wrote:
> > 
> > I don't think -G is the problem here.  The problem is that the GOT
> > needs to be bigger than a 16 bit value.  The only way to do this is to
> > recompile everything that is going to be linked in statically
> > (libc_noshared.a and libgcc.a included) with -Wa,-xgot This problem
> > currently affects openh323 and mozilla, among other things.

I think the current favoured solution on IRIX is multigot, where
if I understand correctly you switch GOT on some function calls 
in order to have multiple GOTs in one .o (or .so).

-- 
Erik Corry erik@arbat.com

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

end of thread, other threads:[~2001-09-26  3:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20010916091654.C1812@lucon.org>
     [not found] ` <Pine.BSO.4.33.0109161323280.14503-100000@oddbox.cn>
     [not found]   ` <20010917000719.B25531@false.linpro.no>
     [not found]     ` <20010916153857.H22750@cyberhqz.com>
2001-09-16 15:50       ` linker problem: relocation truncated to fit H . J . Lu
2001-09-16 18:55         ` Ralf Baechle
2001-09-17 15:41           ` Richard Henderson
2001-09-17 15:53             ` H . J . Lu
2001-09-17 15:56               ` Richard Henderson
2001-09-17 16:06                 ` H . J . Lu
2001-09-17 15:57               ` Jakub Jelinek
2001-09-18  6:33                 ` Marc Espie
2001-09-18 10:02                   ` Richard Henderson
2001-09-17 15:47         ` Richard Henderson
2001-09-17 15:52           ` Jakub Jelinek
2001-09-20 15:33           ` Geoff Keating
2001-09-26  3:08         ` Erik Corry

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).