kernel.ld: slight rewrite, use memory regions for ram instead of static offset

This commit is contained in:
Imbus 2025-09-06 00:54:38 +02:00
parent 6f5746a805
commit 57be90da84

View file

@ -1,14 +1,13 @@
OUTPUT_ARCH( "riscv" )
ENTRY( _entry ) /* See: entry.S */
MEMORY
{
RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 128M
}
SECTIONS
{
/*
* ensure that entry.S / _entry is at 0x80000000,
* where qemu's -kernel jumps.
*/
. = 0x80000000;
/*
* This section contains the code. This is, the machine language instructions
* that will be executed by the processor. In here we will find symbols
@ -35,7 +34,7 @@ SECTIONS
/* Define symbol etext to be the current location. */
PROVIDE(etext = .);
} :text
} > RAM :text
/*
* This contains any data that is marked as read only.
@ -47,7 +46,7 @@ SECTIONS
*(.srodata*) /* do not need to distinguish this from .rodata */
. = ALIGN(16);
*(.rodata*)
}
} > RAM
/*
* This section contains initialized global and static variables.
@ -58,7 +57,7 @@ SECTIONS
*(.sdata*) /* do not need to distinguish this from .data */
. = ALIGN(16);
*(.data*)
}
} > RAM
/*
* Contains all uninitialized global and static var iables. These are usually
@ -71,10 +70,12 @@ SECTIONS
*(.sbss*) /* do not need to distinguish this from .bss */
. = ALIGN(16);
*(.bss*)
}
} > RAM
/* Define symbol end as current location, note that this is not aligned, see vm.c */
PROVIDE(kernel_end = .);
PROVIDE(__heap_start = ALIGN(32));
PROVIDE(__heap_end = ORIGIN(RAM) + LENGTH(RAM));
}
PHDRS {