--- a/cmake_modules/compilerchecks.cmake Sat Jun 08 01:52:32 2013 +0200
+++ b/cmake_modules/compilerchecks.cmake Sat Jun 08 01:56:23 2013 +0200
@@ -12,6 +12,22 @@
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
endif()
+#check for full relro on ELF, Debian security
+set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro,-z,now")
+check_c_compiler_flag("" HAVE_RELROFULL)
+if(HAVE_RELROFULL)
+ list(APPEND pascal_flags "-k-z" "-krelro" "-k-z" "-know")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+else()
+ #if full relro is not available, try partial relro
+ set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro")
+ check_c_compiler_flag("" HAVE_RELROPARTIAL)
+ if(HAVE_RELROPARTIAL)
+ list(APPEND pascal_flags "-k-z" "-krelro")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ endif()
+endif()
+
#check for ASLR on Windows Vista or later, requires binutils >= 2.20
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
check_c_compiler_flag("" HAVE_WINASLR)