mirror of
https://github.com/usatiuk/ficus.git
synced 2025-10-29 00:27:52 +01:00
enable stack protection
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
|
||||
add_executable(kernel.elf)
|
||||
|
||||
target_compile_options(kernel.elf PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti -ffreestanding>)
|
||||
target_compile_options(kernel.elf PUBLIC $<$<COMPILE_LANGUAGE:C>:-ffreestanding>)
|
||||
target_compile_options(kernel.elf PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-fstack-protector-all -fno-exceptions -fno-rtti -ffreestanding>)
|
||||
target_compile_options(kernel.elf PUBLIC $<$<COMPILE_LANGUAGE:C>:-fstack-protector-all -ffreestanding>)
|
||||
|
||||
add_subdirectory(./arch/)
|
||||
add_subdirectory(./kernel/)
|
||||
|
||||
@@ -21,8 +21,7 @@ target_sources(kernel.elf PRIVATE
|
||||
paging.cpp
|
||||
kmain.cpp
|
||||
gdt.cpp
|
||||
misc.cpp
|
||||
cppsupport.cpp)
|
||||
misc.cpp)
|
||||
|
||||
target_include_directories(kernel.elf PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
target_include_directories(kernel.elf PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
target_sources(kernel.elf PRIVATE mutex.cpp cv.cpp)
|
||||
target_sources(kernel.elf PRIVATE mutex.cpp cv.cpp cppsupport.cpp)
|
||||
@@ -3,9 +3,23 @@
|
||||
//
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "kmem.hpp"
|
||||
#include "misc.hpp"
|
||||
#include "serial.hpp"
|
||||
|
||||
#if UINT32_MAX == UINTPTR_MAX
|
||||
#define STACK_CHK_GUARD 0xb079a218
|
||||
#else
|
||||
#define STACK_CHK_GUARD 0x2e61e13e4d5ae23c
|
||||
#endif
|
||||
|
||||
uintptr_t __stack_chk_guard = STACK_CHK_GUARD;
|
||||
|
||||
extern "C" __attribute__((noreturn)) void __stack_chk_fail(void) {
|
||||
assert2(false, "Stack protection triggered!");
|
||||
}
|
||||
|
||||
extern "C" void __cxa_pure_virtual() {
|
||||
// Do nothing or print an error message.
|
||||
Reference in New Issue
Block a user