summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2014-08-26 10:08:24 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2014-08-26 10:08:24 +0000
commita26c0c71fd272b0c8a3d13e94b362792794a8691 (patch)
tree2ee20019f69e99ff86fd24f9910648f713a80f9e
parentea4f5b5b4c0f82e14a3421d5bee54905323d1e74 (diff)
[ASan/Win] Add an extra thunk.lib to handle stack-use-after-return option
With this patch, "check-asan" passes all the tests with both MT and MD ASan RTL if you set COMPILER_RT_BUILD_SHARED_ASAN to ON (PR20214) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216447 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/asan/CMakeLists.txt5
-rw-r--r--lib/asan/asan_win_uar_thunk.cc31
2 files changed, 36 insertions, 0 deletions
diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt
index a304ff1ed..09407e866 100644
--- a/lib/asan/CMakeLists.txt
+++ b/lib/asan/CMakeLists.txt
@@ -187,6 +187,11 @@ else()
CFLAGS ${ASAN_CFLAGS} -DASAN_DLL_THUNK
DEFS ${ASAN_COMMON_DEFINITIONS})
add_dependencies(asan clang_rt.asan_dll_thunk-${arch})
+ add_compiler_rt_runtime(clang_rt.asan_uar_thunk-${arch} ${arch} STATIC
+ SOURCES asan_win_uar_thunk.cc
+ CFLAGS ${ASAN_CFLAGS} -DASAN_UAR_THUNK
+ DEFS ${ASAN_COMMON_DEFINITIONS})
+ add_dependencies(asan clang_rt.asan_uar_thunk-${arch})
endif()
endforeach()
endif()
diff --git a/lib/asan/asan_win_uar_thunk.cc b/lib/asan/asan_win_uar_thunk.cc
new file mode 100644
index 000000000..27c977ac4
--- /dev/null
+++ b/lib/asan/asan_win_uar_thunk.cc
@@ -0,0 +1,31 @@
+//===-- asan_win_uar_thunk.cc ---------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// This file defines a copy of __asan_option_detect_stack_use_after_return that
+// should be used when linking an MD runtime with a set of object files on
+// Windows.
+//
+// The ASan MD runtime dllexports this variable, so normally we would dllimport
+// it in each TU. Unfortunately, in general we don't know
+// if a given TU is going to be used with a MT or MD runtime.
+//===----------------------------------------------------------------------===//
+
+// Only compile this code when buidling asan_uar_thunk.lib
+// Using #ifdef rather than relying on Makefiles etc.
+// simplifies the build procedure.
+#ifdef ASAN_UAR_THUNK
+extern "C" {
+__declspec(dllimport) int __asan_should_detect_stack_use_after_return();
+
+int __asan_option_detect_stack_use_after_return =
+ __asan_should_detect_stack_use_after_return();
+}
+#endif // ASAN_UAR_THUNK