[llvm-commits] [compiler-rt] r147792 - in /compiler-rt/trunk/lib/asan: asan_interceptors.cc asan_interceptors.h

Kostya Serebryany kcc at google.com
Mon Jan 9 11:35:11 PST 2012


Author: kcc
Date: Mon Jan  9 13:35:11 2012
New Revision: 147792

URL: http://llvm.org/viewvc/llvm-project?rev=147792&view=rev
Log:
[asan]: fix mac build

Modified:
    compiler-rt/trunk/lib/asan/asan_interceptors.cc
    compiler-rt/trunk/lib/asan/asan_interceptors.h

Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=147792&r1=147791&r2=147792&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Mon Jan  9 13:35:11 2012
@@ -16,6 +16,7 @@
 #include "asan_allocator.h"
 #include "asan_interface.h"
 #include "asan_internal.h"
+#include "asan_mac.h"
 #include "asan_mapping.h"
 #include "asan_stack.h"
 #include "asan_stats.h"
@@ -161,59 +162,6 @@
   return 0;
 }
 
-void InitializeAsanInterceptors() {
-#ifndef __APPLE__
-  INTERCEPT_FUNCTION(index);
-#else
-  OVERRIDE_FUNCTION(index, WRAP(strchr));
-#endif
-  INTERCEPT_FUNCTION(memcmp);
-  INTERCEPT_FUNCTION(memcpy);
-  INTERCEPT_FUNCTION(memmove);
-  INTERCEPT_FUNCTION(memset);
-  INTERCEPT_FUNCTION(strcasecmp);
-  INTERCEPT_FUNCTION(strcat);  // NOLINT
-  INTERCEPT_FUNCTION(strchr);
-  INTERCEPT_FUNCTION(strcmp);
-  INTERCEPT_FUNCTION(strcpy);  // NOLINT
-  INTERCEPT_FUNCTION(strdup);
-  INTERCEPT_FUNCTION(strlen);
-  INTERCEPT_FUNCTION(strncasecmp);
-  INTERCEPT_FUNCTION(strncmp);
-  INTERCEPT_FUNCTION(strncpy);
-
-  INTERCEPT_FUNCTION(sigaction);
-  INTERCEPT_FUNCTION(signal);
-  INTERCEPT_FUNCTION(longjmp);
-  INTERCEPT_FUNCTION(_longjmp);
-  INTERCEPT_FUNCTION_IF_EXISTS(__cxa_throw);
-  INTERCEPT_FUNCTION(pthread_create);
-
-#ifdef __APPLE__
-  INTERCEPT_FUNCTION(dispatch_async_f);
-  INTERCEPT_FUNCTION(dispatch_sync_f);
-  INTERCEPT_FUNCTION(dispatch_after_f);
-  INTERCEPT_FUNCTION(dispatch_barrier_async_f);
-  INTERCEPT_FUNCTION(dispatch_group_async_f);
-  // We don't need to intercept pthread_workqueue_additem_np() to support the
-  // libdispatch API, but it helps us to debug the unsupported functions. Let's
-  // intercept it only during verbose runs.
-  if (FLAG_v >= 2) {
-    INTERCEPT_FUNCTION(pthread_workqueue_additem_np);
-  }
-#else
-  // On Darwin siglongjmp tailcalls longjmp, so we don't want to intercept it
-  // there.
-  INTERCEPT_FUNCTION(siglongjmp);
-#endif
-
-#ifndef __APPLE__
-  INTERCEPT_FUNCTION(strnlen);
-#endif
-  if (FLAG_v > 0) {
-    Printf("AddressSanitizer: libc interceptors initialized\n");
-  }
-}
 
 }  // namespace __asan
 
@@ -277,8 +225,7 @@
 }
 
 extern "C"
-int WRAP(sigaction)(int signum, const struct sigaction *act,
-                    struct sigaction *oldact) {
+int WRAP(sigaction)(int signum, const void *act, void *oldact) {
   if (!AsanInterceptsSignal(signum)) {
     return real_sigaction(signum, act, oldact);
   }
@@ -569,4 +516,63 @@
   }
   return length;
 }
+
+// ---------------------- InitializeAsanInterceptors ---------------- {{{1
+namespace __asan {
+void InitializeAsanInterceptors() {
+#ifndef __APPLE__
+  INTERCEPT_FUNCTION(index);
+#else
+  OVERRIDE_FUNCTION(index, WRAP(strchr));
+#endif
+  INTERCEPT_FUNCTION(memcmp);
+  INTERCEPT_FUNCTION(memcpy);
+  INTERCEPT_FUNCTION(memmove);
+  INTERCEPT_FUNCTION(memset);
+  INTERCEPT_FUNCTION(strcasecmp);
+  INTERCEPT_FUNCTION(strcat);  // NOLINT
+  INTERCEPT_FUNCTION(strchr);
+  INTERCEPT_FUNCTION(strcmp);
+  INTERCEPT_FUNCTION(strcpy);  // NOLINT
+  INTERCEPT_FUNCTION(strdup);
+  INTERCEPT_FUNCTION(strlen);
+  INTERCEPT_FUNCTION(strncasecmp);
+  INTERCEPT_FUNCTION(strncmp);
+  INTERCEPT_FUNCTION(strncpy);
+
+  INTERCEPT_FUNCTION(sigaction);
+  INTERCEPT_FUNCTION(signal);
+  INTERCEPT_FUNCTION(longjmp);
+  INTERCEPT_FUNCTION(_longjmp);
+  INTERCEPT_FUNCTION_IF_EXISTS(__cxa_throw);
+  INTERCEPT_FUNCTION(pthread_create);
+
+#ifdef __APPLE__
+  INTERCEPT_FUNCTION(dispatch_async_f);
+  INTERCEPT_FUNCTION(dispatch_sync_f);
+  INTERCEPT_FUNCTION(dispatch_after_f);
+  INTERCEPT_FUNCTION(dispatch_barrier_async_f);
+  INTERCEPT_FUNCTION(dispatch_group_async_f);
+  // We don't need to intercept pthread_workqueue_additem_np() to support the
+  // libdispatch API, but it helps us to debug the unsupported functions. Let's
+  // intercept it only during verbose runs.
+  if (FLAG_v >= 2) {
+    INTERCEPT_FUNCTION(pthread_workqueue_additem_np);
+  }
+#else
+  // On Darwin siglongjmp tailcalls longjmp, so we don't want to intercept it
+  // there.
+  INTERCEPT_FUNCTION(siglongjmp);
+#endif
+
+#ifndef __APPLE__
+  INTERCEPT_FUNCTION(strnlen);
+#endif
+  if (FLAG_v > 0) {
+    Printf("AddressSanitizer: libc interceptors initialized\n");
+  }
+}
+
+}  // namespace __asan
+
 #endif

Modified: compiler-rt/trunk/lib/asan/asan_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.h?rev=147792&r1=147791&r2=147792&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.h (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.h Mon Jan  9 13:35:11 2012
@@ -66,22 +66,6 @@
   do { real_##func = (func##_f)dlsym(RTLD_NEXT, #func); } while (0)
 #endif
 
-#ifdef __APPLE__
-int WRAP(memcmp)(const void *a1, const void *a2, size_t size);
-void *WRAP(memcpy)(void *to, const void *from, size_t size);
-void *WRAP(memmove)(void *to, const void *from, size_t size);
-void *WRAP(memset)(void *block, int c, size_t size);
-int WRAP(strcasecmp)(const char *s1, const char *s2);
-char *WRAP(strcat)(char *to, const char *from);  // NOLINT
-char *WRAP(strchr)(const char *string, int c);
-int WRAP(strcmp)(const char *s1, const char *s2);
-char *WRAP(strcpy)(char *to, const char *from);  // NOLINT
-char *WRAP(strdup)(const char *s);
-size_t WRAP(strlen)(const char *s);
-int WRAP(strncasecmp)(const char *s1, const char *s2, size_t n);
-int WRAP(strncmp)(const char *s1, const char *s2, size_t size);
-char *WRAP(strncpy)(char *to, const char *from, size_t size);
-#endif
 
 namespace __asan {
 





More information about the llvm-commits mailing list