public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [Linux-ia64] [patch] Assign __gp to middle of short data sections
@ 2002-08-01  3:17 Keith Owens
  2002-08-01  4:01 ` [Linux-ia64] [patch] Assign __gp to middle of short data sect Luck, Tony
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Keith Owens @ 2002-08-01  3:17 UTC (permalink / raw)
  To: linux-ia64

I was getting '__gp does not cover short data segment'.
arch/ia64/vmlinus.lds.S assigns __gp well away from the short data
sections, for no good reason that I can see.  A kernel with more than
2^21 bytes between __gp and the end of sbss cannot link.

This patch (against 2.4.18) puts __gp right in the middle of the short
data sections.  The comment 'gp must be 16-byte aligned for exc. table'
puzzles me, AFAICT the exception tables are not accessed via gp.

Index: 19-pre10.10/arch/ia64/vmlinux.lds.S
--- 19-pre10.10/arch/ia64/vmlinux.lds.S Thu, 09 May 2002 12:00:25 +1000 kaos (linux-2.4/p/c/50_vmlinux.ld 1.1.5.1.2.1.1.1.1.2 644)
+++ 19-pre10.10(w)/arch/ia64/vmlinux.lds.S Thu, 01 Aug 2002 13:09:02 +1000 kaos (linux-2.4/p/c/50_vmlinux.ld 1.1.5.1.2.1.1.1.1.2 644)
@@ -40,8 +40,6 @@ SECTIONS
 
   /* Read-only data */
 
-  __gp = ALIGN(16) + 0x200000;	/* gp must be 16-byte aligned for exc. table */
-
   /* Global data */
   _data = .;
 
@@ -130,6 +128,7 @@ SECTIONS
   .data : AT(ADDR(.data) - PAGE_OFFSET)
 	{ *(.data) *(.gnu.linkonce.d*) CONSTRUCTORS }
 
+  __got = ALIGN(16);
   .got : AT(ADDR(.got) - PAGE_OFFSET)
 	{ *(.got.plt) *(.got) }
   /* We want the small data sections together, so single-instruction offsets
@@ -141,6 +140,7 @@ SECTIONS
   _bss = .;
   .sbss : AT(ADDR(.sbss) - PAGE_OFFSET)
 	{ *(.sbss) *(.scommon) }
+  __gp = (. - (. - __got) / 2) & -16;	/* put __gp in the middle of the short data areas */
   .bss : AT(ADDR(.bss) - PAGE_OFFSET)
 	{ *(.bss) *(COMMON) }
   . = ALIGN(64 / 8);



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

* RE: [Linux-ia64] [patch] Assign __gp to middle of short data sect
  2002-08-01  3:17 [Linux-ia64] [patch] Assign __gp to middle of short data sections Keith Owens
@ 2002-08-01  4:01 ` Luck, Tony
  2002-08-01  4:10 ` [Linux-ia64] [patch] Assign __gp to middle of short data sections David Mosberger
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Luck, Tony @ 2002-08-01  4:01 UTC (permalink / raw)
  To: linux-ia64

From: Keith Owens [mailto:kaos@ocs.com.au]

> I was getting '__gp does not cover short data segment'.
> arch/ia64/vmlinus.lds.S assigns __gp well away from the short data
> sections, for no good reason that I can see.  A kernel with more than
> 2^21 bytes between __gp and the end of sbss cannot link.
>
> This patch (against 2.4.18) puts __gp right in the middle of the short
> data sections.  The comment 'gp must be 16-byte aligned for exc. table'
> puzzles me, AFAICT the exception tables are not accessed via gp.

Look at include/asm-ia64/uaccess.h ... all the exception table entries
use gp relative addressing.

-Tony


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

* Re: [Linux-ia64] [patch] Assign __gp to middle of short data sections
  2002-08-01  3:17 [Linux-ia64] [patch] Assign __gp to middle of short data sections Keith Owens
  2002-08-01  4:01 ` [Linux-ia64] [patch] Assign __gp to middle of short data sect Luck, Tony
@ 2002-08-01  4:10 ` David Mosberger
  2002-08-01  6:00 ` Keith Owens
  2002-08-01  6:26 ` David Mosberger
  3 siblings, 0 replies; 5+ messages in thread
From: David Mosberger @ 2002-08-01  4:10 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Thu, 01 Aug 2002 13:17:25 +1000, Keith Owens <kaos@ocs.com.au> said:

  Keith> I was getting '__gp does not cover short data segment'.
  Keith> arch/ia64/vmlinus.lds.S assigns __gp well away from the short
  Keith> data sections, for no good reason that I can see.  A kernel
  Keith> with more than 2^21 bytes between __gp and the end of sbss
  Keith> cannot link.

  Keith> This patch (against 2.4.18) puts __gp right in the middle of
  Keith> the short data sections.

Umh, the got must be covered by the __gp too!

The real problem that you were seeing is that the (old) linker script
aligned __gp, but not the section it was pointing to.  If the previous
section ended on an address that was not 16-byte aligned, this would
have the effect of putting the first word in the got out of reach.  I
fixed this bug a while ago (about two 2.4.18 patches ago, IIRC).  The
corrected version reads like this:

  . = ALIGN(16);
  __gp = . + 0x200000;	/* gp must be 16-byte aligned for exc. table */

  Keith> The comment 'gp must be 16-byte
  Keith> aligned for exc. table' puzzles me, AFAICT the exception
  Keith> tables are not accessed via gp.

The addresses in the exception table are currently gp-relative (so
they fit in 32 bits), with the least-significant four bits reserved to
encode extra info (such as slot number).  If someone cares, this table
probably could be converted to use IP-relative addresses, in which
case this constraint could be dropped.

	--david


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

* Re: [Linux-ia64] [patch] Assign __gp to middle of short data sections
  2002-08-01  3:17 [Linux-ia64] [patch] Assign __gp to middle of short data sections Keith Owens
  2002-08-01  4:01 ` [Linux-ia64] [patch] Assign __gp to middle of short data sect Luck, Tony
  2002-08-01  4:10 ` [Linux-ia64] [patch] Assign __gp to middle of short data sections David Mosberger
@ 2002-08-01  6:00 ` Keith Owens
  2002-08-01  6:26 ` David Mosberger
  3 siblings, 0 replies; 5+ messages in thread
From: Keith Owens @ 2002-08-01  6:00 UTC (permalink / raw)
  To: linux-ia64

On Wed, 31 Jul 2002 21:10:40 -0700, 
David Mosberger <davidm@napali.hpl.hp.com> wrote:
>>>>>> On Thu, 01 Aug 2002 13:17:25 +1000, Keith Owens <kaos@ocs.com.au> said:
>
>  Keith> I was getting '__gp does not cover short data segment'.
>  Keith> arch/ia64/vmlinus.lds.S assigns __gp well away from the short
>  Keith> data sections, for no good reason that I can see.  A kernel
>  Keith> with more than 2^21 bytes between __gp and the end of sbss
>  Keith> cannot link.
>
>  Keith> This patch (against 2.4.18) puts __gp right in the middle of
>  Keith> the short data sections.
>
>Umh, the got must be covered by the __gp too!

@gprel() maps to instruction immediate22 which is a signed offset.  My
patch puts gp in the middle of the set { got, sdata, sbss }.  ld is
quite happy with that, it even tries to put gp in the middle of these
sections if you have not already defined __gp.

>The real problem that you were seeing is that the (old) linker script
>aligned __gp, but not the section it was pointing to.  If the previous
>section ended on an address that was not 16-byte aligned, this would
>have the effect of putting the first word in the got out of reach.  I
>fixed this bug a while ago (about two 2.4.18 patches ago, IIRC).  The
>corrected version reads like this:
>
>  . = ALIGN(16);
>  __gp = . + 0x200000;	/* gp must be 16-byte aligned for exc. table */

I tried that, same error, it is definitely a size problem.  With my
build, _data + 0x200000 (where __gp used to be) is e0000000049b7490,
got starts at e000000004ced170, a difference from gp of 0x335ce0 bytes.
imm22 can only do +/- 0x200000.

>  Keith> The comment 'gp must be 16-byte
>  Keith> aligned for exc. table' puzzles me, AFAICT the exception
>  Keith> tables are not accessed via gp.
>
>The addresses in the exception table are currently gp-relative (so
>they fit in 32 bits), with the least-significant four bits reserved to
>encode extra info (such as slot number).  If someone cares, this table
>probably could be converted to use IP-relative addresses, in which
>case this constraint could be dropped.

In that case __ex_table should be moved to the same place as got,
sdata, sbss.  As it stands, the gprel data is split with all the read
only data plus init code between them.  ld does not detect errors for
gprel in ex_table because __ex_table is not marked as short.



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

* Re: [Linux-ia64] [patch] Assign __gp to middle of short data sections
  2002-08-01  3:17 [Linux-ia64] [patch] Assign __gp to middle of short data sections Keith Owens
                   ` (2 preceding siblings ...)
  2002-08-01  6:00 ` Keith Owens
@ 2002-08-01  6:26 ` David Mosberger
  3 siblings, 0 replies; 5+ messages in thread
From: David Mosberger @ 2002-08-01  6:26 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Thu, 01 Aug 2002 16:00:39 +1000, Keith Owens <kaos@ocs.com.au> said:

  >> . = ALIGN(16); __gp = . + 0x200000; /* gp must be 16-byte aligned
  >> for exc. table */

  Keith> I tried that, same error, it is definitely a size problem.
  Keith> With my build, _data + 0x200000 (where __gp used to be) is
  Keith> e0000000049b7490, got starts at e000000004ced170, a
  Keith> difference from gp of 0x335ce0 bytes.  imm22 can only do +/-
  Keith> 0x200000.

Please try with the latest 2.4.18 patch---__gp *is* defined after
.data, not before.

  >>  The addresses in the exception table are currently gp-relative
  >> (so they fit in 32 bits), with the least-significant four bits
  >> reserved to encode extra info (such as slot number).  If someone
  >> cares, this table probably could be converted to use IP-relative
  >> addresses, in which case this constraint could be dropped.

  Keith> In that case __ex_table should be moved to the same place as
  Keith> got, sdata, sbss.  As it stands, the gprel data is split with
  Keith> all the read only data plus init code between them.  ld does
  Keith> not detect errors for gprel in ex_table because __ex_table is
  Keith> not marked as short.

No, the gp-relative values in the exception table are 32-bits wide;
there is no 22-bit limitation there.

	--david


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

end of thread, other threads:[~2002-08-01  6:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-01  3:17 [Linux-ia64] [patch] Assign __gp to middle of short data sections Keith Owens
2002-08-01  4:01 ` [Linux-ia64] [patch] Assign __gp to middle of short data sect Luck, Tony
2002-08-01  4:10 ` [Linux-ia64] [patch] Assign __gp to middle of short data sections David Mosberger
2002-08-01  6:00 ` Keith Owens
2002-08-01  6:26 ` David Mosberger

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