[compiler-rt] r216447 - [ASan/Win] Add an extra thunk.lib to handle stack-use-after-return option

Timur Iskhodzhanov timurrrr at google.com
Tue Aug 26 03:08:24 PDT 2014


Author: timurrrr
Date: Tue Aug 26 05:08:24 2014
New Revision: 216447

URL: http://llvm.org/viewvc/llvm-project?rev=216447&view=rev
Log:
[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)

Added:
    compiler-rt/trunk/lib/asan/asan_win_uar_thunk.cc
Modified:
    compiler-rt/trunk/lib/asan/CMakeLists.txt

Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=216447&r1=216446&r2=216447&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Tue Aug 26 05:08:24 2014
@@ -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()

Added: compiler-rt/trunk/lib/asan/asan_win_uar_thunk.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win_uar_thunk.cc?rev=216447&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win_uar_thunk.cc (added)
+++ compiler-rt/trunk/lib/asan/asan_win_uar_thunk.cc Tue Aug 26 05:08:24 2014
@@ -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





More information about the llvm-commits mailing list