diff --git a/ld/system.ld b/ld/system.ld index cfebbd6..b8cf71a 100644 --- a/ld/system.ld +++ b/ld/system.ld @@ -5,7 +5,6 @@ OUTPUT_FORMAT(elf64-x86-64) ENTRY(_efi_start) -PROVIDE(__stack_start__ = 0x1000); PROVIDE(__stack_end__ = 0x2000); PROVIDE(__first_page__ = 0x2000); PROVIDE(__pagetable__ = 0x20000); diff --git a/src/platform/pagetable.cpp b/src/platform/pagetable.cpp index 7401951..9506953 100644 --- a/src/platform/pagetable.cpp +++ b/src/platform/pagetable.cpp @@ -85,9 +85,11 @@ void Pagetable::init() { const EFI_SYSTEM_TABLE *ST = EFI::getSystemTable(); MULTIBOOT_PAYLOAD *multiboot = Multiboot::getPayload(); + static const size_t stack_size = 0x1000; + asm volatile("mov %%cr3, %q0":"=r"(pagetable)); - asm volatile("lea __stack_start__(%%rip), %q0":"=r"(stack_start)); asm volatile("lea __stack_end__(%%rip), %q0":"=r"(stack_top)); + stack_start = stack_top - stack_size; asm volatile("lea __text_start__(%%rip), %q0":"=r"(text_start)); asm volatile("lea __data_end__(%%rip), %q0":"=r"(data_top)); asm volatile("lea __modules_start__(%%rip), %q0":"=r"(modules_start));