diff options
author | Evgenii Stepanov <eugenis@google.com> | 2015-04-24 16:34:47 -0700 |
---|---|---|
committer | Evgenii Stepanov <eugenis@google.com> | 2015-05-12 13:40:29 -0700 |
commit | 6708b6c99cbc61c7fd2bdb51b7f1ddc5b53943ec (patch) | |
tree | 3468e70318ec29b48de1c62099909050347ae266 /core/config_sanitizers.mk | |
parent | eebb8001702fe5c1ce7bb36f024943985df54d75 (diff) | |
download | build-6708b6c99cbc61c7fd2bdb51b7f1ddc5b53943ec.zip build-6708b6c99cbc61c7fd2bdb51b7f1ddc5b53943ec.tar.gz build-6708b6c99cbc61c7fd2bdb51b7f1ddc5b53943ec.tar.bz2 |
Fix AddressSanitizer link order and multilib setup.
ASan runtime library (when using dynamic linking) must be the first
dependency of the main executable to achieve correct symbol
interposition. This matches how the clang driver works.
In multilib setup, ASan-RT name depends on the target arch:
/system/lib/libclang_rt.asan-arm-android.so
/system/lib64/libclang_rt.asan-arm64-android.so
We also set RPATH to /system/lib/asan or /system/lib64/asan
to have a place for ASan-only versions of system libraries.
Change-Id: I937d202077b6e433ba476c075d31be818b662d53
Diffstat (limited to 'core/config_sanitizers.mk')
-rw-r--r-- | core/config_sanitizers.mk | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk index 6e3c0b8..c3009eb 100644 --- a/core/config_sanitizers.mk +++ b/core/config_sanitizers.mk @@ -81,8 +81,12 @@ ifneq ($(filter address,$(my_sanitize)),) my_ldlibs += -lm -ldl -lpthread my_ldflags += --no-as-needed else - my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES) + # ASan runtime library must be the first in the link order. + my_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY) \ + $(my_shared_libraries) \ + $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES) my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES) + my_ldflags += -Wl,-rpath,$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RPATH) endif endif |