Loading...
src/dyldAPIs.cpp dyld-852 dyld-551.4
--- dyld/dyld-852/src/dyldAPIs.cpp
+++ dyld/dyld-551.4/src/dyldAPIs.cpp
@@ -45,41 +45,19 @@
 #include <sys/sysctl.h>
 #include <mach/mach_traps.h> // for task_self_trap()
 
-#include <mach-o/dyld_images.h>
-#include <mach-o/dyld.h>
-#include <mach-o/dyld_priv.h>
+
+#include "mach-o/dyld_images.h"
+#include "mach-o/dyld.h"
+#include "mach-o/dyld_priv.h"
 
 #include "ImageLoader.h"
 #include "ImageLoaderMachO.h"
-#include "dyld2.h"
+#include "dyld.h"
 #include "dyldLibSystemInterface.h"
 #include "DyldSharedCache.h"
-#include "MachOFile.h"
 
 #undef _POSIX_C_SOURCE
-#include <dlfcn.h>
-
-#if __has_feature(ptrauth_calls)
-  #include <ptrauth.h>
-#endif
-
-
-// relocation_info.r_length field has value 3 for 64-bit executables and value 2 for 32-bit executables
-#if __LP64__
-#define RELOC_SIZE 3
-#define LC_SEGMENT_COMMAND		LC_SEGMENT_64
-#define LC_ROUTINES_COMMAND		LC_ROUTINES_64
-struct macho_segment_command	: public segment_command_64  {};
-struct macho_section			: public section_64  {};
-struct macho_routines_command	: public routines_command_64  {};
-#else
-#define RELOC_SIZE 2
-#define LC_SEGMENT_COMMAND		LC_SEGMENT
-#define LC_ROUTINES_COMMAND		LC_ROUTINES
-struct macho_segment_command	: public segment_command {};
-struct macho_section			: public section  {};
-struct macho_routines_command	: public routines_command  {};
-#endif
+#include "dlfcn.h"
 
 
 // this was in dyld_priv.h but it is no longer exported
@@ -98,21 +76,11 @@
 
 extern "C" int _dyld_func_lookup(const char* name, void** address);
 
-extern "C" void* dlopen_internal(const char* path, int mode, void* callerAddress);
-extern "C" bool  dlopen_preflight_internal(const char* path, void* callerAddress);
-extern "C" void* dlsym_internal(void* handle, const char* symbolName, void* callerAddress);
-
-extern "C" void* dlopen_compat(const char* path, int mode);
-extern "C" bool  dlopen_preflight_compat(const char* path);
-extern "C" void* dlsym_compat(void* handle, const char* symbolName);
-
-
-
 // deprecated APIs are still availble on Mac OS X, but not on iPhone OS
-#if TARGET_OS_OSX
+#if __IPHONE_OS_VERSION_MIN_REQUIRED	
+	#define DEPRECATED_APIS_SUPPORTED 0
+#else
 	#define DEPRECATED_APIS_SUPPORTED 1
-#else
-	#define DEPRECATED_APIS_SUPPORTED 0
 #endif
 
 static bool sDynamicInterposing = false;
@@ -162,24 +130,20 @@
     void*		implementation;
 };
 
-static const struct dyld_func dyld_funcs[] = {
+static struct dyld_func dyld_funcs[] = {
     {"__dyld_register_func_for_add_image",				(void*)_dyld_register_func_for_add_image },
     {"__dyld_register_func_for_remove_image",			(void*)_dyld_register_func_for_remove_image },
     {"__dyld_dladdr",									(void*)dladdr },
     {"__dyld_dlclose",									(void*)dlclose },
     {"__dyld_dlerror",									(void*)dlerror },
-    {"__dyld_dlopen_internal",							(void*)dlopen_internal },
-    {"__dyld_dlsym_internal",							(void*)dlsym_internal },
-    {"__dyld_dlopen_preflight_internal",				(void*)dlopen_preflight_internal },
-    {"__dyld_dlopen",									(void*)dlopen_compat },
-    {"__dyld_dlsym",									(void*)dlsym_compat },
-    {"__dyld_dlopen_preflight",							(void*)dlopen_preflight_compat },
+    {"__dyld_dlopen",									(void*)dlopen },
+    {"__dyld_dlsym",									(void*)dlsym },
+    {"__dyld_dlopen_preflight",							(void*)dlopen_preflight },
 	{"__dyld_image_count",								(void*)_dyld_image_count },
     {"__dyld_get_image_header",							(void*)_dyld_get_image_header },
     {"__dyld_get_image_vmaddr_slide",					(void*)_dyld_get_image_vmaddr_slide },
     {"__dyld_get_image_name",							(void*)_dyld_get_image_name },
     {"__dyld_get_image_slide",							(void*)_dyld_get_image_slide },
-    {"__dyld_get_prog_image_header",					(void*)_dyld_get_prog_image_header },
     {"__dyld__NSGetExecutablePath",						(void*)_NSGetExecutablePath },
 
 	// SPIs
@@ -198,21 +162,15 @@
 	{"__dyld_process_is_restricted",					(void*)dyld::processIsRestricted },
 	{"__dyld_dynamic_interpose",						(void*)dyld_dynamic_interpose },
 	{"__dyld_shared_cache_file_path",					(void*)dyld::getStandardSharedCacheFilePath },
-	{"__dyld_has_inserted_or_interposing_libraries",	(void*)dyld::hasInsertedOrInterposingLibraries },
     {"__dyld_get_image_header_containing_address",		(void*)dyld_image_header_containing_address },
     {"__dyld_is_memory_immutable",						(void*)_dyld_is_memory_immutable },
     {"__dyld_objc_notify_register",						(void*)_dyld_objc_notify_register },
     {"__dyld_get_shared_cache_uuid",					(void*)_dyld_get_shared_cache_uuid },
     {"__dyld_get_shared_cache_range",					(void*)_dyld_get_shared_cache_range },
-    {"__dyld_images_for_addresses",						(void*)_dyld_images_for_addresses },
-    {"__dyld_register_for_image_loads",					(void*)_dyld_register_for_image_loads },
-    {"__dyld_register_for_bulk_image_loads",			(void*)_dyld_register_for_bulk_image_loads },
-    {"__dyld_register_driverkit_main",					(void*)_dyld_register_driverkit_main },
-    {"__dyld_halt",										(void*)dyld::halt },
-
+
+
+	// deprecated
 #if DEPRECATED_APIS_SUPPORTED
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
     {"__dyld_lookup_and_bind",						(void*)client_dyld_lookup_and_bind },
     {"__dyld_lookup_and_bind_with_hint",			(void*)_dyld_lookup_and_bind_with_hint },
     {"__dyld_lookup_and_bind_fully",				(void*)_dyld_lookup_and_bind_fully },
@@ -254,7 +212,6 @@
 #if OLD_LIBSYSTEM_SUPPORT
     {"__dyld_link_module",							(void*)_dyld_link_module },
 #endif
-#pragma clang diagnostic pop
 #endif //DEPRECATED_APIS_SUPPORTED
 
     {NULL, 0}
@@ -300,7 +257,6 @@
 	const void*		imageBaseAddress;	// not used with OFI created from files
 	size_t			imageLength;		// not used with OFI created from files
 };
-typedef __NSObjectFileImage*  NSObjectFileImage;
 
 
 VECTOR_NEVER_DESTRUCTED(NSObjectFileImage);
@@ -391,35 +347,10 @@
 	return allImagesIndexedPath(image_index);
 }
 
-const struct mach_header* _dyld_get_prog_image_header()
-{
-	if ( dyld::gLogAPIs )
-		dyld::log("%s()\n", __func__);
-	
-	return dyld::mainExecutable()->machHeader();
-}
-
-static const void *stripPointer(const void *ptr) {
-#if __has_feature(ptrauth_calls)
-	return __builtin_ptrauth_strip(ptr, ptrauth_key_asia);
-#else
-	return ptr;
-#endif
-}
-
-static void *stripPointer(void *ptr) {
-#if __has_feature(ptrauth_calls)
-	return __builtin_ptrauth_strip(ptr, ptrauth_key_asia);
-#else
-	return ptr;
-#endif
-}
-
 const struct mach_header * dyld_image_header_containing_address(const void* address)
 {
 	if ( dyld::gLogAPIs )
 		dyld::log("%s(%p)\n", __func__, address);
-	address = stripPointer(address);
 #if SUPPORT_ACCELERATE_TABLES
 	const mach_header* mh;
 	const char* path;
@@ -427,7 +358,7 @@
 		return mh;
 #endif
 	ImageLoader* image = dyld::findImageContainingAddress(address);
-	if ( image != NULL )
+	if ( image != NULL ) 
 		return image->machHeader();
 	return NULL;
 }
@@ -784,19 +715,6 @@
 	ImageLoader* image = dyld::findImageContainingSymbol(symbol);
 	if ( image != NULL ) 
 		result = (void*)image->getExportedSymbolAddress(NSSymbolToSymbol(symbol), dyld::gLinkContext);
-
-#if __has_feature(ptrauth_calls)
-	// Sign the pointer if it points to a function
-	if ( result ) {
-		const ImageLoader* symbolImage = image;
-		if (!symbolImage->containsAddress(result)) {
-			symbolImage = dyld::findImageContainingAddress(result);
-		}
-		const macho_section *sect = symbolImage ? symbolImage->findSection(result) : NULL;
-		if ( sect && ((sect->flags & S_ATTR_PURE_INSTRUCTIONS) || (sect->flags & S_ATTR_SOME_INSTRUCTIONS)) )
-			result = __builtin_ptrauth_sign_unauthenticated(result, ptrauth_key_asia, 0);
-	}
-#endif
 	return result;
 }
 
@@ -825,7 +743,6 @@
 {
 	if ( dyld::gLogAPIs )
 		dyld::log("%s(%p)\n", __func__, address);
-	address = stripPointer(address);
 	dyld::clearErrorMessage();
 	ImageLoader* image = dyld::findImageContainingAddress(address);
 	if ( image != NULL ) {
@@ -1382,7 +1299,7 @@
 }
 
 
-bool dlopen_preflight_internal(const char* path, void* callerAddress)
+bool dlopen_preflight(const char* path)
 {
 	if ( dyld::gLogAPIs )
 		dyld::log("%s(%s)\n", __func__, path);
@@ -1393,7 +1310,7 @@
 
 	const bool leafName = (strchr(path, '/') == NULL);
 	const bool absolutePath = (path[0] == '/');
-#if TARGET_OS_IPHONE
+#if __IPHONE_OS_VERSION_MIN_REQUIRED
 	char canonicalPath[PATH_MAX]; 
 	// <rdar://problem/7017050> dlopen() not opening frameworks from shared cache with // or ./ in path
 	if ( !leafName ) {
@@ -1423,21 +1340,11 @@
 	// if requested path is to something in the dyld shared cache, always succeed
 	if ( dyld::inSharedCache(path) )
 		return true;
-
-#if TARGET_OS_OSX
-	// <rdar://problem/47464387> dlopen_preflight() on symlink to image in shared cache leaves it half loaded
-	if ( strncmp(path, "/System/Library/", 16) == 0 ) {
-		char canonicalPath[PATH_MAX];
-		if ( realpath(path, canonicalPath) ) {
-			if ( dyld::inSharedCache(canonicalPath) )
-				return true;
-		}
-	}
-#endif
-
+	
 	bool result = false;
 	std::vector<const char*> rpathsFromCallerImage;
 	try {
+		void* callerAddress = __builtin_return_address(1); // note layers: 1: real client, 0: libSystem glue
 		ImageLoader* callerImage = dyld::findImageContainingAddress(callerAddress);
 		// for dlopen, use rpath from caller image and from main executable
 		if ( callerImage != NULL )
@@ -1503,13 +1410,14 @@
 }
 #endif
 
-void* dlopen_internal(const char* path, int mode, void* callerAddress)
+void* dlopen(const char* path, int mode)
 {
 	if ( dyld::gLogAPIs )
 		dyld::log("%s(%s, 0x%08X)\n", __func__, ((path==NULL) ? "NULL" : path), mode);
 
 #if SUPPORT_ACCELERATE_TABLES
 	if ( dyld::gLogAppAPIs ) {
+		void* callerAddress = __builtin_return_address(1); // note layers: 1: real client, 0: libSystem glue
 		const char* shortName;
 		if ( callerIsNonOSApp(callerAddress, &shortName) ) {
 			dyld::log("%s: %s(%s, 0x%08X)\n", shortName, __func__, ((path==NULL) ? "NULL" : path), mode);
@@ -1539,7 +1447,7 @@
 	void* result = NULL;
 	const bool leafName = (strchr(path, '/') == NULL);
 	const bool absolutePath = (path[0] == '/');
-#if TARGET_OS_IPHONE
+#if __IPHONE_OS_VERSION_MIN_REQUIRED
 	char canonicalPath[PATH_MAX]; 
 	// <rdar://problem/7017050> dlopen() not opening frameworks from shared cache with // or ./ in path
 	if ( !leafName ) {
@@ -1573,6 +1481,7 @@
 	std::vector<const char*> rpathsFromCallerImage;
 	ImageLoader::RPathChain callersRPaths(NULL, &rpathsFromCallerImage);
 	try {
+		void* callerAddress = __builtin_return_address(1); // note layers: 1: real client, 0: libSystem glue
 		ImageLoader* callerImage = dyld::findImageContainingAddress(callerAddress);
 		if ( (mode & RTLD_NOLOAD) == 0 ) {
 			// for dlopen, use rpath from caller image and from main executable
@@ -1618,12 +1527,7 @@
 				bool alreadyLinked = image->isLinked();
 				bool forceLazysBound = ( (mode & RTLD_NOW) != 0 );
 				dyld::link(image, forceLazysBound, false, callersRPaths, cacheIndex);
-				if ( alreadyLinked ) {
-					// upgrade
-					if ( ((mode & RTLD_LOCAL) == 0) && image->hasHiddenExports() )
-						image->setHideExports(false);
-				}
-				else {
+				if ( ! alreadyLinked ) {
 					// only hide exports if image is not already in use
 					if ( (mode & RTLD_LOCAL) != 0 )
 						image->setHideExports(true);
@@ -1699,6 +1603,8 @@
 	return result;
 }
 
+
+
 int dlclose(void* handle)
 {
 	if ( dyld::gLogAPIs )
@@ -1709,14 +1615,7 @@
 		return 0;
 	if ( handle == RTLD_DEFAULT )
 		return 0;
-
-#if SUPPORT_ACCELERATE_TABLES
-	if ( dyld::isCacheHandle(handle) ) {
-		dlerrorClear();
-		return 0;
-	}
-#endif
-
+	
 	ImageLoader* image = (ImageLoader*)(((uintptr_t)handle) & (-4));	// clear mode bits
 	if ( dyld::validImage(image) ) {
 		dlerrorClear();
@@ -1742,12 +1641,6 @@
 {
 	if ( dyld::gLogAPIs )
 		dyld::log("%s(%p, %p)\n", __func__, address, info);
-
-	// <rdar://problem/42171466> calling dladdr(xx,NULL) crashes
-	if ( info == NULL )
-		return 0; // failure
-
-	address = stripPointer(address);
 
 	CRSetCrashLogMessage("dyld: in dladdr()");
 #if SUPPORT_ACCELERATE_TABLES
@@ -1816,13 +1709,14 @@
 	return NULL;
 }
 
-void* dlsym_internal(void* handle, const char* symbolName, void* callerAddress)
+void* dlsym(void* handle, const char* symbolName)
 {
 	if ( dyld::gLogAPIs )
 		dyld::log("%s(%p, %s)\n", __func__, handle, symbolName);
 
 #if SUPPORT_ACCELERATE_TABLES
 	if ( dyld::gLogAppAPIs ) {
+		void* callerAddress = __builtin_return_address(1); // note layers: 1: real client, 0: libSystem glue
 		const char* shortName;
 		if ( callerIsNonOSApp(callerAddress, &shortName) ) {
 			dyld::log("%s: %s(%p, %s)\n", shortName, __func__, handle, symbolName);
@@ -1848,20 +1742,6 @@
 		if ( dyld::flatFindExportedSymbol(underscoredName, &sym, &image) ) {
 			CRSetCrashLogMessage(NULL);
 			result = (void*)image->getExportedSymbolAddress(sym, dyld::gLinkContext, NULL, false, underscoredName);
-#if __has_feature(ptrauth_calls)
-			// Sign the pointer if it points to a function
-			// Note we only do this if the main executable is arm64e as otherwise we
-			// may end up calling containsAddress on the accelerator tables.
-			if ( result && ((dyld::gLinkContext.mainExecutable->machHeader()->cpusubtype  & ~CPU_SUBTYPE_MASK) == CPU_SUBTYPE_ARM64E) ) {
-				const ImageLoader* symbolImage = image;
-				if (!symbolImage->containsAddress(result)) {
-					symbolImage = dyld::findImageContainingAddress(result);
-				}
-				const macho_section *sect = symbolImage ? symbolImage->findSection(result) : NULL;
-				if ( sect && ((sect->flags & S_ATTR_PURE_INSTRUCTIONS) || (sect->flags & S_ATTR_SOME_INSTRUCTIONS)) )
-					result = __builtin_ptrauth_sign_unauthenticated(result, ptrauth_key_asia, 0);
-			}
-#endif
 			if ( dyld::gLogAPIs )
 				dyld::log("  %s(RTLD_DEFAULT, %s) ==> %p\n", __func__, symbolName, result);
 			return result;
@@ -1882,20 +1762,6 @@
 		if ( sym != NULL ) {
 			CRSetCrashLogMessage(NULL);
 			result = (void*)image->getExportedSymbolAddress(sym, dyld::gLinkContext, NULL, false, underscoredName);
-#if __has_feature(ptrauth_calls)
-			// Sign the pointer if it points to a function
-			// Note we only do this if the main executable is arm64e as otherwise we
-			// may end up calling containsAddress on the accelerator tables.
-			if ( result && ((dyld::gLinkContext.mainExecutable->machHeader()->cpusubtype  & ~CPU_SUBTYPE_MASK) == CPU_SUBTYPE_ARM64E) ) {
-				const ImageLoader* symbolImage = image;
-				if (!symbolImage->containsAddress(result)) {
-					symbolImage = dyld::findImageContainingAddress(result);
-				}
-				const macho_section *sect = symbolImage ? symbolImage->findSection(result) : NULL;
-				if ( sect && ((sect->flags & S_ATTR_PURE_INSTRUCTIONS) || (sect->flags & S_ATTR_SOME_INSTRUCTIONS)) )
-					result = __builtin_ptrauth_sign_unauthenticated(result, ptrauth_key_asia, 0);
-			}
-#endif
 			if ( dyld::gLogAPIs )
 				dyld::log("  %s(RTLD_MAIN_ONLY, %s) ==> %p\n", __func__, symbolName, result);
 			return result;
@@ -1911,6 +1777,7 @@
 	
 	// magic "search what I would see" handle
 	else if ( handle == RTLD_NEXT ) {
+		void* callerAddress = __builtin_return_address(1); // note layers: 1: real client, 0: libSystem glue
 #if SUPPORT_ACCELERATE_TABLES
 		const mach_header* mh;
 		const char* path;
@@ -1928,20 +1795,6 @@
 		if ( sym != NULL ) {
 			CRSetCrashLogMessage(NULL);
 			result = (void*)image->getExportedSymbolAddress(sym, dyld::gLinkContext , callerImage, false, underscoredName);
-#if __has_feature(ptrauth_calls)
-			// Sign the pointer if it points to a function
-			// Note we only do this if the main executable is arm64e as otherwise we
-			// may end up calling containsAddress on the accelerator tables.
-			if ( result && ((dyld::gLinkContext.mainExecutable->machHeader()->cpusubtype  & ~CPU_SUBTYPE_MASK) == CPU_SUBTYPE_ARM64E) ) {
-				const ImageLoader* symbolImage = image;
-				if (!symbolImage->containsAddress(result)) {
-					symbolImage = dyld::findImageContainingAddress(result);
-				}
-				const macho_section *sect = symbolImage ? symbolImage->findSection(result) : NULL;
-				if ( sect && ((sect->flags & S_ATTR_PURE_INSTRUCTIONS) || (sect->flags & S_ATTR_SOME_INSTRUCTIONS)) )
-					result = __builtin_ptrauth_sign_unauthenticated(result, ptrauth_key_asia, 0);
-			}
-#endif
 			if ( dyld::gLogAPIs )
 				dyld::log("  %s(RTLD_NEXT, %s) ==> %p\n", __func__, symbolName, result);
 			return result;
@@ -1956,6 +1809,7 @@
 	}
 	// magic "search me, then what I would see" handle
 	else if ( handle == RTLD_SELF ) {
+		void* callerAddress = __builtin_return_address(1); // note layers: 1: real client, 0: libSystem glue
 #if SUPPORT_ACCELERATE_TABLES
 		const mach_header* mh;
 		const char* path;
@@ -1973,20 +1827,6 @@
 		if ( sym != NULL ) {
 			CRSetCrashLogMessage(NULL);
 			result = (void*)image->getExportedSymbolAddress(sym, dyld::gLinkContext, callerImage, false, underscoredName);
-#if __has_feature(ptrauth_calls)
-			// Sign the pointer if it points to a function
-			// Note we only do this if the main executable is arm64e as otherwise we
-			// may end up calling containsAddress on the accelerator tables.
-			if ( result && ((dyld::gLinkContext.mainExecutable->machHeader()->cpusubtype & ~CPU_SUBTYPE_MASK) == CPU_SUBTYPE_ARM64E) ) {
-				const ImageLoader* symbolImage = image;
-				if (!symbolImage->containsAddress(result)) {
-					symbolImage = dyld::findImageContainingAddress(result);
-				}
-				const macho_section *sect = symbolImage ? symbolImage->findSection(result) : NULL;
-				if ( sect && ((sect->flags & S_ATTR_PURE_INSTRUCTIONS) || (sect->flags & S_ATTR_SOME_INSTRUCTIONS)) )
-					result = __builtin_ptrauth_sign_unauthenticated(result, ptrauth_key_asia, 0);
-			}
-#endif
 			if ( dyld::gLogAPIs )
 				dyld::log("  %s(RTLD_SELF, %s) ==> %p\n", __func__, symbolName, result);
 			return result;
@@ -2021,23 +1861,10 @@
 			ImageLoader* callerImage = NULL;
 			if ( sDynamicInterposing ) {
 				// only take time to look up caller, if dynamic interposing in use
+				void* callerAddress = __builtin_return_address(1); // note layers: 1: real client, 0: libSystem glue
 				callerImage = dyld::findImageContainingAddress(callerAddress);
 			}
 			result = (void*)image->getExportedSymbolAddress(sym, dyld::gLinkContext, callerImage, false, underscoredName);
-#if __has_feature(ptrauth_calls)
-			// Sign the pointer if it points to a function
-			// Note we only do this if the main executable is arm64e as otherwise we
-			// may end up calling containsAddress on the accelerator tables.
-			if ( result && ((dyld::gLinkContext.mainExecutable->machHeader()->cpusubtype & ~CPU_SUBTYPE_MASK) == CPU_SUBTYPE_ARM64E) ) {
-				const ImageLoader* symbolImage = image;
-				if (!symbolImage->containsAddress(result)) {
-					symbolImage = dyld::findImageContainingAddress(result);
-				}
-				const macho_section *sect = symbolImage ? symbolImage->findSection(result) : NULL;
-				if ( sect && ((sect->flags & S_ATTR_PURE_INSTRUCTIONS) || (sect->flags & S_ATTR_SOME_INSTRUCTIONS)) )
-					result = __builtin_ptrauth_sign_unauthenticated(result, ptrauth_key_asia, 0);
-			}
-#endif
 			if ( dyld::gLogAPIs )
 				dyld::log("  %s(%p, %s) ==> %p\n", __func__, handle, symbolName, result);
 			return result;
@@ -2055,25 +1882,11 @@
 	return NULL;
 }
 
-// Note this is only here to support ___pthread_abort in libpthread.a
-void* dlsym(void* handle, const char* symbolName) {
-	return dlsym_internal(handle, symbolName, __builtin_return_address(1));
-}
-
-
-// <rdar://problem/40352925> *_compat functions are for old binaries that have __dyld section and use it to bypass libdyld.dylib
-void* dlopen_compat(const char* path, int mode)
-{
-	return dlopen_internal(path, mode, (void*)dyld::mainExecutable()->machHeader());
-}
-bool  dlopen_preflight_compat(const char* path)
-{
-	return dlopen_preflight_internal(path, (void*)dyld::mainExecutable()->machHeader());
-}
-void* dlsym_compat(void* handle, const char* symbolName)
-{
-	return dlsym_internal(handle, symbolName, (void*)dyld::mainExecutable()->machHeader());
-}
+
+
+
+
+
 
 
 
@@ -2089,8 +1902,6 @@
 {
 	//if ( dyld::gLogAPIs )
 	//	dyld::log("%s(%p, %p)\n", __func__, addr, info);
-
-	addr = stripPointer(addr);
 	
 #if SUPPORT_ACCELERATE_TABLES
 	if ( dyld::findUnwindSections(addr, info) )
@@ -2111,8 +1922,6 @@
 	if ( dyld::gLogAPIs )
 		dyld::log("%s(%p)\n", __func__, address);
 
-    address = (void*)stripPointer(address);
-    
 #if SUPPORT_ACCELERATE_TABLES
 	const mach_header* mh;
 	const char* path;
@@ -2121,9 +1930,8 @@
 #endif
 
 	ImageLoader* image = dyld::findImageContainingAddress(address);
-	if ( image != NULL ) {
+	if ( image != NULL )
 		return image->getRealPath();
-	}
 	return NULL;
 }
 
@@ -2146,9 +1954,6 @@
 	ImageLoader* image = dyld::findImageByMachHeader(mh);
 	if ( image == NULL )
 		return;
-
-	// make the cache writable for this block
-	DyldSharedCache::DataConstScopedWriter patcher(dyld::gLinkContext.dyldCache, mach_task_self(), (dyld::gLinkContext.verboseMapping ? &dyld::log : nullptr));
 	
 	// make pass at bound references in this image and update them
 	dyld::gLinkContext.dynamicInterposeArray = array;
@@ -2219,55 +2024,11 @@
     const DyldSharedCache* cache = (DyldSharedCache*)dyld::imMemorySharedCacheHeader();
     if ( cache != nullptr ) {
         const dyld_cache_mapping_info* const mappings = (dyld_cache_mapping_info*)((char*)cache + cache->header.mappingOffset);
-		const dyld_cache_mapping_info* lastMapping = &mappings[cache->header.mappingCount - 1];
-        *length = (size_t)((lastMapping->address + lastMapping->size) - cache->unslidLoadAddress());
+        *length = (size_t)((mappings[2].address + mappings[2].size) - mappings[0].address);
         return cache;
     }
 	return nullptr;
 }
 
-void _dyld_images_for_addresses(unsigned count, const void* addresses[], struct dyld_image_uuid_offset infos[])
-{
-	for (unsigned i=0; i < count; ++i) {
-        const void* addr = addresses[i];
-		addr = stripPointer(addr);
-        bzero(&infos[i], sizeof(dyld_image_uuid_offset));
-#if SUPPORT_ACCELERATE_TABLES
-		const mach_header* 	mh;
-		const char* 		path;
-		if ( dyld::addressInCache(addr, &mh, &path) ) {
-			infos[i].image         = mh;
-			infos[i].offsetInImage = (uintptr_t)addr - (uintptr_t)mh;
-			((dyld3::MachOFile*)mh)->getUuid(infos[i].uuid);
-			continue;
-		}
-#endif
-		ImageLoader* image = dyld::findImageContainingAddress(addr);
-        if ( image != nullptr ) {
-            infos[i].image         = image->machHeader();
-            infos[i].offsetInImage = (uintptr_t)addr - (uintptr_t)(image->machHeader());
-            image->getUUID(infos[i].uuid);
-        }
-    }
-}
-
-void _dyld_register_for_image_loads(void (*func)(const mach_header* mh, const char* path, bool unloadable))
-{
-	if ( dyld::gLogAPIs )
-		dyld::log("%s(%p)\n", __func__, (void *)func);
-	dyld::registerLoadCallback(func);
-}
-
-void _dyld_register_for_bulk_image_loads(void (*func)(unsigned imageCount, const struct mach_header* mhs[], const char* paths[]))
-{
-	if ( dyld::gLogAPIs )
-		dyld::log("%s(%p)\n", __func__, (void *)func);
-	dyld::registerBulkLoadCallback(func);
-}
-
-void _dyld_register_driverkit_main(void (*mainFunc)())
-{
-	dyld::setMainEntry(mainFunc);
-}
-
-
+
+