diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2025-12-15 17:13:12 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2025-12-15 17:13:12 +0100 |
| commit | 7b9482ae637126ac9337876e60f519b493437711 (patch) | |
| tree | 6fc71a253c8b0325d303bd34c95b564ba536ed14 /arch/x86_64/scripts/kernel.ld | |
| parent | 116f9332a206767c45095950f09f7c7447b561cf (diff) | |
| parent | a9eeec745e29d89afd48ee43d09432eb6fc35be7 (diff) | |
| download | teachos-7b9482ae637126ac9337876e60f519b493437711.tar.xz teachos-7b9482ae637126ac9337876e60f519b493437711.zip | |
os: rework kernel architecture
Rework the code structure and architecture of the kernel by separating
platform-dependent and platform-independent code more cleanly. As of
this patchset, full feature parity has not been achieved. Nonetheless, a
sufficient subset of functionality has been ported to the new
architecture to demonstrate the feasibility of the new structure.
Diffstat (limited to 'arch/x86_64/scripts/kernel.ld')
| -rw-r--r-- | arch/x86_64/scripts/kernel.ld | 73 |
1 files changed, 28 insertions, 45 deletions
diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index 3d9a7ae..064b8d7 100644 --- a/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld @@ -3,7 +3,8 @@ ENTRY(_start) /***************************************************************************** * Virtual and linear start addresses of the TeachOS kernel *****************************************************************************/ -TEACHOS_LOW = 1M; +TEACHOS_PMA = 1M; +TEACHOS_VMA = 0xFFFFFFFF80000000; PHDRS { boot_rodata PT_LOAD FLAGS(4); @@ -22,15 +23,16 @@ SECTIONS * 32-Bit mode, so we want to live down low, but we need to leave the 1MiB * hole open since some BIOS functionality resides below it. ***************************************************************************/ - . = TEACHOS_LOW; + . = TEACHOS_PMA; /*************************************************************************** - * We want to be able to be able to access all memory (linear and virtual) + * We want to be able to be able to access all memory (physical and virtual) * during bootstrapping and operation. To achieve this, we define some * symbols at the beginning. ***************************************************************************/ - _start_linear = .; - _start_virtual = .; + _start_physical = .; + _start_virtual = . + TEACHOS_VMA; + /*************************************************************************** * The bootstrapping infratructure goes first. We first place the read-only @@ -63,78 +65,59 @@ SECTIONS * 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)) - { - /* - * Make sure that the crt code is wrapped around the compiler generated - * initialization code. - */ - KEEP(*crti.s.o*(.init)) - KEEP(*(EXCLUDE_FILE (*crti.s.o* *crtn.s.o*) .init)) - KEEP(*crtn.s.o*(.init)) - } :text - - .fini ALIGN(4K) : AT(ADDR (.fini)) - { - /* - * Make sure that the crt code is wrapped around the compiler generated - * finalizer code. - */ - KEEP(*crti.s.o*(.fini)) - KEEP(*(EXCLUDE_FILE (*crti.s.o* *crtn.s.o*) .fini)) - KEEP(*crtn.s.o*(.fini)) - } + . = ALIGN(4K); + . += TEACHOS_VMA; - .stl_text ALIGN(4K) : AT(ADDR (.stl_text)) + .stl_text ALIGN(4K) : AT(ADDR (.stl_text) - TEACHOS_VMA) { *(.stl_text .stl_text*) KEEP(*libstdc++.a:*(.text .text.*)) - } + } :text - .text ALIGN(4K) : AT(ADDR (.text)) + .text ALIGN(4K) : AT(ADDR (.text) - TEACHOS_VMA) { *(.text .text.*) } - .user_text ALIGN(4K) : AT(ADDR (.user_text)) + .user_text ALIGN(4K) : AT(ADDR (.user_text) - TEACHOS_VMA) { *(.user_text .user_text.*) } - .rodata ALIGN(4K) : AT (ADDR (.rodata)) + .rodata ALIGN(4K) : AT (ADDR (.rodata) - TEACHOS_VMA) { *(.rodata) *(.rodata.*) } :rodata - .ctors ALIGN(4K) : AT (ADDR (.ctors)) + .ctors ALIGN(4K) : AT (ADDR (.ctors) - TEACHOS_VMA) { - KEEP(*crtbegin.o(.ctors)) - KEEP(*(EXCLUDE_FILE (*crtend.o) .ctors)) + __ctors_start = .; KEEP(*(SORT(.ctors.*))) - KEEP(*crtend.o(.ctors)) + KEEP(*(.ctors)) + __ctors_end = .; } :data - .dtors ALIGN(4K) : AT (ADDR (.dtors)) + .init_array ALIGN(4K) : AT (ADDR (.init_array) - TEACHOS_VMA) { - KEEP(*crtbegin.o(.dtors)) - KEEP(*(EXCLUDE_FILE (*crtend.o) .dtors)) - KEEP(*(SORT(.dtors.*))) - KEEP(*crtend.o(.dtors)) + __init_array_start = .; + KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*))) + KEEP(*(.init_array)) + __init_array_end = .; } - .bss ALIGN(4K) : AT (ADDR (.bss)) + .bss ALIGN(4K) : AT (ADDR (.bss) - TEACHOS_VMA) { *(COMMON) *(.bss*) } - .data ALIGN(4K) : AT (ADDR (.data)) + .data ALIGN(4K) : AT (ADDR (.data) - TEACHOS_VMA) { *(.data*) } - .user_data ALIGN(4K) : AT (ADDR (.user_data)) + .user_data ALIGN(4K) : AT (ADDR (.user_data) - TEACHOS_VMA) { *(.user_data .user_data.*) } @@ -143,8 +126,8 @@ SECTIONS * In accordance with the symbol definitions at the start, we generate some * symbols to mark the end of our loaded image. ***************************************************************************/ - _end_virtual = ADDR(.bss) + SIZEOF(.bss); - _end_linear = _end_virtual; + _end_virtual = .; + _end_physical = _end_virtual - TEACHOS_VMA; /DISCARD/ : { *(.comment) } } |
