Subject: Re: kern/21844: netwinder kernal cannot be linked because link_set_* sections overlap with .data
To: Jason Thorpe <thorpej@wasabisystems.com>
From: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
List: tech-toolchain
Date: 06/12/2003 01:12:55
On Tue, Jun 10, 2003 at 19:38:56 -0700, Jason Thorpe wrote:
> >The problem is that the kernel ld script for netwinder does not list
> >link_set_* sections, so they are transfered to the ld output as-is
> >after the .text section, however the kernel ld script explicitely
> >places .data section after the .text section with:
>
> I have certainly not seen this problem, and I know I've built/booted
> netwinder kernels recently. The linker should actually be sorting
> the link_set_ sections along with the .rodata section.
Should it? My readind of ld(1) docs is that the "orphaned" sections
are transferred from input to output as-is.
> > .data :
> > AT ((LOADADDR(.text) + SIZEOF(.text) + (0x8000 - 1)) & ~(0x8000 - 1))
> > { ... }
> >
> >if sizes of .text section and link_set_* section are such that there
> >is not enough room for the link_set_* sections in the last page
> >occupied by the .text section, the link_set_* section will be
> >overlapped by the .data section b/c of the explicit .data section
> >placement
>
> ...oh, right, SIZEOF(). "Nice." This is a problem with the use of
> SIZEOF(); it cannot be safely used when orphan sections (like link_set)
> are in use. I submitted a patch to "fix" it to the FSF, but it was
> rejected, so I implemented a different strategy for the evbarm port...
>
> Take a look at evbarm/conf/ldscript.evbarm -- it should have the hints
> you need to fix the netwinder script.
Oh, that helps. Is that a correct change:
. = ALIGN(0x8000);
.data :
- AT ((LOADADDR(.text) + SIZEOF(.text) + (0x8000 - 1)) & ~(0x8000 - 1))
+ AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text)))
I think the preceding ALIGN is enough to avoid the bit-masking dance
of the old version (and the resulting kernel correctly places the
.data), but just to be sure...
Thanks.
SY, Uwe
--
uwe@ptc.spbu.ru | Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/ | Ist zu Grunde gehen