[compiler-rt] r217673 - [ASan/Win] Rename asan_win_uar_thunk.lib to asan_win_dynamic_runtime_thunk.lib

Timur Iskhodzhanov timurrrr at google.com
Fri Sep 12 06:21:02 PDT 2014


Author: timurrrr
Date: Fri Sep 12 08:21:02 2014
New Revision: 217673

URL: http://llvm.org/viewvc/llvm-project?rev=217673&view=rev
Log:
[ASan/Win] Rename asan_win_uar_thunk.lib to asan_win_dynamic_runtime_thunk.lib

It turned out that we have to bridge more stuff between the executable
and the ASan RTL DLL than just __asan_option_detect_stack_use_after_return.
See PR20918 for more details.


Added:
    compiler-rt/trunk/lib/asan/asan_win_dynamic_runtime_thunk.cc
      - copied, changed from r217666, compiler-rt/trunk/lib/asan/asan_win_uar_thunk.cc
Removed:
    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=217673&r1=217672&r2=217673&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Fri Sep 12 08:21:02 2014
@@ -193,11 +193,12 @@ 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 -Zl
+      add_compiler_rt_runtime(clang_rt.asan_dynamic_runtime_thunk-${arch} ${arch}
+        STATIC
+        SOURCES asan_win_dynamic_runtime_thunk.cc
+        CFLAGS ${ASAN_CFLAGS} -DASAN_DYNAMIC_RUNTIME_THUNK -Zl
         DEFS ${ASAN_COMMON_DEFINITIONS})
-      add_dependencies(asan clang_rt.asan_uar_thunk-${arch})
+      add_dependencies(asan clang_rt.asan_dynamic_runtime_thunk-${arch})
     endif()
   endforeach()
 endif()

Copied: compiler-rt/trunk/lib/asan/asan_win_dynamic_runtime_thunk.cc (from r217666, compiler-rt/trunk/lib/asan/asan_win_uar_thunk.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win_dynamic_runtime_thunk.cc?p2=compiler-rt/trunk/lib/asan/asan_win_dynamic_runtime_thunk.cc&p1=compiler-rt/trunk/lib/asan/asan_win_uar_thunk.cc&r1=217666&r2=217673&rev=217673&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win_uar_thunk.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win_dynamic_runtime_thunk.cc Fri Sep 12 08:21:02 2014
@@ -9,23 +9,34 @@
 //
 // 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.
+// This file defines things that need to be present in the application modules
+// to interact with the ASan DLL runtime correctly and can't be implemented
+// using the default "import library" generated when linking the DLL RTL.
+//
+// This includes:
+//  - forwarding the detect_stack_use_after_return runtime option
+//  - FIXME: installing a custom SEH handler (PR20918)
 //
-// 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
+// Only compile this code when buidling asan_dynamic_runtime_thunk.lib
 // Using #ifdef rather than relying on Makefiles etc.
 // simplifies the build procedure.
-#ifdef ASAN_UAR_THUNK
+#ifdef ASAN_DYNAMIC_RUNTIME_THUNK
 extern "C" {
 __declspec(dllimport) int __asan_should_detect_stack_use_after_return();
 
+// Define 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 '__asan_option_detect_stack_use_after_return',
+// so normally we would just dllimport it.  Unfortunately, the dllimport
+// attribute adds __imp_ prefix to the symbol name of a variable.
+// Since in general we don't know if a given TU is going to be used
+// with a MT or MD runtime and we don't want to use ugly __imp_ names on Windows
+// just to work around this issue, let's clone the a variable that is
+// constant after initialization anyways.
 int __asan_option_detect_stack_use_after_return =
     __asan_should_detect_stack_use_after_return();
 }
-#endif // ASAN_UAR_THUNK
+#endif // ASAN_DYNAMIC_RUNTIME_THUNK

Removed: 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=217672&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win_uar_thunk.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win_uar_thunk.cc (removed)
@@ -1,31 +0,0 @@
-//===-- 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