Index: lib/asan/asan_flags.inc =================================================================== --- lib/asan/asan_flags.inc +++ lib/asan/asan_flags.inc @@ -148,3 +148,5 @@ "(WARNING: USE AT YOUR OWN RISK!)") ASAN_FLAG(bool, use_odr_indicator, false, "Use special ODR indicator symbol for ODR violation detection") +ASAN_FLAG(bool, check_dynamic_rt_prereqs, true, + "Check that dynamic ASan runtime comes first in initial library list") Index: lib/asan/asan_linux.cc =================================================================== --- lib/asan/asan_linux.cc +++ lib/asan/asan_linux.cc @@ -111,7 +111,7 @@ } void AsanCheckDynamicRTPrereqs() { - if (!ASAN_DYNAMIC) + if (!ASAN_DYNAMIC || !flags()->check_dynamic_rt_prereqs) return; // Ensure that dynamic RT is the first DSO in the list Index: test/asan/TestCases/Linux/asan_dlopen_test.cc =================================================================== --- test/asan/TestCases/Linux/asan_dlopen_test.cc +++ test/asan/TestCases/Linux/asan_dlopen_test.cc @@ -2,6 +2,8 @@ // // RUN: %clangxx %s -DRT=\"%shared_libasan\" -o %t -ldl // RUN: not %run %t 2>&1 | FileCheck %s +// RUN: %env_asan_opts=check_dynamic_rt_prereqs=true not %run %t 2>&1 | FileCheck %s +// RUN: %env_asan_opts=check_dynamic_rt_prereqs=false %run %t 2>&1 // REQUIRES: asan-dynamic-runtime // XFAIL: android