Subject: Re: Adding Multiboot support (or not)
To: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
From: Pavel Cahyna <pavel.cahyna@st.mff.cuni.cz>
List: tech-kern
Date: 02/11/2006 22:30:40
--17pEHd4RhPHOinZp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sat, Feb 11, 2006 at 05:12:27PM +0300, Valeriy E. Ushakov wrote:
> Program Headers:
>   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>   LOAD           0x000000 0x00008000 0x00008000 0x040a8 0x040a8 R E 0x8000
>   LOAD           0x0040a8 0xf000c0a8 0x0000c0a8 0x277bac 0x277bac R E 0x8000
>   LOAD           0x280000 0xf0288000 0x00288000 0x86584 0x86584 RW  0x8000
>   LOAD           0x306584 0xf030e584 0xf030e584 0x00000 0x2b420 RW  0x8000
> 
>  Section to Segment mapping:
>   Segment Sections...
>    00     .start
>    01     .text link_set_malloc_types link_set_pools link_set_domains link_set_sysctl_funcs link_set_vfsops link_set_vfs_hooks link_set_evcnts link_set_dkwedge_methods link_set_bufq_strats
>    02     .data
>    03     .bss
> 
> 
> > I still don't see how do you indicate to the linker that the
> > link_set_* sections should start at a paddr different from vaddr.
> 
> My point was that linker will merge link_set_* sections with the .text
> and .rodata* sections (see the quotes from the ld.info the PR).

In my case it won't, unless I add an explicit statement for .rodata:

   .rodata    : 
   AT (LOADADDR(.text) + (ADDR(.rodata) - ADDR(.text)))
   { 
     *(.rodata)
   }

Then it works and boots as expected:
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x001000 0xc0100000 0x00100000 0x6423f3 0x6423f3 R E 0x1000
  LOAD           0x644000 0xc0743000 0x00743000 0x43610 0x91b74 RW  0x1000

 Section to Segment mapping:
  Segment Sections...
   00     .text .rodata.str1.1 .rodata.str1.32 link_set_malloc_types link_set_ieee80211_funcs link_set_sysctl_funcs link_set_domains link_set_pools link_set_vfsops link_set_vfs_hooks link_set_evcnts link_set_dkwedge_methods link_set_bufq_strats .rodata.str1.4 
   01     .data .bss 

The complete working ldscript is attached.

BTW in your output paddr of .bss is inconsistent with others. Is it
intended?

Pavel

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

ENTRY(KERNEL_BASE_phys)
SECTIONS
{
   KERNEL_BASE_phys = 0x00100000;
   KERNEL_BASE_virt = 0xc0100000;

   /* Read-only sections, merged into text segment: */
   .text (KERNEL_BASE_virt) :
   AT (KERNEL_BASE_phys)
   {
     *(.text)
     *(.text.*)
     *(.stub)
     *(.rodata)
   } =0
   .rodata    : 
   AT (LOADADDR(.text) + (ADDR(.rodata) - ADDR(.text)))
   { 
     *(.rodata)
   }
   PROVIDE (__etext = .);
   PROVIDE (_etext = .);
   PROVIDE (etext = .);

   /* Align the data segment to start on a page boundary. */
   . = ALIGN(0x1000);
   .data :
   AT (LOADADDR(.text) + (ADDR(.data) - ADDR(.text)))
   {
     __data_start = . ;
     *(.data)
     *(.data.*)
   }
   PROVIDE (_edata = .);
   PROVIDE (edata = .);
   __bss_start = . ;
   .bss :
   AT (LOADADDR(.text) + (ADDR(.bss) - ADDR(.text)))
   {
     *(.bss)
     *(.bss.*)
     *(COMMON)
     . = ALIGN(32 / 8);
   }
   . = ALIGN(32 / 8);
  PROVIDE (_end = .) ;
  PROVIDE (end = .) ;
}

--17pEHd4RhPHOinZp--