From 39cd7d8aed9f604f2b03570d94cffee45df1451b Mon Sep 17 00:00:00 2001
From: =?utf8?q?Duje=20Mihanovi=C4=87?= <duje.mihanovic@skole.hr>
Date: Mon, 9 May 2022 16:41:31 +0200
Subject: [PATCH] Define start and end of each section

This is needed so the kernel knows what are all the memory ranges that need to
be mapped in the paging tables.
---
 kernel/linker.ld | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/kernel/linker.ld b/kernel/linker.ld
index 645a824..82f6e4a 100644
--- a/kernel/linker.ld
+++ b/kernel/linker.ld
@@ -6,11 +6,17 @@ SECTIONS
 	. = 0x100000;
 	__KERNEL_BASE__ = .;
 
-	.text : ALIGN(4K) { 
+	.text : ALIGN(4K) {
+		__TEXT_BASE__ = .;
 		kernel/entry.o (.text)
-		*(.text) 
+		*(.text)
+		__TEXT_END__ = .;
+	}
+	.rodata : ALIGN(4K) {
+		__RODATA_BASE__ = .;
+		*(.rodata)
+		__RODATA_END__ = .;
 	}
-	.rodata : ALIGN(4K) { *(.rodata) }
 
 	/* .rodata is put after .text so that the read-only entry in the program
 	 * header covers .rodata as well. When .rodata is after .data, that entry
@@ -21,12 +27,18 @@ SECTIONS
 	 * matter yet because we (currently) assume that the NX bit is not
 	 * supported anyway. */
 
-	.data : ALIGN(4K) { *(.data) }
-	.bss : ALIGN(4K) { 
+	.data : ALIGN(4K) {
+		__DATA_BASE__ = .;
+		*(.data)
+		__DATA_END__ = .;
+	}
+	.bss : ALIGN(4K) {
+		__BSS_BASE__ = .;
 		*(.bss)
 		/* Reserving 16KiB for the stack. A __STACK_TOP__ is not really
 		 * needed (yet). */
-		. += 16K; 
+		. += 16K;
 		__STACK_BOTTOM__ = .;
+		__BSS_END__ = .;
 	}
 }
-- 
2.39.5