From f7df7167f0c54bd8da79dbf2d48bda5d7491fd32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Sun, 6 Oct 2024 08:45:04 +0000 Subject: Remove high memory kernel and needless prints --- arch/x86_64/scripts/kernel.ld | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'arch/x86_64/scripts') diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index 943266c..31d8be3 100644 --- a/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld @@ -3,7 +3,6 @@ ENTRY(_start) /***************************************************************************** * Virtual and linear start addresses of the TeachOS kernel *****************************************************************************/ -TEACHOS_HIGH = -2048M; TEACHOS_LOW = 1M; PHDRS { @@ -31,7 +30,7 @@ SECTIONS * symbols at the beginning. ***************************************************************************/ _start_linear = .; - _start_virtual = . + TEACHOS_HIGH; + _start_virtual = .; /*************************************************************************** * The bootstrapping infratructure goes first. We first place the read-only @@ -66,9 +65,8 @@ SECTIONS * also make sure to align the loaded data onto a page boundary. ***************************************************************************/ . = ALIGN(4K); - . += TEACHOS_HIGH; - .init ALIGN(4K) : AT(ADDR (.init) - TEACHOS_HIGH) + .init ALIGN(4K) : AT(ADDR (.init)) { /* * Make sure that the crt code is wrapped around the compiler generated @@ -79,7 +77,7 @@ SECTIONS KEEP(*crtn.s.o*(.init)) } :text - .fini ALIGN(4K) : AT(ADDR (.fini) - TEACHOS_HIGH) + .fini ALIGN(4K) : AT(ADDR (.fini)) { /* * Make sure that the crt code is wrapped around the compiler generated @@ -90,18 +88,18 @@ SECTIONS KEEP(*crtn.s.o*(.fini)) } - .text ALIGN(4K) : AT(ADDR (.text) - TEACHOS_HIGH) + .text ALIGN(4K) : AT(ADDR (.text)) { *(.text*) } - .rodata ALIGN(4K) : AT (ADDR (.rodata) - TEACHOS_HIGH) + .rodata ALIGN(4K) : AT (ADDR (.rodata)) { *(.rodata) *(.rodata.*) } :rodata - .ctors ALIGN(4K) : AT (ADDR (.ctors) - TEACHOS_HIGH) + .ctors ALIGN(4K) : AT (ADDR (.ctors)) { KEEP(*crtbegin.o(.ctors)) KEEP(*(EXCLUDE_FILE (*crtend.o) .ctors)) @@ -109,7 +107,7 @@ SECTIONS KEEP(*crtend.o(.ctors)) } :data - .dtors ALIGN(4K) : AT (ADDR (.dtors) - TEACHOS_HIGH) + .dtors ALIGN(4K) : AT (ADDR (.dtors)) { KEEP(*crtbegin.o(.dtors)) KEEP(*(EXCLUDE_FILE (*crtend.o) .dtors)) @@ -117,12 +115,12 @@ SECTIONS KEEP(*crtend.o(.dtors)) } - .data ALIGN(4K) : AT (ADDR (.data) - TEACHOS_HIGH) + .data ALIGN(4K) : AT (ADDR (.data)) { *(.data*) } - .bss ALIGN(4K) : AT (ADDR (.bss) - TEACHOS_HIGH) + .bss ALIGN(4K) : AT (ADDR (.bss)) { *(COMMON) *(.bss*) @@ -133,7 +131,7 @@ SECTIONS * symbols to mark the end of our loaded image. ***************************************************************************/ _end_virtual = ADDR(.bss) + SIZEOF(.bss); - _end_linear = _end_virtual - TEACHOS_HIGH; + _end_linear = _end_virtual; /DISCARD/ : { *(.comment) } } -- cgit v1.2.3 From c2c7503fec31c07645fdc087dbf1ef487e90912e Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Sat, 26 Oct 2024 07:03:01 +0000 Subject: fix mmap type, adjust linker, use std::array --- arch/x86_64/scripts/kernel.ld | 3 +++ 1 file changed, 3 insertions(+) (limited to 'arch/x86_64/scripts') diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index 31d8be3..c777d10 100644 --- a/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld @@ -59,6 +59,9 @@ SECTIONS *(.boot_stack) } + . = ALIGN(4K); + _end_of_image = .; + /*************************************************************************** * Now it is time to load the 64-bit kernel code. We virtually load it into * the upper 2GiB, while adjusting the linear load address appropriately. We -- cgit v1.2.3 From b00ec1f863e330d2c4ae1d1ef4d352ab73861f17 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Sat, 26 Oct 2024 07:47:27 +0000 Subject: move paging alignment --- arch/x86_64/scripts/kernel.ld | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'arch/x86_64/scripts') diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index c777d10..e244ce1 100644 --- a/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld @@ -59,9 +59,6 @@ SECTIONS *(.boot_stack) } - . = ALIGN(4K); - _end_of_image = .; - /*************************************************************************** * Now it is time to load the 64-bit kernel code. We virtually load it into * the upper 2GiB, while adjusting the linear load address appropriately. We @@ -129,6 +126,9 @@ SECTIONS *(.bss*) } + . = ALIGN(4K); + _end_of_image = .; + /*************************************************************************** * In accordance with the symbol definitions at the start, we generate some * symbols to mark the end of our loaded image. -- cgit v1.2.3 From bca36b0c10fcae447c90e211e83987fea28eecdc Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Sat, 26 Oct 2024 08:47:26 +0000 Subject: wip --- arch/x86_64/scripts/kernel.ld | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'arch/x86_64/scripts') diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index e244ce1..3449828 100644 --- a/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld @@ -59,13 +59,14 @@ SECTIONS *(.boot_stack) } + . = ALIGN(4K); + _end_of_image = .; + /*************************************************************************** * Now it is time to load the 64-bit kernel code. We virtually load it into * the upper 2GiB, while adjusting the linear load address appropriately. We * also make sure to align the loaded data onto a page boundary. ***************************************************************************/ - . = ALIGN(4K); - .init ALIGN(4K) : AT(ADDR (.init)) { /* @@ -126,9 +127,6 @@ SECTIONS *(.bss*) } - . = ALIGN(4K); - _end_of_image = .; - /*************************************************************************** * In accordance with the symbol definitions at the start, we generate some * symbols to mark the end of our loaded image. -- cgit v1.2.3 From d971ee4dd26d928d9590ccbf8e39220d81787a98 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Sun, 3 Nov 2024 13:22:34 +0000 Subject: align elf sections to 4kb --- arch/x86_64/scripts/kernel.ld | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'arch/x86_64/scripts') diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index 3449828..e9d245f 100644 --- a/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld @@ -37,31 +37,28 @@ SECTIONS * data, followed by our code, initialized mutable data, and finally our * uninitialized mutable data. ***************************************************************************/ - .boot_rodata : + .boot_rodata ALIGN(4K) : AT(ADDR (.boot_rodata)) { KEEP(*(.boot_mbh)) *(.boot_rodata) } :boot_rodata - .boot_text : + .boot_text ALIGN(4K) : AT(ADDR (.boot_text)) { *(.boot_text) } :boot_text - .boot_data : + .boot_data ALIGN(4K) : AT(ADDR (.boot_data)) { *(.boot_data) } :boot_data - .boot_bss : + .boot_bss ALIGN(4K) : AT(ADDR (.boot_bss)) { *(.boot_bss) *(.boot_stack) } - . = ALIGN(4K); - _end_of_image = .; - /*************************************************************************** * Now it is time to load the 64-bit kernel code. We virtually load it into * the upper 2GiB, while adjusting the linear load address appropriately. We -- cgit v1.2.3 From 55f32173e97fdcf4a45006b66cc4b20329a5c7af Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Sun, 24 Nov 2024 13:10:21 +0000 Subject: implement basic heap and remap it --- arch/x86_64/scripts/kernel.ld | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'arch/x86_64/scripts') diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index e9d245f..c3eea9c 100644 --- a/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld @@ -60,9 +60,8 @@ SECTIONS } /*************************************************************************** - * Now it is time to load the 64-bit kernel code. We virtually load it into - * the upper 2GiB, while adjusting the linear load address appropriately. We - * also make sure to align the loaded data onto a page boundary. + * Now it is time to load the 64-bit kernel code. We + * make sure to align the loaded data onto a page boundary. ***************************************************************************/ .init ALIGN(4K) : AT(ADDR (.init)) { -- cgit v1.2.3 From c1e7edabc1dfbe387546297720fc495837d38d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matteo=20Gm=C3=BCr?= Date: Sun, 1 Dec 2024 09:46:37 +0000 Subject: Fix guard page and ensure it crashes even if guard page is skipped altogether --- arch/x86_64/scripts/kernel.ld | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'arch/x86_64/scripts') diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index c3eea9c..cc07896 100644 --- a/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld @@ -48,17 +48,17 @@ SECTIONS *(.boot_text) } :boot_text - .boot_data ALIGN(4K) : AT(ADDR (.boot_data)) - { - *(.boot_data) - } :boot_data - .boot_bss ALIGN(4K) : AT(ADDR (.boot_bss)) { *(.boot_bss) *(.boot_stack) } + .boot_data ALIGN(4K) : AT(ADDR (.boot_data)) + { + *(.boot_data) + } :boot_data + /*************************************************************************** * Now it is time to load the 64-bit kernel code. We * make sure to align the loaded data onto a page boundary. @@ -112,17 +112,17 @@ SECTIONS KEEP(*crtend.o(.dtors)) } - .data ALIGN(4K) : AT (ADDR (.data)) - { - *(.data*) - } - .bss ALIGN(4K) : AT (ADDR (.bss)) { *(COMMON) *(.bss*) } + .data ALIGN(4K) : AT (ADDR (.data)) + { + *(.data*) + } + /*************************************************************************** * In accordance with the symbol definitions at the start, we generate some * symbols to mark the end of our loaded image. -- cgit v1.2.3