8 set(CMAKE_REQUIRED_FLAGS "-Wl,-z,noexecstack") |
8 set(CMAKE_REQUIRED_FLAGS "-Wl,-z,noexecstack") |
9 check_c_compiler_flag("" HAVE_NOEXECSTACK) |
9 check_c_compiler_flag("" HAVE_NOEXECSTACK) |
10 if(HAVE_NOEXECSTACK) |
10 if(HAVE_NOEXECSTACK) |
11 list(APPEND pascal_flags "-k-z" "-knoexecstack") |
11 list(APPEND pascal_flags "-k-z" "-knoexecstack") |
12 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
12 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
|
13 endif() |
|
14 |
|
15 #check for full relro on ELF, Debian security |
|
16 set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro,-z,now") |
|
17 check_c_compiler_flag("" HAVE_RELROFULL) |
|
18 if(HAVE_RELROFULL) |
|
19 list(APPEND pascal_flags "-k-z" "-krelro" "-k-z" "-know") |
|
20 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
|
21 else() |
|
22 #if full relro is not available, try partial relro |
|
23 set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro") |
|
24 check_c_compiler_flag("" HAVE_RELROPARTIAL) |
|
25 if(HAVE_RELROPARTIAL) |
|
26 list(APPEND pascal_flags "-k-z" "-krelro") |
|
27 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") |
|
28 endif() |
13 endif() |
29 endif() |
14 |
30 |
15 #check for ASLR on Windows Vista or later, requires binutils >= 2.20 |
31 #check for ASLR on Windows Vista or later, requires binutils >= 2.20 |
16 set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat") |
32 set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat") |
17 check_c_compiler_flag("" HAVE_WINASLR) |
33 check_c_compiler_flag("" HAVE_WINASLR) |