- 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
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)
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)
"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
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)
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)
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)
--- /dev/null
+
+add_library(gcc_ssp STATIC gcc_ssp.c)
\ No newline at end of file
--- /dev/null
+
+#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");
+}
target_link_libraries(msvcrtex oldnames)
endif()
+if(STACK_PROTECTOR)
+ target_link_libraries(msvcrtex gcc_ssp)
+endif()
+
add_dependencies(msvcrtex psdk asm)
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)
set_image_base(ntkrnlmp 0x80800000)
endif()
+if(STACK_PROTECTOR)
+ target_link_libraries(ntkrnlmp gcc_ssp)
+endif()
+
target_link_libraries(ntkrnlmp
cportlib
csq