From 47c10eb2fcce1af3f8cbae95e9c459864f1d44bc Mon Sep 17 00:00:00 2001 From: Kostya Kortchinsky Date: Thu, 11 Oct 2018 08:56:12 -0700 Subject: [PATCH] Scudo minimal runtime support for make Scudo is now compatible with the -fsanitize-minimal-runtime, and offers a new dynamic library that doesn't bundle UBSan. This patch adds support for this new library in make, preferring it over the full one, unless a diagnostic dependency is found. Test: aosp compiled with m -j Test: local test enabling Scudo for mediaextractor Change-Id: I99ac0d410b1619de09783f5009476c1ea2995f98 --- core/config_sanitizers.mk | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk index e58f67684..be1b124f0 100644 --- a/core/config_sanitizers.mk +++ b/core/config_sanitizers.mk @@ -212,10 +212,6 @@ ifneq ($(filter address thread hwaddress,$(my_sanitize)),) my_sanitize := $(filter-out scudo,$(my_sanitize)) endif -ifneq ($(filter scudo,$(my_sanitize)),) - my_shared_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)SCUDO_RUNTIME_LIBRARY) -endif - # Undefined symbols can occur if a non-sanitized library links # sanitized static libraries. That's OK, because the executable # always depends on the ASan runtime library, which defines these @@ -375,7 +371,7 @@ ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_IS_AUX_MODULE),) 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 unsigned-integer-overflow signed-integer-overflow integer,$(my_sanitize_diag)),) ifeq ($(filter cfi,$(my_sanitize_diag)),) ifeq ($(filter address hwaddress,$(my_sanitize)),) my_cflags += -fsanitize-minimal-runtime @@ -387,6 +383,18 @@ ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_IS_AUX_MODULE),) endif endif +# For Scudo, we opt for the minimal runtime, unless some diagnostics are enabled. +ifneq ($(filter scudo,$(my_sanitize)),) + ifeq ($(filter unsigned-integer-overflow signed-integer-overflow integer cfi,$(my_sanitize_diag)),) + my_cflags += -fsanitize-minimal-runtime + endif + ifneq ($(filter -fsanitize-minimal-runtime,$(my_cflags)),) + my_shared_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)SCUDO_MINIMAL_RUNTIME_LIBRARY) + else + my_shared_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)SCUDO_RUNTIME_LIBRARY) + endif +endif + ifneq ($(strip $(LOCAL_SANITIZE_RECOVER)),) recover_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_RECOVER)), my_cflags += -fsanitize-recover=$(recover_arg)