[PATCH] [ASan] Don't hardcode ASan runtime version in ASan dll thunk

Alexey Samsonov vonosmas at gmail.com
Mon Jul 7 12:06:14 PDT 2014


Hi timurrrr,

Instead, include ASan headers in asan_dll_thunk.cc and make
use of __asan_init macro expansion.

http://reviews.llvm.org/D4411

Files:
  lib/asan/asan_dll_thunk.cc
  lib/asan/asan_interface_internal.h

Index: lib/asan/asan_dll_thunk.cc
===================================================================
--- lib/asan/asan_dll_thunk.cc
+++ lib/asan/asan_dll_thunk.cc
@@ -20,6 +20,7 @@
 // Using #ifdef rather than relying on Makefiles etc.
 // simplifies the build procedure.
 #ifdef ASAN_DLL_THUNK
+#include "asan_interface_internal.h"
 #include "sanitizer_common/sanitizer_interception.h"
 
 // ---------- Function interception helper functions and macros ----------- {{{1
@@ -203,13 +204,13 @@
 
   // Manually wrap __asan_init as we need to initialize
   // __asan_option_detect_stack_use_after_return afterwards.
-  void __asan_init_v4() {
+  void __asan_init() {
     typedef void (*fntype)();
     static fntype fn = 0;
-    // __asan_init_v4 is expected to be called by only one thread.
+    // __asan_init is expected to be called by only one thread.
     if (fn) return;
 
-    fn = (fntype)getRealProcAddressOrDie("__asan_init_v4");
+    fn = (fntype)getRealProcAddressOrDie(__asan_init_name);
     fn();
     __asan_option_detect_stack_use_after_return =
         (__asan_should_detect_stack_use_after_return() != 0);
@@ -339,7 +340,7 @@
 // In DLLs, the callbacks are expected to return 0,
 // otherwise CRT initialization fails.
 static int call_asan_init() {
-  __asan_init_v4();
+  __asan_init();
   return 0;
 }
 #pragma section(".CRT$XIB", long, read)  // NOLINT
Index: lib/asan/asan_interface_internal.h
===================================================================
--- lib/asan/asan_interface_internal.h
+++ lib/asan/asan_interface_internal.h
@@ -33,6 +33,7 @@
   // v3=>v4: added '__asan_global_source_location' to __asan_global.
   SANITIZER_INTERFACE_ATTRIBUTE void __asan_init_v4();
   #define __asan_init __asan_init_v4
+  #define __asan_init_name "__asan_init_v4"
 
   // This structure is used to describe the source location of a place where
   // global was defined.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4411.11126.patch
Type: text/x-patch
Size: 1899 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140707/2313f83f/attachment.bin>


More information about the llvm-commits mailing list