> Date: Fri, 26 Oct 2018 13:55:08 +0200
> From: Christian Weisgerber <[email protected]>
> 
> Move the calculation of the entry point to after the description
> of the .text section.  LOADADDR(.text) is not available earlier
> with lld.
> 
> With this, lld builds working kernels on i386.
> 
> Also: Should this be __start_phys?  It seems odd that we put a
> non-reserved symbol into the kernel namespace.  start_phys is not
> referenced anywhere by the kernel code and this is the only place
> it appears in the source tree.

Doesn't really matter for the kernel.

I wonder though whether we can simply replace ENTRY(start_phys) with
ENTRY(start) like we do on amd64.  The bootloader strips the high bits
from the entry point address already, so using the virtual address as
the entry point address should work.

> Index: sys/arch/i386/conf/ld.script
> ===================================================================
> RCS file: /cvs/src/sys/arch/i386/conf/ld.script,v
> retrieving revision 1.9
> diff -u -p -r1.9 ld.script
> --- sys/arch/i386/conf/ld.script      11 Apr 2018 15:44:08 -0000      1.9
> +++ sys/arch/i386/conf/ld.script      25 Oct 2018 20:35:18 -0000
> @@ -41,8 +41,6 @@ __ALIGN_SIZE = 0x1000;
>  __kernel_base_virt = 0xd0200000 + SIZEOF_HEADERS;
>  __kernel_base_phys = __kernel_base_virt & 0xfffffff;
>  
> -/* We use physical address to jump to kernel */
> -start_phys = LOADADDR(.text) + (start - __kernel_base_virt);
>  ENTRY(start_phys)
>  SECTIONS
>  {
> @@ -56,6 +54,8 @@ SECTIONS
>               locore0.o(.text)
>               *(.text .text.*)
>       } :text =0xcccccccc
> +     /* We use physical address to jump to kernel */
> +     start_phys = LOADADDR(.text) + (start - __kernel_base_virt);
>  
>       . = ALIGN(__ALIGN_SIZE);
>       __kernel_kutext_phys = . & 0xfffffff;
> -- 
> Christian "naddy" Weisgerber                          [email protected]
> 
> 

Reply via email to