Loading...
src/dyldAPIs.cpp dyld-852 dyld-732.8
--- dyld/dyld-852/src/dyldAPIs.cpp
+++ dyld/dyld-732.8/src/dyldAPIs.cpp
@@ -109,10 +109,10 @@
 
 
 // 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;
@@ -179,7 +179,6 @@
     {"__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
@@ -208,7 +207,7 @@
     {"__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 },
+
 
 #if DEPRECATED_APIS_SUPPORTED
 #pragma clang diagnostic push
@@ -391,14 +390,6 @@
 	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);
@@ -784,19 +775,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;
 }
 
@@ -1393,7 +1371,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 ) {
@@ -1424,7 +1402,7 @@
 	if ( dyld::inSharedCache(path) )
 		return true;
 
-#if TARGET_OS_OSX
+#if __MAC_OS_X_VERSION_MIN_REQUIRED
 	// <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];
@@ -1539,7 +1517,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 ) {
@@ -1852,7 +1830,7 @@
 			// 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) ) {
+			if ( result && (dyld::gLinkContext.mainExecutable->machHeader()->cpusubtype == CPU_SUBTYPE_ARM64E) ) {
 				const ImageLoader* symbolImage = image;
 				if (!symbolImage->containsAddress(result)) {
 					symbolImage = dyld::findImageContainingAddress(result);
@@ -1886,7 +1864,7 @@
 			// 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) ) {
+			if ( result && (dyld::gLinkContext.mainExecutable->machHeader()->cpusubtype == CPU_SUBTYPE_ARM64E) ) {
 				const ImageLoader* symbolImage = image;
 				if (!symbolImage->containsAddress(result)) {
 					symbolImage = dyld::findImageContainingAddress(result);
@@ -1932,7 +1910,7 @@
 			// 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) ) {
+			if ( result && (dyld::gLinkContext.mainExecutable->machHeader()->cpusubtype == CPU_SUBTYPE_ARM64E) ) {
 				const ImageLoader* symbolImage = image;
 				if (!symbolImage->containsAddress(result)) {
 					symbolImage = dyld::findImageContainingAddress(result);
@@ -1977,7 +1955,7 @@
 			// 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) ) {
+			if ( result && (dyld::gLinkContext.mainExecutable->machHeader()->cpusubtype == CPU_SUBTYPE_ARM64E) ) {
 				const ImageLoader* symbolImage = image;
 				if (!symbolImage->containsAddress(result)) {
 					symbolImage = dyld::findImageContainingAddress(result);
@@ -2028,7 +2006,7 @@
 			// 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) ) {
+			if ( result && (dyld::gLinkContext.mainExecutable->machHeader()->cpusubtype == CPU_SUBTYPE_ARM64E) ) {
 				const ImageLoader* symbolImage = image;
 				if (!symbolImage->containsAddress(result)) {
 					symbolImage = dyld::findImageContainingAddress(result);
@@ -2146,9 +2124,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,8 +2194,7 @@
     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;