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.

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