Merge "Add minimal-runtime support for integer overflows."
This commit is contained in:
commit
b5399007ca
1 changed files with 25 additions and 6 deletions
|
@ -217,19 +217,17 @@ ifneq ($(filter integer_overflow,$(my_sanitize)),)
|
||||||
|
|
||||||
# Respect LOCAL_NOSANITIZE for integer-overflow flags.
|
# Respect LOCAL_NOSANITIZE for integer-overflow flags.
|
||||||
ifeq ($(filter signed-integer-overflow, $(strip $(LOCAL_NOSANITIZE))),)
|
ifeq ($(filter signed-integer-overflow, $(strip $(LOCAL_NOSANITIZE))),)
|
||||||
my_cflags += -fsanitize=signed-integer-overflow
|
my_sanitize += signed-integer-overflow
|
||||||
endif
|
endif
|
||||||
ifeq ($(filter unsigned-integer-overflow, $(strip $(LOCAL_NOSANITIZE))),)
|
ifeq ($(filter unsigned-integer-overflow, $(strip $(LOCAL_NOSANITIZE))),)
|
||||||
my_cflags += -fsanitize=unsigned-integer-overflow
|
my_sanitize += unsigned-integer-overflow
|
||||||
endif
|
endif
|
||||||
my_cflags += -fsanitize-trap=all
|
|
||||||
my_cflags += -ftrap-function=abort
|
|
||||||
my_cflags += $(INTEGER_OVERFLOW_EXTRA_CFLAGS)
|
my_cflags += $(INTEGER_OVERFLOW_EXTRA_CFLAGS)
|
||||||
|
|
||||||
# Check for diagnostics mode (on by default).
|
# Check for diagnostics mode (on by default).
|
||||||
ifneq ($(filter integer_overflow,$(my_sanitize_diag)),)
|
ifneq ($(filter integer_overflow,$(my_sanitize_diag)),)
|
||||||
my_cflags += -fno-sanitize-trap=signed-integer-overflow,unsigned-integer-overflow
|
my_sanitize_diag += signed-integer-overflow
|
||||||
my_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_RUNTIME_LIBRARY) $(my_shared_libraries)
|
my_sanitize_diag += unsigned-integer-overflow
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -326,6 +324,27 @@ ifneq ($(filter address,$(my_sanitize)),)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Use minimal diagnostics when integer overflow is enabled
|
||||||
|
ifndef LOCAL_IS_HOST_MODULE
|
||||||
|
# Pre-emptively add UBSAN minimal runtime incase a static library dependency requires it
|
||||||
|
ifeq ($(filter STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
|
||||||
|
ifndef LOCAL_SDK_VERSION
|
||||||
|
my_static_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_MINIMAL_RUNTIME_LIBRARY)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
ifneq ($(filter unsigned-integer-overflow signed-integer-overflow integer,$(my_sanitize)),)
|
||||||
|
ifeq ($(filter unsigned-integer-overflow signed-integer overflow integer,$(my_sanitize_diag)),)
|
||||||
|
ifeq ($(filter cfi,$(my_sanitize_diag)),)
|
||||||
|
ifeq ($(filter address,$(my_sanitize)),)
|
||||||
|
my_cflags += -fsanitize-minimal-runtime
|
||||||
|
my_cflags += -fno-sanitize-trap=integer
|
||||||
|
my_cflags += -fno-sanitize-recover=integer
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(strip $(LOCAL_SANITIZE_RECOVER)),)
|
ifneq ($(strip $(LOCAL_SANITIZE_RECOVER)),)
|
||||||
recover_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_RECOVER)),
|
recover_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_RECOVER)),
|
||||||
my_cflags += -fsanitize-recover=$(recover_arg)
|
my_cflags += -fsanitize-recover=$(recover_arg)
|
||||||
|
|
Loading…
Reference in a new issue