Skip to content

Commit 5f9fe42

Browse files
rdayRisto Kankkunen
andauthored
Add flags for non exec stack and read only GOT. (#2707)
Co-authored-by: Risto Kankkunen <risto.kankkunen@f-secure.com>
1 parent 3da2dcf commit 5f9fe42

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ set(CMAKE_C_FLAGS_DEBUGOPT "")
194194

195195
target_compile_options(${PROJECT_NAME} PRIVATE -pedantic -std=gnu99 -Wall -Werror -Wimplicit -Wunused -Wcomment -Wchar-subscripts
196196
-Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings -Wno-deprecated-declarations -Wno-unknown-pragmas -Wformat-security
197-
-Wno-missing-braces -fvisibility=hidden -DS2N_EXPORTS)
197+
-Wno-missing-braces -fvisibility=hidden -DS2N_EXPORTS
198+
-Wa,--noexecstack
199+
)
200+
201+
set(CMAKE_SHARED_LINKER_FLAGS -Wl,-z,noexecstack,-z,relro,-z,now)
198202

199203
if(S2N_NO_PQ)
200204
target_compile_options(${PROJECT_NAME} PUBLIC -DS2N_NO_PQ)

s2n.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ DEFAULT_CFLAGS += -pedantic -Wall -Werror -Wimplicit -Wunused -Wcomment -Wchar-s
5050

5151
COVERAGE_CFLAGS = -fprofile-arcs -ftest-coverage
5252
COVERAGE_LDFLAGS = --coverage
53+
LDFLAGS = -z relro -z now -z noexecstack
5354

5455
FUZZ_CFLAGS = -fsanitize-coverage=trace-pc-guard -fsanitize=address,undefined,leak
5556

0 commit comments

Comments
 (0)