summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compiler-rt/lib/asan/asan_flags.inc3
-rw-r--r--compiler-rt/lib/asan/asan_linux.cc2
-rw-r--r--compiler-rt/test/asan/TestCases/Linux/asan_dlopen_test.cc2
3 files changed, 6 insertions, 1 deletions
diff --git a/compiler-rt/lib/asan/asan_flags.inc b/compiler-rt/lib/asan/asan_flags.inc
index 65a1d173fa6..f2216c2e9b3 100644
--- a/compiler-rt/lib/asan/asan_flags.inc
+++ b/compiler-rt/lib/asan/asan_flags.inc
@@ -158,3 +158,6 @@ ASAN_FLAG(bool, allocator_frees_and_returns_null_on_realloc_zero, true,
"realloc(p, 0) is equivalent to free(p) by default (Same as the "
"POSIX standard). If set to false, realloc(p, 0) will return a "
"pointer to an allocated space which can not be used.")
+ASAN_FLAG(bool, verify_asan_link_order, true,
+ "Check position of ASan runtime in library list (needs to be disabled"
+ " when other library has to be preloaded system-wide)")
diff --git a/compiler-rt/lib/asan/asan_linux.cc b/compiler-rt/lib/asan/asan_linux.cc
index 6d150de790b..50ef84c39a6 100644
--- a/compiler-rt/lib/asan/asan_linux.cc
+++ b/compiler-rt/lib/asan/asan_linux.cc
@@ -111,7 +111,7 @@ static void ReportIncompatibleRT() {
}
void AsanCheckDynamicRTPrereqs() {
- if (!ASAN_DYNAMIC)
+ if (!ASAN_DYNAMIC || !flags()->verify_asan_link_order)
return;
// Ensure that dynamic RT is the first DSO in the list
diff --git a/compiler-rt/test/asan/TestCases/Linux/asan_dlopen_test.cc b/compiler-rt/test/asan/TestCases/Linux/asan_dlopen_test.cc
index f1e31b0a055..5081b775321 100644
--- a/compiler-rt/test/asan/TestCases/Linux/asan_dlopen_test.cc
+++ b/compiler-rt/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=verify_asan_link_order=true not %run %t 2>&1 | FileCheck %s
+// RUN: %env_asan_opts=verify_asan_link_order=false %run %t 2>&1
// REQUIRES: asan-dynamic-runtime
// XFAIL: android
OpenPOWER on IntegriCloud