From bb5454b6db5770f0b0275424148b2d7d3c52a56d Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 27 Jun 2016 15:15:31 -0700 Subject: [PATCH] Build: Add module-level product configuration of sanitization To allow special sanitizer settings for modules shared between products, add product-specific module settings. This was copied from the product-specific dexopt settings. Bug: 29498013 Change-Id: I17a96b975bb6ac7f4ffb3d5b08e2f00b21bd97a1 --- core/config_sanitizers.mk | 8 ++++++++ core/product.mk | 12 ++++++++++++ core/product_config.mk | 16 +++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk index f84a66f0f3..dbcf276952 100644 --- a/core/config_sanitizers.mk +++ b/core/config_sanitizers.mk @@ -24,6 +24,14 @@ ifneq ($(my_global_sanitize),) my_sanitize := $(my_global_sanitize) endif +# The sanitizer specified in the product configuration wins over the previous. +ifneq ($(SANITIZER.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG),) + my_sanitize := $(SANITIZER.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG) + ifeq ($(my_sanitize),never) + my_sanitize := + endif +endif + # Add a filter point for 32-bit vs 64-bit sanitization (to lighten the burden). SANITIZE_ARCH ?= 32 64 ifeq ($(filter $(SANITIZE_ARCH),$(my_32_64_bit_suffix)),) diff --git a/core/product.mk b/core/product.mk index 94cc2e390a..332b015fd8 100644 --- a/core/product.mk +++ b/core/product.mk @@ -120,6 +120,7 @@ _product_var_list := \ PRODUCT_DEX_PREOPT_MODULE_CONFIGS \ PRODUCT_DEX_PREOPT_DEFAULT_FLAGS \ PRODUCT_DEX_PREOPT_BOOT_FLAGS \ + PRODUCT_SANITIZER_MODULE_CONFIGS \ PRODUCT_SYSTEM_BASE_FS_PATH \ PRODUCT_VENDOR_BASE_FS_PATH \ PRODUCT_SHIPPING_API_LEVEL \ @@ -333,3 +334,14 @@ $(eval _c := $(subst $(space),$(_PDPMC_SP_PLACE_HOLDER),$(strip $(2))))\ $(eval PRODUCT_DEX_PREOPT_MODULE_CONFIGS += \ $(foreach m,$(1),$(m)=$(_c))) endef + +# whitespace placeholder when we record module's sanitizer config. +_PSMC_SP_PLACE_HOLDER := |@SP@| +# Set up sanitizer config for a module. +# $(1) list of module names +# $(2) the modules' sanitizer config +define add-product-sanitizer-module-config +$(eval _c := $(subst $(space),$(_PSMC_SP_PLACE_HOLDER),$(strip $(2))))\ +$(eval PRODUCT_SANITIZER_MODULE_CONFIGS += \ + $(foreach m,$(1),$(m)=$(_c))) +endef diff --git a/core/product_config.mk b/core/product_config.mk index ed38bc8fbf..0d4ced3209 100644 --- a/core/product_config.mk +++ b/core/product_config.mk @@ -392,7 +392,7 @@ PRODUCT_DEX_PREOPT_DEFAULT_FLAGS := \ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)) PRODUCT_DEX_PREOPT_BOOT_FLAGS := \ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_BOOT_FLAGS)) -# Resolve and setup per-module dex-preopot configs. +# Resolve and setup per-module dex-preopt configs. PRODUCT_DEX_PREOPT_MODULE_CONFIGS := \ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_MODULE_CONFIGS)) # If a module has multiple setups, the first takes precedence. @@ -405,3 +405,17 @@ $(foreach c,$(PRODUCT_DEX_PREOPT_MODULE_CONFIGS),\ $(eval cf := $(subst $(_PDPMC_SP_PLACE_HOLDER),$(space),$(cf)))\ $(eval DEXPREOPT.$(TARGET_PRODUCT).$(m).CONFIG := $(cf)))) _pdpmc_modules := + +# Resolve and setup per-module sanitizer configs. +PRODUCT_SANITIZER_MODULE_CONFIGS := \ + $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SANITIZER_MODULE_CONFIGS)) +# If a module has multiple setups, the first takes precedence. +_psmc_modules := +$(foreach c,$(PRODUCT_SANITIZER_MODULE_CONFIGS),\ + $(eval m := $(firstword $(subst =,$(space),$(c))))\ + $(if $(filter $(_psmc_modules),$(m)),,\ + $(eval _psmc_modules += $(m))\ + $(eval cf := $(patsubst $(m)=%,%,$(c)))\ + $(eval cf := $(subst $(_PSMC_SP_PLACE_HOLDER),$(space),$(cf)))\ + $(eval SANITIZER.$(TARGET_PRODUCT).$(m).CONFIG := $(cf)))) +_psmc_modules :=