Loading...
src/dyldAPIs.cpp dyld-46.9 dyld-44.2
--- dyld/dyld-46.9/src/dyldAPIs.cpp
+++ dyld/dyld-44.2/src/dyldAPIs.cpp
@@ -33,7 +33,6 @@
 #include <string.h>
 #include <mach/mach.h>
 #include <sys/time.h>
-#include <sys/sysctl.h>
 
 extern "C" mach_port_name_t	task_self_trap(void);  // can't include <System/mach/mach_traps.h> because it is missing extern C
 
@@ -401,11 +400,12 @@
 
 
 static __attribute__((noinline)) 
-const struct mach_header* addImage(void* callerAddress, const char* path, bool search, bool dontLoad, bool matchInstallName, bool abortOnError)
+const struct mach_header* addImage(const char* path, bool search, bool dontLoad, bool matchInstallName, bool abortOnError)
 {
 	ImageLoader*	image = NULL;
 	try {
 		dyld::clearErrorMessage();
+		void* callerAddress = __builtin_return_address(2); // note layers: 2: real client, 1: libSystem glue, 0: dyld API
 		ImageLoader* callerImage = dyld::findImageContainingAddress(callerAddress);
 		dyld::LoadContext context;
 		context.useSearchPaths		= search;
@@ -447,24 +447,21 @@
 	const bool search = ( (options & NSADDIMAGE_OPTION_WITH_SEARCHING) != 0 );
 	const bool matchInstallName = ( (options & NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME) != 0 );
 	const bool abortOnError = ( (options & NSADDIMAGE_OPTION_RETURN_ON_ERROR) == 0 );
-	void* callerAddress = __builtin_return_address(1); // note layers: 1: real client, 0: libSystem glue
-	return addImage(callerAddress, path, search, dontLoad, matchInstallName, abortOnError);
+	return addImage(path, search, dontLoad, matchInstallName, abortOnError);
 }
 
 bool NSAddLibrary(const char* path)
 {
 	if ( dyld::gLogAPIs )
 		fprintf(stderr, "%s(\"%s\")\n", __func__, path);
-	void* callerAddress = __builtin_return_address(1); // note layers: 1: real client, 0: libSystem glue
-	return (addImage(callerAddress, path, false, false, false, false) != NULL);
+	return (addImage(path, false, false, false, false) != NULL);
 }
 
 bool NSAddLibraryWithSearching(const char* path)
 {
 	if ( dyld::gLogAPIs )
 		fprintf(stderr, "%s(\"%s\")\n", __func__, path);
-	void* callerAddress = __builtin_return_address(1); // note layers: 1: real client, 0: libSystem glue
-	return (addImage(callerAddress, path, true, false, false, false) != NULL);
+	return (addImage(path, true, false, false, false) != NULL);
 }
 
 
@@ -1560,29 +1557,6 @@
 		else {
 			uint32_t imageCount = preboundImages.size();
 			uint32_t imageNumber = 1;
-
-			// on Intel system, update_prebinding is run twice: i386, then emulated ppc
-			// calculate fudge factors so that progress output represents both runs
-			int denomFactor = 1;
-			int numerAddend = 0;
-			if (UPDATE_PREBINDING_PROGRESS & flags) {
-		#if __i386__
-				// i386 half runs first, just double denominator
-				denomFactor = 2;
-		#endif	
-		#if __ppc__
-				// if emulated ppc, double denominator and shift numerator
-				int mib[] = { CTL_KERN, KERN_CLASSIC, getpid() };
-				int is_emulated = 0;
-				size_t len = sizeof(int);
-				int ret = sysctl(mib, 3, &is_emulated, &len, NULL, 0);
-				if ((ret != -1) && is_emulated) {
-					denomFactor = 2;
-					numerAddend = imageCount;
-				}
-		#endif
-			}
-
 			// tell each image to write itself out re-prebound
 			struct timeval currentTime = { 0 , 0 };
 			gettimeofday(&currentTime, NULL);
@@ -1592,7 +1566,7 @@
 				uint64_t freespace = (*it)->reprebind(dyld::gLinkContext, timestamp);
 				updatedImages.push_back(*it);
 				if(UPDATE_PREBINDING_PROGRESS & flags) {
-					fprintf(stdout, "update_prebinding: progress: %3u/%u\n", imageNumber+numerAddend, imageCount*denomFactor);
+					fprintf(stdout, "update_prebinding: progress: %3u/%u\n", imageNumber, imageCount);
 					fflush(stdout);
 					imageNumber++;
 				}