1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:57:35 +00:00

Kernel: Define a KERNEL_VIRTUAL_BASE in the linker script

Slightly nicer than saying "0xc0000000" over and over.
This commit is contained in:
Andreas Kling 2021-03-04 18:18:43 +01:00
parent adb2e6be5f
commit 50632af4de

View file

@ -1,12 +1,14 @@
ENTRY(start) ENTRY(start)
KERNEL_VIRTUAL_BASE = 0xc0000000;
SECTIONS SECTIONS
{ {
. = 0xc0100000; . = KERNEL_VIRTUAL_BASE + 0x00100000;
start_of_kernel_image = .; start_of_kernel_image = .;
.text ALIGN(4K) : AT (ADDR(.text) - 0xc0000000) .text ALIGN(4K) : AT (ADDR(.text) - KERNEL_VIRTUAL_BASE)
{ {
$<TARGET_OBJECTS:boot> $<TARGET_OBJECTS:boot>
*(.multiboot) *(.multiboot)
@ -22,7 +24,7 @@ SECTIONS
*(.text*) *(.text*)
} }
.unmap_after_init ALIGN(4K) : AT (ADDR(.unmap_after_init) - 0xc0000000) .unmap_after_init ALIGN(4K) : AT (ADDR(.unmap_after_init) - KERNEL_VIRTUAL_BASE)
{ {
start_of_unmap_after_init = .; start_of_unmap_after_init = .;
*(.unmap_after_init*); *(.unmap_after_init*);
@ -31,7 +33,7 @@ SECTIONS
end_of_kernel_text = .; end_of_kernel_text = .;
} }
.rodata ALIGN(4K) : AT (ADDR(.rodata) - 0xc0000000) .rodata ALIGN(4K) : AT (ADDR(.rodata) - KERNEL_VIRTUAL_BASE)
{ {
start_heap_ctors = .; start_heap_ctors = .;
*libkernel_heap.a:*(.ctors) *libkernel_heap.a:*(.ctors)
@ -44,21 +46,21 @@ SECTIONS
*(.rodata*) *(.rodata*)
} }
.data ALIGN(4K) : AT (ADDR(.data) - 0xc0000000) .data ALIGN(4K) : AT (ADDR(.data) - KERNEL_VIRTUAL_BASE)
{ {
start_of_kernel_data = .; start_of_kernel_data = .;
*(.data*) *(.data*)
end_of_kernel_data = .; end_of_kernel_data = .;
} }
.ro_after_init ALIGN(4K) (NOLOAD) : AT(ADDR(.ro_after_init) - 0xc0000000) .ro_after_init ALIGN(4K) (NOLOAD) : AT(ADDR(.ro_after_init) - KERNEL_VIRTUAL_BASE)
{ {
start_of_ro_after_init = .; start_of_ro_after_init = .;
*(.ro_after_init); *(.ro_after_init);
end_of_ro_after_init = .; end_of_ro_after_init = .;
} }
.bss ALIGN(4K) (NOLOAD) : AT (ADDR(.bss) - 0xc0000000) .bss ALIGN(4K) (NOLOAD) : AT (ADDR(.bss) - KERNEL_VIRTUAL_BASE)
{ {
start_of_kernel_bss = .; start_of_kernel_bss = .;
*(page_tables) *(page_tables)