Merge "Link in ASAN library if my_global_santitize is set."
This commit is contained in:
commit
9d5fb14b2d
|
@ -167,7 +167,6 @@ endif
|
||||||
ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer
|
ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer
|
||||||
ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
|
ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
|
||||||
|
|
||||||
ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES :=
|
|
||||||
ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
|
ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
|
||||||
|
|
||||||
# This allows us to use the superset of functionality that compiler-rt
|
# This allows us to use the superset of functionality that compiler-rt
|
||||||
|
|
|
@ -100,10 +100,8 @@ ifneq ($(my_sanitize),)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(filter address,$(my_sanitize)),)
|
# If local or global modules need ASAN, add linker flags.
|
||||||
# Frame pointer based unwinder in ASan requires ARM frame setup.
|
ifneq ($(filter address,$(my_global_sanitize) $(my_sanitize)),)
|
||||||
LOCAL_ARM_MODE := arm
|
|
||||||
my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
|
|
||||||
my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
|
my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
|
||||||
ifdef LOCAL_IS_HOST_MODULE
|
ifdef LOCAL_IS_HOST_MODULE
|
||||||
# -nodefaultlibs (provided with libc++) prevents the driver from linking
|
# -nodefaultlibs (provided with libc++) prevents the driver from linking
|
||||||
|
@ -111,12 +109,20 @@ ifneq ($(filter address,$(my_sanitize)),)
|
||||||
my_ldlibs += -lm -lpthread
|
my_ldlibs += -lm -lpthread
|
||||||
my_ldflags += -Wl,--no-as-needed
|
my_ldflags += -Wl,--no-as-needed
|
||||||
else
|
else
|
||||||
my_cflags += -mllvm -asan-globals=0
|
# Add asan libraries unless LOCAL_MODULE is the asan library.
|
||||||
# ASan runtime library must be the first in the link order.
|
# ASan runtime library must be the first in the link order.
|
||||||
my_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
|
ifeq (,$(filter $(LOCAL_MODULE),$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY)))
|
||||||
$(my_shared_libraries) \
|
my_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
|
||||||
$(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
|
$(my_shared_libraries)
|
||||||
my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
|
endif
|
||||||
|
ifeq (,$(filter $(LOCAL_MODULE),$(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)))
|
||||||
|
my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Do not add unnecessary dependency in shared libraries.
|
||||||
|
ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
|
||||||
|
my_ldflags += -Wl,--as-needed
|
||||||
|
endif
|
||||||
|
|
||||||
my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
|
my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
|
||||||
# Make sure linker_asan get installed.
|
# Make sure linker_asan get installed.
|
||||||
|
@ -124,6 +130,16 @@ ifneq ($(filter address,$(my_sanitize)),)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# If local module needs ASAN, add compiler flags.
|
||||||
|
ifneq ($(filter address,$(my_sanitize)),)
|
||||||
|
# Frame pointer based unwinder in ASan requires ARM frame setup.
|
||||||
|
LOCAL_ARM_MODE := arm
|
||||||
|
my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
|
||||||
|
ifndef LOCAL_IS_HOST_MODULE
|
||||||
|
my_cflags += -mllvm -asan-globals=0
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(filter undefined,$(my_sanitize)),)
|
ifneq ($(filter undefined,$(my_sanitize)),)
|
||||||
ifndef LOCAL_IS_HOST_MODULE
|
ifndef LOCAL_IS_HOST_MODULE
|
||||||
$(error ubsan is not yet supported on the target)
|
$(error ubsan is not yet supported on the target)
|
||||||
|
|
|
@ -1598,10 +1598,10 @@ $(hide) $(PRIVATE_CXX) \
|
||||||
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
|
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
|
||||||
$(PRIVATE_TARGET_LIBATOMIC) \
|
$(PRIVATE_TARGET_LIBATOMIC) \
|
||||||
$(PRIVATE_TARGET_LIBGCC) \
|
$(PRIVATE_TARGET_LIBGCC) \
|
||||||
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
|
|
||||||
-o $@ \
|
|
||||||
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
|
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
|
||||||
$(PRIVATE_LDFLAGS) \
|
$(PRIVATE_LDFLAGS) \
|
||||||
|
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
|
||||||
|
-o $@ \
|
||||||
$(PRIVATE_TARGET_CRTEND_SO_O) \
|
$(PRIVATE_TARGET_CRTEND_SO_O) \
|
||||||
$(PRIVATE_LDLIBS)
|
$(PRIVATE_LDLIBS)
|
||||||
endef
|
endef
|
||||||
|
@ -1669,10 +1669,10 @@ $(hide) $(PRIVATE_CXX) -pie \
|
||||||
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
|
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
|
||||||
$(PRIVATE_TARGET_LIBATOMIC) \
|
$(PRIVATE_TARGET_LIBATOMIC) \
|
||||||
$(PRIVATE_TARGET_LIBGCC) \
|
$(PRIVATE_TARGET_LIBGCC) \
|
||||||
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
|
|
||||||
-o $@ \
|
|
||||||
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
|
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
|
||||||
$(PRIVATE_LDFLAGS) \
|
$(PRIVATE_LDFLAGS) \
|
||||||
|
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
|
||||||
|
-o $@ \
|
||||||
$(PRIVATE_TARGET_CRTEND_O) \
|
$(PRIVATE_TARGET_CRTEND_O) \
|
||||||
$(PRIVATE_LDLIBS)
|
$(PRIVATE_LDLIBS)
|
||||||
endef
|
endef
|
||||||
|
|
Loading…
Reference in New Issue