public inbox for binutils@sourceware.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:48         ` 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:54             ` 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:48         ` 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:48 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:48         ` 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:54             ` 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:54 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:54             ` H . J . Lu
@ 2001-09-17 15:56               ` Richard Henderson
  2001-09-17 16:07                 ` 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:54             ` H . J . Lu
  2001-09-17 15:56               ` Richard Henderson
@ 2001-09-17 15:57               ` Jakub Jelinek
       [not found]                 ` <200109181332.f8IDWXK10307@quatramaran.ens.fr>
  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:07                 ` H . J . Lu
  0 siblings, 0 replies; 13+ messages in thread
From: H . J . Lu @ 2001-09-17 16:07 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
       [not found]                   ` <20010918100235.B31128@redhat.com>
@ 2001-09-18 10:18                     ` Jakub Jelinek
  2001-09-18 11:16                       ` Marc Espie
  0 siblings, 1 reply; 13+ messages in thread
From: Jakub Jelinek @ 2001-09-18 10:18 UTC (permalink / raw)
  To: Richard Henderson, Marc Espie, binutils

On Tue, Sep 18, 2001 at 10:02:35AM -0700, Richard Henderson wrote:
> 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.

Nope, but it wouldn't be hard to add it if people think this is common
situation. It would probably require sparc elf_link_hash_table to keep track
on how many got entries are of which type, got.offset resp.
local_got_offsets could be assigned e.g. values | 2 for
GOT{10,22} relocs and they'd be translated once got was finalized.

	Jakub

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

* Re: linker problem: relocation truncated to fit
  2001-09-18 10:18                     ` Jakub Jelinek
@ 2001-09-18 11:16                       ` Marc Espie
  0 siblings, 0 replies; 13+ messages in thread
From: Marc Espie @ 2001-09-18 11:16 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Richard Henderson, binutils

On Tue, Sep 18, 2001 at 01:15:16PM -0400, Jakub Jelinek wrote:
> On Tue, Sep 18, 2001 at 10:02:35AM -0700, Richard Henderson wrote:
> > 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, but it wouldn't be hard to add it if people think this is common
> situation. It would probably require sparc elf_link_hash_table to keep track
> on how many got entries are of which type, got.offset resp.
> local_got_offsets could be assigned e.g. values | 2 for
> GOT{10,22} relocs and they'd be translated once got was finalized.

This could be fairly useful. For instance, you may wish to have a very common
part of a library compiled with -fpic, and the rest with -fPIC.

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

* Re: linker problem: relocation truncated to fit
  2001-09-17 15:48         ` 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:48         ` 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:54             ` H . J . Lu
2001-09-17 15:56               ` Richard Henderson
2001-09-17 16:07                 ` H . J . Lu
2001-09-17 15:57               ` Jakub Jelinek
     [not found]                 ` <200109181332.f8IDWXK10307@quatramaran.ens.fr>
     [not found]                   ` <20010918100235.B31128@redhat.com>
2001-09-18 10:18                     ` Jakub Jelinek
2001-09-18 11:16                       ` Marc Espie
2001-09-17 15:48         ` 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).