summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/asan/asan_mac.cc22
-rw-r--r--lib/asan/asan_mac.h22
-rw-r--r--lib/asan/asan_malloc_mac.cc11
3 files changed, 26 insertions, 29 deletions
diff --git a/lib/asan/asan_mac.cc b/lib/asan/asan_mac.cc
index 740c011eb..b219e0ad4 100644
--- a/lib/asan/asan_mac.cc
+++ b/lib/asan/asan_mac.cc
@@ -379,28 +379,6 @@ INTERCEPTOR(int, pthread_workqueue_additem_np, pthread_workqueue_t workq,
gencountp);
}
-// CF_RC_BITS, the layout of CFRuntimeBase and __CFStrIsConstant are internal
-// and subject to change in further CoreFoundation versions. Apple does not
-// guarantee any binary compatibility from release to release.
-
-// See http://opensource.apple.com/source/CF/CF-635.15/CFInternal.h
-#if defined(__BIG_ENDIAN__)
-#define CF_RC_BITS 0
-#endif
-
-#if defined(__LITTLE_ENDIAN__)
-#define CF_RC_BITS 3
-#endif
-
-// See http://opensource.apple.com/source/CF/CF-635.15/CFRuntime.h
-typedef struct __CFRuntimeBase {
- uptr _cfisa;
- u8 _cfinfo[4];
-#if __LP64__
- u32 _rc;
-#endif
-} CFRuntimeBase;
-
// See http://opensource.apple.com/source/CF/CF-635.15/CFString.c
int __CFStrIsConstant(CFStringRef str) {
CFRuntimeBase *base = (CFRuntimeBase*)str;
diff --git a/lib/asan/asan_mac.h b/lib/asan/asan_mac.h
index 4917b20cd..e3412bd1a 100644
--- a/lib/asan/asan_mac.h
+++ b/lib/asan/asan_mac.h
@@ -14,6 +14,28 @@
#ifndef ASAN_MAC_H
#define ASAN_MAC_H
+// CF_RC_BITS, the layout of CFRuntimeBase and __CFStrIsConstant are internal
+// and subject to change in further CoreFoundation versions. Apple does not
+// guarantee any binary compatibility from release to release.
+
+// See http://opensource.apple.com/source/CF/CF-635.15/CFInternal.h
+#if defined(__BIG_ENDIAN__)
+#define CF_RC_BITS 0
+#endif
+
+#if defined(__LITTLE_ENDIAN__)
+#define CF_RC_BITS 3
+#endif
+
+// See http://opensource.apple.com/source/CF/CF-635.15/CFRuntime.h
+typedef struct __CFRuntimeBase {
+ uptr _cfisa;
+ u8 _cfinfo[4];
+#if __LP64__
+ u32 _rc;
+#endif
+} CFRuntimeBase;
+
enum {
MACOS_VERSION_UNKNOWN = 0,
MACOS_VERSION_LEOPARD,
diff --git a/lib/asan/asan_malloc_mac.cc b/lib/asan/asan_malloc_mac.cc
index 5770324ab..34591ebfa 100644
--- a/lib/asan/asan_malloc_mac.cc
+++ b/lib/asan/asan_malloc_mac.cc
@@ -397,13 +397,10 @@ void ReplaceSystemMalloc() {
// If __CFInitialize() hasn't been called yet, cf_asan will be installed
// as the default allocator after __CFInitialize() finishes (see the
// interceptor for __CFInitialize() above). Otherwise install cf_asan right
- // now. On Snow Leopard we can check for __CFRuntimeClassTableSize, but on
- // Lion it is private, so we can't.
- if (GetMacosVersion() == MACOS_VERSION_SNOW_LEOPARD) {
- int *cf_rcts = (int*)dlsym(RTLD_SELF, "__CFRuntimeClassTableSize");
- if (cf_rcts && *cf_rcts) CFAllocatorSetDefault(cf_asan);
- } else {
- // FIXME: how can we check __CFInitialize() has been called already?
+ // now. On both Snow Leopard and Lion __CFInitialize() calls
+ // __CFAllocatorInitialize(), which initializes the _base._cfisa field of
+ // the default allocators we check here.
+ if (((CFRuntimeBase*)kCFAllocatorSystemDefault)->_cfisa) {
CFAllocatorSetDefault(cf_asan);
}
}