Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/riscv/conf Fixup kernel linking and provide a linke...



details:   https://anonhg.NetBSD.org/src/rev/963f5f7f7ef1
branches:  trunk
changeset: 1020989:963f5f7f7ef1
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sat May 01 07:13:21 2021 +0000

description:
Fixup kernel linking and provide a linker script with standard sections
and symbols

diffstat:

 sys/arch/riscv/conf/Makefile.riscv |  10 ++++++-
 sys/arch/riscv/conf/kern.ldscript  |  46 ++++++++++++++++++++++++++++---------
 2 files changed, 42 insertions(+), 14 deletions(-)

diffs (120 lines):

diff -r b7b45b418406 -r 963f5f7f7ef1 sys/arch/riscv/conf/Makefile.riscv
--- a/sys/arch/riscv/conf/Makefile.riscv        Sat May 01 07:11:12 2021 +0000
+++ b/sys/arch/riscv/conf/Makefile.riscv        Sat May 01 07:13:21 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.riscv,v 1.6 2020/03/14 16:12:15 skrll Exp $
+#      $NetBSD: Makefile.riscv,v 1.7 2021/05/01 07:13:21 skrll Exp $
 
 # Makefile for NetBSD
 #
@@ -74,11 +74,17 @@
 TEXTADDR?=             0xC0001000
 .endif
 KERNLDSCRIPT?=         ${RISCV}/conf/kern.ldscript
-LINKFORMAT+=           -T ${KERNLDSCRIPT}
 EXTRA_LINKFLAGS=       ${LDOPTS} --relax
 LINKFLAGS_NORMAL=      -X
 STRIPFLAGS=            -g -X
 
+# Set the physical load address (aka LMA) to the address that OpenSBI's
+# fw_jump jumps to.  This allows us to load the kernel with the -kernel flag
+# in QEMU without having to embed it inside BBL or OpenSBI's fw_payload first.
+#
+KERNEL_PHYS?=          0x80200000
+EXTRA_LINKFLAGS+=      --defsym='KERNEL_PHYS=${KERNEL_PHYS}'
+
 ##
 ## (6) port specific target dependencies
 ##
diff -r b7b45b418406 -r 963f5f7f7ef1 sys/arch/riscv/conf/kern.ldscript
--- a/sys/arch/riscv/conf/kern.ldscript Sat May 01 07:11:12 2021 +0000
+++ b/sys/arch/riscv/conf/kern.ldscript Sat May 01 07:13:21 2021 +0000
@@ -1,4 +1,6 @@
-/*     $NetBSD: kern.ldscript,v 1.7 2020/11/04 07:09:45 skrll Exp $    */
+/*     $NetBSD: kern.ldscript,v 1.8 2021/05/01 07:13:21 skrll Exp $    */
+
+#include "assym.h"
 
 OUTPUT_ARCH(riscv)
 ENTRY(start)
@@ -8,8 +10,10 @@
 
 SECTIONS
 {
-       .text : AT (ADDR(.text) & 0x0fffffff)
+
+       .text : AT (KERNEL_PHYS)
        {
+               PROVIDE(__kernel_text = .);
                *(.text)
                *(.text.*)
                *(.stub)
@@ -19,7 +23,7 @@
 
        . = ALIGN(__LARGE_PAGE_SIZE);
 
-       __rodata_start = . ;
+       PROVIDE(__rodata_start = .);
        .rodata :
        {
                *(.rodata)
@@ -28,17 +32,36 @@
                *(.srodata.*)
        }
 
+       PROVIDE(_etext = .);
+       PROVIDE(etext = .);
        . = ALIGN(__LARGE_PAGE_SIZE);
 
-       __data_start = . ;
        .data :
        {
+               PROVIDE(__data_start = .);
                *(.data)
+       }
+
+       . = ALIGN(COHERENCY_UNIT);
+       .data.cacheline_aligned :
+       {
+               *(.data.cacheline_aligned)
+       }
+       . = ALIGN(COHERENCY_UNIT);
+       .data.read_mostly :
+       {
+               *(.data.read_mostly)
+       }
+       . = ALIGN(COHERENCY_UNIT);
+
+       .sdata :
+       {
+               __global_pointer$ = . + 0x800;
                *(.sdata)
                *(.sdata.*)
        }
-       _edata = . ;
-       PROVIDE (edata = .) ;
+       _edata = .;
+       PROVIDE (edata = .);
 
        __bss_start = .;
        .bss :
@@ -50,14 +73,13 @@
                *(COMMON)
                . = ALIGN(__LARGE_PAGE_SIZE);
        }
-
+       _bss_end__ = . ;
+       __bss_end__ = . ;
        . = ALIGN(__PAGE_SIZE);
 
-       /* End of the kernel image */
-       __kernel_end = . ;
-
-       _end = . ;
-       PROVIDE (end = .) ;
+       __end__ = . ;
+       _end = .;
+       PROVIDE(end = .);
        .note.netbsd.ident :
        {
                KEEP(*(.note.netbsd.ident));



Home | Main Index | Thread Index | Old Index