Map the kernel to the higher half

This commit is contained in:
2025-07-28 23:26:59 +02:00
parent 98010a17e3
commit eac9236e44
4 changed files with 224 additions and 193 deletions

View File

@@ -3,35 +3,45 @@ OUTPUT_FORMAT("elf32-littleriscv")
ENTRY(_entry)
PHDRS {
boot PT_LOAD FLAGS(5);
text PT_LOAD FLAGS(5);
data PT_LOAD FLAGS(6);
}
SECTIONS {
.text 0x80200000 : {
.text.boot 0x80200000 : {
KEEP(*(.text.boot));
. = ALIGN(CONSTANT(MAXPAGESIZE));
ASSERT(. - ADDR(.text.boot) == 0x1000, "error: stub larger than one page");
} :boot
_kernel_offset = 0x3fdff000;
.text 0xc0000000 : AT(ADDR(.text) - _kernel_offset) {
PROVIDE(__executable_start = . - _kernel_offset);
*(.text .text.*);
} :text
. = ALIGN(CONSTANT(MAXPAGESIZE));
PROVIDE(etext = .);
PROVIDE(etext = . - _kernel_offset);
.rodata : ALIGN(16) {
.rodata : AT(ADDR(.rodata) - _kernel_offset) ALIGN(16) {
*(.rodata .rodata.*);
}
.data : ALIGN(16) {
*(.data .data.*);
} :data
. = ALIGN(CONSTANT(MAXPAGESIZE));
PROVIDE(_data = . - _kernel_offset);
.bss : ALIGN(16) {
__bss = .;
.data : AT(ADDR(.data) - _kernel_offset) ALIGN(16) {
*(.data .data.*);
}
.bss (NOLOAD) : {
PROVIDE(__bss_start = . - _kernel_offset);
*(.bss .bss.* .sbss .sbss.*);
__bss_end = .;
}
. = ALIGN(CONSTANT(MAXPAGESIZE));
PROVIDE(end = .);
PROVIDE(end = . - _kernel_offset);
/DISCARD/ : {
*(.eh_frame)