Browse Source

Kernel: Build the kernel as a position-independent executable

This is a prerequisite for KASLR, which we should eventually be doing.
Andreas Kling 5 năm trước cách đây
mục cha
commit
0614c3dd3c
2 tập tin đã thay đổi với 6 bổ sung1 xóa
  1. 1 1
      Kernel/Makefile
  2. 5 0
      Kernel/StdLib.cpp

+ 1 - 1
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/

+ 5 - 0
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();
+}
 }