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

Alexey Samsonov samsonov at google.com
Wed Mar 21 05:03:46 PDT 2012


Author: samsonov
Date: Wed Mar 21 07:03:44 2012
New Revision: 153178

URL: http://llvm.org/viewvc/llvm-project?rev=153178&view=rev
Log:
[asan]: start removing os-specific asan_mac.h - move inclusion of mac system header to asan_mac.cc

Modified:
    compiler-rt/trunk/lib/asan/asan_interceptors.cc
    compiler-rt/trunk/lib/asan/asan_mac.cc
    compiler-rt/trunk/lib/asan/asan_mac.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=153178&r1=153177&r2=153178&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Wed Mar 21 07:03:44 2012
@@ -720,14 +720,8 @@
   CHECK(INTERCEPT_FUNCTION(dispatch_barrier_async_f));
   CHECK(INTERCEPT_FUNCTION(dispatch_group_async_f));
 
-  // Normally CFStringCreateCopy should not copy constant CF strings.
-  // Replacing the default CFAllocator causes constant strings to be copied
-  // rather than just returned, which leads to bugs in big applications like
-  // Chromium and WebKit, see
   // http://code.google.com/p/address-sanitizer/issues/detail?id=10
-  // Until this problem is fixed we need to check that the string is
-  // non-constant before calling CFStringCreateCopy.
-  CHECK(INTERCEPT_FUNCTION(CFStringCreateCopy));
+  PatchCFStringCreateCopy();
 #endif
 
   if (FLAG_v > 0) {

Modified: compiler-rt/trunk/lib/asan/asan_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.cc?rev=153178&r1=153177&r2=153178&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_mac.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_mac.cc Wed Mar 21 07:03:44 2012
@@ -16,6 +16,7 @@
 
 #include "asan_mac.h"
 
+#include "asan_interceptors.h"
 #include "asan_internal.h"
 #include "asan_mapping.h"
 #include "asan_procmaps.h"
@@ -34,6 +35,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <libkern/OSAtomic.h>
+#include <CoreFoundation/CFString.h>
 
 namespace __asan {
 
@@ -610,4 +612,17 @@
   }
 }
 
+namespace __asan {
+void PatchCFStringCreateCopy() {
+  // Normally CFStringCreateCopy should not copy constant CF strings.
+  // Replacing the default CFAllocator causes constant strings to be copied
+  // rather than just returned, which leads to bugs in big applications like
+  // Chromium and WebKit, see
+  // http://code.google.com/p/address-sanitizer/issues/detail?id=10
+  // Until this problem is fixed we need to check that the string is
+  // non-constant before calling CFStringCreateCopy.
+  CHECK(INTERCEPT_FUNCTION(CFStringCreateCopy));
+}
+}  // namespace __asan
+
 #endif  // __APPLE__

Modified: compiler-rt/trunk/lib/asan/asan_mac.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.h?rev=153178&r1=153177&r2=153178&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_mac.h (original)
+++ compiler-rt/trunk/lib/asan/asan_mac.h Wed Mar 21 07:03:44 2012
@@ -18,8 +18,6 @@
 
 #include "asan_interceptors.h"
 
-#include <CoreFoundation/CFString.h>
-
 typedef void* pthread_workqueue_t;
 typedef void* pthread_workitem_handle_t;
 
@@ -29,6 +27,10 @@
 typedef void (*dispatch_function_t)(void *block);
 typedef void* (*worker_t)(void *block);
 
+namespace __asan {
+void PatchCFStringCreateCopy();
+}  // namespace __asan
+
 DECLARE_REAL_AND_INTERCEPTOR(void, dispatch_async_f, dispatch_queue_t dq,
                                                      void *ctxt,
                                                      dispatch_function_t func);
@@ -54,9 +56,6 @@
                                   void * workitem_arg,
                                   pthread_workitem_handle_t * itemhandlep,
                                   unsigned int *gencountp);
-DECLARE_REAL_AND_INTERCEPTOR(CFStringRef, CFStringCreateCopy,
-                                          CFAllocatorRef alloc,
-                                          CFStringRef str);
 
 // A wrapper for the ObjC blocks used to support libdispatch.
 typedef struct {





More information about the llvm-commits mailing list