build: add Wstrict-overflow and FORTIFY_SOURCE options
This patch adds further compiler options related to security to
RMM build options. The `-D_FORTIFY_SOURCE=2` is added mainly
for future proofing as RMM does not link against glibc today
but may do so in future.
Change-Id: I711135491a17cd6f11da72e1b6c701c149f017aa
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
diff --git a/toolchains/common.cmake b/toolchains/common.cmake
index 295bed1..fe2f19c 100644
--- a/toolchains/common.cmake
+++ b/toolchains/common.cmake
@@ -14,8 +14,9 @@
string(APPEND CMAKE_${language}_FLAGS_INIT "-fno-common ")
string(APPEND CMAKE_${language}_FLAGS_INIT "-ffunction-sections ")
string(APPEND CMAKE_${language}_FLAGS_INIT "-fdata-sections ")
- string(APPEND CMAKE_${language}_FLAGS_INIT "-Wall -Werror ")
+ string(APPEND CMAKE_${language}_FLAGS_INIT "-Wall -Werror -Wstrict-overflow ")
string(APPEND CMAKE_${language}_FLAGS_INIT "-gdwarf-4 ")
+ string(APPEND CMAKE_${language}_FLAGS_INIT "-D_FORTIFY_SOURCE=2 ")
string(APPEND CMAKE_${language}_FLAGS_DEBUG_INIT "-Og -Wnull-dereference ")
string(APPEND CMAKE_${language}_FLAGS_RELEASE_INIT "-g ")
endforeach()