[Makefile] add option to enable gcc sanitizer for UB and asan

Add option to enable gcc sanitizer option for undefined behavior.
The following changesets will make ubsan work.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
This commit is contained in:
Isaku Yamahata
2019-07-27 01:38:26 -07:00
parent ad0dd8be31
commit e994f8eb13
5 changed files with 16 additions and 2 deletions
+1
View File
@@ -9,6 +9,7 @@ CFLAGS = -Wall -fPIC -std=c11 -Winline -Wwrite-strings \
-fmerge-all-constants -Wstrict-prototypes \
-Werror=implicit-function-declaration \
$(cc-option, -Wnull-dereference) \
$(CFLAGS_SANITIZE) \
-fno-stack-protector -fno-builtin -Wno-inline \
-I../include -I../../../Pal/lib -I../../../Pal/include/pal
+10
View File
@@ -11,3 +11,13 @@ ifeq ($(origin LD),default)
LD = ld
endif
OBJCOPY ?= objcopy
# CONFIG_ENABLE_UBSAN=y
CONFIG_ENABLE_UBSAN=n
#
# variables depend on configrations
#
ifeq ($(CONFIG_ENABLE_UBSAN),y)
CFLAGS_SANITIZE += $(call cc-option,-fsanitize=undefined)
endif
+2 -1
View File
@@ -5,7 +5,8 @@ include ../src/Makefile.Host
CFLAGS = -Wall -fPIC -O2 -std=gnu99 -fgnu89-inline -U_FORTIFY_SOURCE \
$(call cc-option,-Wnull-dereference) \
-fno-omit-frame-pointer \
-fno-stack-protector -fno-builtin
-fno-stack-protector -fno-builtin \
$(CFLAGS_SANITIZE)
ARFLAGS =
include ../src/host/$(PAL_HOST)/Makefile.am
+1
View File
@@ -2,6 +2,7 @@
HOST_DIR = host/$(PAL_HOST)
CFLAGS = -Wall -fPIC -O2 -maes -std=c11 -U_FORTIFY_SOURCE \
$(CFLAGS_SANITIZE) \
-fno-omit-frame-pointer \
-fno-stack-protector -fno-builtin
+2 -1
View File
@@ -3,7 +3,8 @@ HOST_DIR = host/$(PAL_HOST)
SEC_DIR = security/$(PAL_HOST)
CFLAGS = -Wall -fPIC -O2 -std=c11 -U_FORTIFY_SOURCE \
-fno-stack-protector -fno-builtin
-fno-stack-protector -fno-builtin \
$(CFLAGS_SANITIZE)
EXTRAFLAGS = -Wextra $(call cc-option,-Wnull-dereference)