Subject: Re: kern/21844: netwinder kernal cannot be linked because link_set_* sections overlap with .data
To: None <uwe@netbsd.org>
From: Jason Thorpe <thorpej@wasabisystems.com>
List: tech-toolchain
Date: 06/10/2003 19:38:56
On Tuesday, June 10, 2003, at 02:12  PM, uwe@netbsd.org 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.

>
>   . = ALIGN(0x8000);
>   .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.

         -- Jason R. Thorpe <thorpej@wasabisystems.com>