mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[GCC/CMAKE]
- Add a way to conditionally use the GCC stack protector. Just add -DSTACK_PROTECTOR:BOOL=TRUE as argument to configure.cmd/sh svn path=/trunk/; revision=64527
This commit is contained in:
parent
4e9593f906
commit
87daca2bea
9 changed files with 61 additions and 0 deletions
|
@ -210,6 +210,11 @@ endif()
|
|||
target_link_libraries(freeldr_pe freeldr_common cportlib cmlib rtl libcntpr)
|
||||
target_link_libraries(freeldr_pe_dbg freeldr_common cportlib cmlib rtl libcntpr)
|
||||
|
||||
if (STACK_PROTECTOR)
|
||||
target_link_libraries(freeldr_pe gcc_ssp)
|
||||
target_link_libraries(freeldr_pe_dbg gcc_ssp)
|
||||
endif()
|
||||
|
||||
add_dependencies(freeldr_pe asm)
|
||||
add_dependencies(freeldr_pe_dbg asm)
|
||||
|
||||
|
@ -266,6 +271,11 @@ endif()
|
|||
target_link_libraries(setupldr_pe freeldr_common cportlib cmlib rtl libcntpr)
|
||||
target_link_libraries(setupldr_pe_dbg freeldr_common cportlib cmlib rtl libcntpr)
|
||||
|
||||
if (STACK_PROTECTOR)
|
||||
target_link_libraries(setupldr_pe gcc_ssp)
|
||||
target_link_libraries(setupldr_pe_dbg gcc_ssp)
|
||||
endif()
|
||||
|
||||
add_dependencies(setupldr_pe asm)
|
||||
add_dependencies(setupldr_pe_dbg asm)
|
||||
|
||||
|
|
|
@ -75,6 +75,9 @@ set(_PREFAST_ FALSE CACHE BOOL
|
|||
"Whether to enable PREFAST while compiling.")
|
||||
set(_VS_ANALYZE_ FALSE CACHE BOOL
|
||||
"Whether to enable static analysis while compiling.")
|
||||
else()
|
||||
set(STACK_PROTECTOR FALSE CACHE BOOL
|
||||
"Whether to enbable the GCC stack checker while compiling")
|
||||
endif()
|
||||
|
||||
set(USE_DUMMY_PSEH FALSE CACHE BOOL
|
||||
|
|
|
@ -30,6 +30,10 @@ if(USE_DUMMY_PSEH)
|
|||
add_definitions(-D_USE_DUMMY_PSEH=1)
|
||||
endif()
|
||||
|
||||
if(STACK_PROTECTOR)
|
||||
add_compile_flags(${MODULE} "-fstack-protector-all")
|
||||
endif()
|
||||
|
||||
# Compiler Core
|
||||
add_compile_flags("-pipe -fms-extensions -fno-strict-aliasing")
|
||||
if(GCC_VERSION VERSION_GREATER 4.7)
|
||||
|
@ -281,6 +285,10 @@ function(set_module_type_toolchain MODULE TYPE)
|
|||
add_target_link_flags(${MODULE} "-Wl,--wdmdriver")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(STACK_PROTECTOR)
|
||||
target_link_libraries(${MODULE} gcc_ssp)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(add_delay_importlibs _module)
|
||||
|
|
|
@ -13,6 +13,9 @@ add_subdirectory(drivers)
|
|||
add_subdirectory(epsapi)
|
||||
add_subdirectory(fast486)
|
||||
add_subdirectory(fslib)
|
||||
if (STACK_PROTECTOR)
|
||||
add_subdirectory(gcc_ssp)
|
||||
endif()
|
||||
add_subdirectory(lsalib)
|
||||
add_subdirectory(ppcmmu)
|
||||
add_subdirectory(pseh)
|
||||
|
|
2
reactos/lib/gcc_ssp/CMakeLists.txt
Normal file
2
reactos/lib/gcc_ssp/CMakeLists.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
|
||||
add_library(gcc_ssp STATIC gcc_ssp.c)
|
23
reactos/lib/gcc_ssp/gcc_ssp.c
Normal file
23
reactos/lib/gcc_ssp/gcc_ssp.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
#define FAST_FAIL_STACK_COOKIE_CHECK_FAILURE 2
|
||||
|
||||
/* Should be random :-/ */
|
||||
void * __stack_chk_guard = (void*)0xf00df00d;
|
||||
|
||||
#if 0
|
||||
void __stack_chk_guard_setup()
|
||||
{
|
||||
unsigned char * p;
|
||||
p = (unsigned char *)&__stack_chk_guard; // *** Notice that this takes the address of __stack_chk_guard ***
|
||||
|
||||
/* If you have the ability to generate random numbers in your kernel then use them,
|
||||
otherwise for 32-bit code: */
|
||||
*p = 0x00000aff; // *** p is &__stack_chk_guard so *p writes to __stack_chk_guard rather than *__stack_chk_guard ***
|
||||
}
|
||||
#endif
|
||||
|
||||
void __stack_chk_fail()
|
||||
{
|
||||
/* Like __fastfail */
|
||||
__asm__("int $0x29" : : "c"(FAST_FAIL_STACK_COOKIE_CHECK_FAILURE) : "memory");
|
||||
}
|
|
@ -85,4 +85,8 @@ if(NOT MSVC)
|
|||
target_link_libraries(msvcrtex oldnames)
|
||||
endif()
|
||||
|
||||
if(STACK_PROTECTOR)
|
||||
target_link_libraries(msvcrtex gcc_ssp)
|
||||
endif()
|
||||
|
||||
add_dependencies(msvcrtex psdk asm)
|
||||
|
|
|
@ -44,6 +44,10 @@ target_link_libraries(ntoskrnl
|
|||
wdmguid
|
||||
ioevent)
|
||||
|
||||
if(STACK_PROTECTOR)
|
||||
target_link_libraries(ntoskrnl gcc_ssp)
|
||||
endif()
|
||||
|
||||
add_importlibs(ntoskrnl hal kdcom bootvid)
|
||||
add_pch(ntoskrnl ${REACTOS_SOURCE_DIR}/ntoskrnl/include/ntoskrnl.h NTOSKRNL_SOURCE)
|
||||
add_dependencies(ntoskrnl psdk bugcodes asm)
|
||||
|
|
|
@ -30,6 +30,10 @@ else()
|
|||
set_image_base(ntkrnlmp 0x80800000)
|
||||
endif()
|
||||
|
||||
if(STACK_PROTECTOR)
|
||||
target_link_libraries(ntkrnlmp gcc_ssp)
|
||||
endif()
|
||||
|
||||
target_link_libraries(ntkrnlmp
|
||||
cportlib
|
||||
csq
|
||||
|
|
Loading…
Reference in a new issue