Subject: Re: Adding Multiboot support (or not)
To: None <tech-kern@netbsd.org, port-i386@netbsd.org>
From: Pavel Cahyna <pavel@netbsd.org>
List: tech-kern
Date: 05/19/2006 11:44:03
--jI8keyz6grp/JLjh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sat, May 13, 2006 at 08:20:45AM -0700, Jason Thorpe wrote:
> 
> On May 3, 2006, at 6:30 AM, Pavel Cahyna wrote:
> 
> >Is it appropriate to commit it? I see that the current ldscript for i386
> >is very different, it has many things which apparently make sense only for
> >userland.
> 
> Looks good.

I made a (hopefully) final version, as I noticed there are some
differences in the output. The PROVIDEs are now the same as in the current
version, as is the alignement of .data . (This alignment saves about 1kB
of the output file size.) The differences in output compare to the current
version now are (except the correct paddr):

- .text is merged with .rodata

- the symbol "etext" points after the .text section, before all the
  .rodata.str* and link_set* sections . Originally it pointed after the
  link_set* sections.

I guess this is harmless.

Comments?

--jI8keyz6grp/JLjh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kern.ldscript"

/*	$NetBSD$	*/

OUTPUT_FORMAT("elf32-i386", "elf32-i386",
	      "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS
{
   /* Read-only sections, merged into text segment: */
   .text :
   AT (ADDR(.text) & 0x0fffffff)
   {
     *(.text)
     *(.text.*)
     *(.stub)
     *(.rodata)
   } =0
   _etext = . ;
   PROVIDE (etext = .) ;

   /* Adjust the address for the data segment.  We want to adjust up to
      the same address within the page on the next page up.  */
   . = ALIGN(0x1000) + (. & (0x1000 - 1));
   .data :
   AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text)))
   {
     *(.data)
     *(.data.*)
   }
   _edata = . ;
   PROVIDE (edata = .) ;
   __bss_start = . ;
   .bss :
   AT (LOADADDR(.text) + (ADDR(.bss) - ADDR(.text)))
   {
     *(.bss)
     *(.bss.*)
     *(COMMON)
     . = ALIGN(32 / 8);
   }
   . = ALIGN(32 / 8);
  _end = . ;
  PROVIDE (end = .) ;
}

--jI8keyz6grp/JLjh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kern.ldscript.4MB"

/*	$NetBSD$	*/

OUTPUT_FORMAT("elf32-i386", "elf32-i386",
	      "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS
{
   /* Read-only sections, merged into text segment: */
   .text :
   AT (ADDR(.text) & 0x0fffffff)
   {
     *(.text)
     *(.text.*)
     *(.stub)
     *(.rodata)
   } =0
   _etext = . ;
   PROVIDE (etext = .) ;

   /* Adjust the address for the data segment.  We push the data segment
      up to the next 4MB boundary so that we can map the text with large
      pages. */
   . = ALIGN(0x400000);
   .data :
   AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text)))
   {
     *(.data)
     *(.data.*)
   }
   _edata = . ;
   PROVIDE (edata = .) ;
   __bss_start = . ;
   .bss :
   AT (LOADADDR(.text) + (ADDR(.bss) - ADDR(.text)))
   {
     *(.bss)
     *(.bss.*)
     *(COMMON)
     . = ALIGN(32 / 8);
   }
   . = ALIGN(32 / 8);
  _end = . ;
  PROVIDE (end = .) ;
}

--jI8keyz6grp/JLjh--