From 2daceaa83c7f49b2bfeb40372123778714925098 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Mon, 20 Oct 2014 11:37:18 -0700 Subject: [PATCH] Add support for ASAN in host modules. Change-Id: Id9ed83499e0eb995f06e845c3153a50677d768b8 --- core/binary.mk | 15 +++++++++++++-- core/clang/config.mk | 10 ++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/core/binary.mk b/core/binary.mk index efb0db0ff..6db8ae47f 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -181,8 +181,19 @@ ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true) my_clang := true my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS) my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS) - my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES) - my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES) + ifdef LOCAL_IS_HOST_MODULE + my_ldlibs += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDLIBS_HOST) + my_shared_libraries += \ + $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES_HOST) + my_static_libraries += \ + $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES_HOST) + else + my_ldlibs += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDLIBS_TARGET) + my_shared_libraries += \ + $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES_TARGET) + my_static_libraries += \ + $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES_TARGET) + endif endif ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true) diff --git a/core/clang/config.mk b/core/clang/config.mk index bdd18d81c..246690f22 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -92,8 +92,14 @@ endif # Address sanitizer clang config ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit -ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl libasan_preload -ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan + +ADDRESS_SANITIZER_CONFIG_EXTRA_LDLIBS_HOST := -lpthread -ldl +ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES_HOST := +ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES_HOST := libasan + +ADDRESS_SANITIZER_CONFIG_EXTRA_LDLIBS_TARGET := +ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES_TARGET := libdl libasan_preload +ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES_TARGET := libasan # This allows us to use the superset of functionality that compiler-rt # provides to Clang (for supporting features like -ftrapv).