CMakeLists.txt: Add security compiling option (RELRO, SC, and FORTIFY) 38/301938/1 accepted/tizen/unified/20231128.175121 accepted/tizen/unified/riscv/20231211.234136
authorUnsung Lee <unsung.lee@samsung.com>
Sat, 25 Nov 2023 12:51:34 +0000 (21:51 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Tue, 28 Nov 2023 02:58:41 +0000 (11:58 +0900)
Add security compiling option (RELRO, SC, and FORTIFY) in CFLAGS.

Change-Id: Ic32765cd1967b7f8d028acac238a3ccf001c6992
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
CMakeLists.txt

index 5fcd8e1..f88a4f1 100644 (file)
@@ -36,6 +36,7 @@ ENDFOREACH(flag)
 
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fPIC")
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fstack-protector-strong -D_FORTIFY_SOURCE=2 -O2 -Wl,-z,relro")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -lrt")
 SET(CMAKE_EXE_LINKER_FLAGS "-pie")