gnucash maint: Bug 797697 - Enable DEP and ASLR for the Windows build

John Ralls jralls at code.gnucash.org
Wed Apr 22 14:36:21 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/d7c05a90 (commit)
	from  https://github.com/Gnucash/gnucash/commit/80230650 (commit)



commit d7c05a90a0b7254738ad2af13bd2fa589811852b
Author: John Ralls <jralls at ceridwen.us>
Date:   Wed Apr 22 11:34:45 2020 -0700

    Bug 797697 - Enable DEP and ASLR for the Windows build
    
    Added hardening flags.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e255b416d..3f8831576 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -186,8 +186,8 @@ if (WIN32)
   set(REGEX_LDFLAGS "-L${REGEX_LIB_PATH} -lregex")
   #set(LIBXSLT_INCLUDE_DIR ${CMAKE_PREFIX_PATH}/libxslt/include)
   #set(LIBXSLT_XSLTPROC_EXECUTABLE ${CMAKE_PREFIX_PATH}/libxslt/bin/xsltproc)
-#Prevent creating a console window on startup.
-  set(CMAKE_EXE_LINKER_FLAGS -mwindows)
+#Prevent creating a console window on startup and harden the executable.
+  set(CMAKE_EXE_LINKER_FLAGS "-mwindows -Wl,--nxcompat -Wl,--dynamicbase")
 endif()
 
 find_package(PkgConfig REQUIRED)
@@ -953,8 +953,14 @@ install(CODE
 #For windows, copy in some DLLs from Mingw
 
 if (WIN32)
-  find_library(LIBSTDC++ libstdc++-6.dll)
-  find_library(LIBDW2 libgcc_s_dw2-1.dll)
+  find_file(LIBSTDC++ libstdc++-6.dll)
+  if (NOT LIBSTDC++)
+    message(FATAL_ERROR "libstdc++ not found.")
+  endif()
+  find_file(LIBDW2 libgcc_s_dw2-1.dll)
+  if (NOT LIBDW2)
+    message(FATAL_ERROR "libgcc_s_dw2-l not found.")
+  endif()
   set(MINGW_DLLS ${LIBSTDC++} ${LIBDW2})
   install(PROGRAMS ${MINGW_DLLS} DESTINATION ${CMAKE_INSTALL_BINDIR})
   file(COPY ${MINGW_DLLS} DESTINATION ${BINDIR_BUILD}



Summary of changes:
 CMakeLists.txt | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)



More information about the gnucash-changes mailing list