From 0d2dde57fef4db0d0e51369a1d9d9cfa5deb7235 Mon Sep 17 00:00:00 2001 From: Evgenii Stepanov Date: Fri, 7 Aug 2015 17:04:37 -0700 Subject: [PATCH] Read global ASAN_OPTIONS from a file. Instead of setting global ASAN_OPTIONS in immutable init.environ.rc, load them from a file that can be changed later. The file has to be on the /system partition to both be editable and available at the early stages of boot. Also add allocator_may_return_null=1 as that is closer to the non-ASan allocator behavior. Bug: 22846541 Change-Id: Ib0f41393c528f2e7cb398470e41f50abf5f4f455 --- rootdir/Android.mk | 24 +++++++++++++++++++----- rootdir/asan.options | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 rootdir/asan.options diff --git a/rootdir/Android.mk b/rootdir/Android.mk index 30a28513c..e1ba2e96f 100644 --- a/rootdir/Android.mk +++ b/rootdir/Android.mk @@ -13,6 +13,20 @@ LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) include $(BUILD_PREBUILT) endif + +####################################### +# asan.options +ifeq (address,$(strip $(SANITIZE_TARGET))) +include $(CLEAR_VARS) + +LOCAL_MODULE := asan.options +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := $(LOCAL_MODULE) +LOCAL_MODULE_PATH := $(TARGET_OUT) + +include $(BUILD_PREBUILT) +endif + ####################################### # init.environ.rc @@ -21,6 +35,11 @@ LOCAL_MODULE_CLASS := ETC LOCAL_MODULE := init.environ.rc LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) +EXPORT_GLOBAL_ASAN_OPTIONS := +ifeq (address,$(strip $(SANITIZE_TARGET))) + EXPORT_GLOBAL_ASAN_OPTIONS := export ASAN_OPTIONS include=/system/asan.options + LOCAL_REQUIRED_MODULES := asan.options +endif # Put it here instead of in init.rc module definition, # because init.rc is conditionally included. # @@ -39,11 +58,6 @@ local_post_install_cmd_base := include $(BUILD_SYSTEM)/base_rules.mk -EXPORT_GLOBAL_ASAN_OPTIONS := -ifeq (address,$(strip $(SANITIZE_TARGET))) - EXPORT_GLOBAL_ASAN_OPTIONS := export ASAN_OPTIONS allow_user_segv_handler=1:detect_odr_violation=0:alloc_dealloc_mismatch=0 -endif - # Regenerate init.environ.rc if PRODUCT_BOOTCLASSPATH has changed. bcp_md5 := $(word 1, $(shell echo $(PRODUCT_BOOTCLASSPATH) $(PRODUCT_SYSTEM_SERVER_CLASSPATH) | $(MD5SUM))) bcp_dep := $(intermediates)/$(bcp_md5).bcp.dep diff --git a/rootdir/asan.options b/rootdir/asan.options new file mode 100644 index 000000000..2f1234127 --- /dev/null +++ b/rootdir/asan.options @@ -0,0 +1 @@ +allow_user_segv_handler=1:detect_odr_violation=0:alloc_dealloc_mismatch=0:allocator_may_return_null=1