diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2025-07-24 10:17:53 +0000 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2025-07-24 10:17:53 +0000 |
| commit | 2ebf8d525e6a030efc8ca23bcbdf92c2d0cb8985 (patch) | |
| tree | d311baa0e25e56bd1d7789fa3260ac5076fd6187 /arch/x86_64/scripts | |
| parent | bb685cca3a537f0df4205050a9c52b411dee95c6 (diff) | |
| download | teachos-2ebf8d525e6a030efc8ca23bcbdf92c2d0cb8985.tar.xz teachos-2ebf8d525e6a030efc8ca23bcbdf92c2d0cb8985.zip | |
x86_64: implement high/low split
Diffstat (limited to 'arch/x86_64/scripts')
| -rw-r--r-- | arch/x86_64/scripts/kernel.ld | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index 8af242f..6ba8b80 100644 --- a/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld @@ -4,6 +4,7 @@ ENTRY(_start) * Virtual and linear start addresses of the TeachOS kernel *****************************************************************************/ TEACHOS_PMA = 1M; +TEACHOS_VMA = 0xFFFFFFFF80000000; PHDRS { boot_rodata PT_LOAD FLAGS(4); @@ -25,12 +26,13 @@ SECTIONS . = 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_physical = .; - _start_virtual = .; + _start_virtual = . + TEACHOS_VMA; + /*************************************************************************** * The bootstrapping infratructure goes first. We first place the read-only @@ -63,7 +65,10 @@ 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)) + . = ALIGN(4K); + . += TEACHOS_VMA; + + .init ALIGN(4K) : AT(ADDR(.init) - TEACHOS_VMA) { /* * Make sure that the crt code is wrapped around the compiler generated @@ -74,7 +79,7 @@ SECTIONS KEEP(*crtn.s.o*(.init)) } :text - .fini ALIGN(4K) : AT(ADDR (.fini)) + .fini ALIGN(4K) : AT(ADDR (.fini) - TEACHOS_VMA) { /* * Make sure that the crt code is wrapped around the compiler generated @@ -85,29 +90,29 @@ SECTIONS KEEP(*crtn.s.o*(.fini)) } - .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 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)) @@ -115,7 +120,7 @@ SECTIONS KEEP(*crtend.o(.ctors)) } :data - .dtors ALIGN(4K) : AT (ADDR (.dtors)) + .dtors ALIGN(4K) : AT (ADDR (.dtors) - TEACHOS_VMA) { KEEP(*crtbegin.o(.dtors)) KEEP(*(EXCLUDE_FILE (*crtend.o) .dtors)) @@ -123,18 +128,18 @@ SECTIONS KEEP(*crtend.o(.dtors)) } - .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 +148,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_physical = _end_virtual; + _end_virtual = .; + _end_physical = _end_virtual - TEACHOS_VMA; /DISCARD/ : { *(.comment) } } |
