From 0614c3dd3c41d91fb72bc421dd10325e17c82fc0 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 6 Jan 2020 13:04:11 +0100 Subject: [PATCH] Kernel: Build the kernel as a position-independent executable This is a prerequisite for KASLR, which we should eventually be doing. --- Kernel/Makefile | 2 +- Kernel/StdLib.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Kernel/Makefile b/Kernel/Makefile index e36a87f3db..1b0e2fd3f6 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -118,7 +118,7 @@ KERNEL = 1 PROGRAM = kernel -SUBPROJECT_CXXFLAGS += -ffreestanding -mno-80387 -mno-mmx -mno-sse -mno-sse2 -fno-asynchronous-unwind-tables +SUBPROJECT_CXXFLAGS += -pie -fPIE -ffreestanding -mno-80387 -mno-mmx -mno-sse -mno-sse2 -fno-asynchronous-unwind-tables SUBPROJECT_CXXFLAGS += -nostdlib -nostdinc -nostdinc++ SUBPROJECT_CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/9.2.0/ SUBPROJECT_CXXFLAGS += -I../Toolchain/Local/i686-pc-serenity/include/c++/9.2.0/i686-pc-serenity/ diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp index 9054d163c3..8407882089 100644 --- a/Kernel/StdLib.cpp +++ b/Kernel/StdLib.cpp @@ -220,4 +220,9 @@ u32 __stack_chk_guard = (u32)0xc0000c13; { ASSERT_NOT_REACHED(); } + +[[noreturn]] void __stack_chk_fail_local() +{ + ASSERT_NOT_REACHED(); +} }