Loading...
src/dyldNew.cpp dyld-210.2.3 dyld-239.4
--- dyld/dyld-210.2.3/src/dyldNew.cpp
+++ dyld/dyld-239.4/src/dyldNew.cpp
@@ -27,6 +27,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <mach/mach.h>
+#include <sys/mman.h>
 
 extern "C" void* __dso_handle;
 
@@ -40,7 +41,7 @@
 
 #if __LP64__
 	// room for about ~1000 initial dylibs
-	#define DYLD_POOL_CHUNK_SIZE 200*1024
+	#define DYLD_POOL_CHUNK_SIZE 224*1024
 #else
 	// room for about ~900 initial dylibs
 	#define DYLD_POOL_CHUNK_SIZE 150*1024
@@ -147,3 +148,26 @@
 int _malloc_lock = 0;
 
 
+// <rdar://problem/12857033> dyld calls this which uses libSystem.dylib's vm_allocate if available
+int vm_alloc(vm_address_t* addr, vm_size_t size, uint32_t flags)
+{
+	if ( (dyld::gLibSystemHelpers != NULL) && (dyld::gLibSystemHelpers->version >= 12) ) {
+		return dyld::gLibSystemHelpers->vm_alloc(mach_task_self(), addr, size, flags);
+	}
+	else {
+		return ::vm_allocate(mach_task_self(), addr, size, flags);
+	}
+}
+
+void* xmmap(void* addr, size_t len, int prot, int flags, int fd, off_t offset)
+{
+	if ( (dyld::gLibSystemHelpers != NULL) && (dyld::gLibSystemHelpers->version >= 12) ) {
+		return dyld::gLibSystemHelpers->mmap(addr, len, prot, flags, fd, offset);
+	}
+	else {
+		return ::mmap(addr, len, prot, flags, fd, offset);
+	}
+}
+
+
+