From 424b069d55fadff2802dbc72d9174b37555d3ea7 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 19 Nov 2022 18:38:32 +0100 Subject: [PATCH] Kernel: Start the call stack with a null RBP on x86_64 --- kernel/CMakeLists.txt | 1 + kernel/moon.ld | 2 +- kernel/src/arch/x86_64/Entry.asm | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 kernel/src/arch/x86_64/Entry.asm diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 24a4acd9..28e9451a 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -21,6 +21,7 @@ add_executable(moon ${SOURCES}) if("${ARCH}" MATCHES "x86_64") set(ASM_SOURCES src/arch/x86_64/CPU.asm + src/arch/x86_64/Entry.asm ) add_library(moon-asm STATIC ${ASM_SOURCES}) target_link_libraries(moon moon-asm) diff --git a/kernel/moon.ld b/kernel/moon.ld index 5b99a57b..c3b72198 100644 --- a/kernel/moon.ld +++ b/kernel/moon.ld @@ -1,4 +1,4 @@ -ENTRY(_start) +ENTRY(_main) OUTPUT_FORMAT(elf64-x86-64) mmio = 0xfffffffff8000000; /* these are configurable for level 2 loaders */ diff --git a/kernel/src/arch/x86_64/Entry.asm b/kernel/src/arch/x86_64/Entry.asm new file mode 100644 index 00000000..92eee7f3 --- /dev/null +++ b/kernel/src/arch/x86_64/Entry.asm @@ -0,0 +1,6 @@ +global _main +extern _start + +_main: + xor rbp, rbp + call _start \ No newline at end of file