Loading...
src/ImageLoader.cpp dyld-210.2.3 dyld-195.5
--- dyld/dyld-210.2.3/src/ImageLoader.cpp
+++ dyld/dyld-195.5/src/ImageLoader.cpp
@@ -64,7 +64,7 @@
 
 
 ImageLoader::ImageLoader(const char* path, unsigned int libCount)
-	: fPath(path), fRealPath(NULL), fDevice(0), fInode(0), fLastModified(0), 
+	: fPath(path), fDevice(0), fInode(0), fLastModified(0), 
 	fPathHash(0), fDlopenReferenceCount(0), fStaticReferenceCount(0),
 	fDynamicReferenceCount(0), fDynamicReferences(NULL), fInitializerRecursiveLock(NULL), 
 	fDepth(0), fLoadOrder(fgLoadOrdinal++), fState(0), fLibraryCount(libCount), 
@@ -72,8 +72,7 @@
 	fHideSymbols(false), fMatchByInstallName(false),
 	fInterposed(false), fRegisteredDOF(false), fAllLazyPointersBound(false), 
     fBeingRemoved(false), fAddFuncNotified(false),
-	fPathOwnedByImage(false), fIsReferencedDownward(false), 
-	fIsReferencedUpward(false), fWeakSymbolsBound(false)
+	fPathOwnedByImage(false), fWeakSymbolsBound(false)
 {
 	if ( fPath != NULL )
 		fPathHash = hash(fPath);
@@ -97,8 +96,6 @@
 
 ImageLoader::~ImageLoader()
 {
-	if ( fRealPath != NULL ) 
-		delete [] fRealPath;
 	if ( fPathOwnedByImage && (fPath != NULL) ) 
 		delete [] fPath;
 	if ( fDynamicReferences != NULL ) {
@@ -169,7 +166,6 @@
 	strcpy((char*)fPath, path);
 	fPathOwnedByImage = true;  // delete fPath when this image is destructed
 	fPathHash = hash(fPath);
-	fRealPath = NULL;
 }
 
 void ImageLoader::setPathUnowned(const char* path)
@@ -180,21 +176,6 @@
 	fPath = path;
 	fPathOwnedByImage = false;  
 	fPathHash = hash(fPath);
-}
-
-void ImageLoader::setPaths(const char* path, const char* realPath)
-{
-	this->setPath(path);
-	fRealPath = new char[strlen(realPath)+1];
-	strcpy((char*)fRealPath, realPath);
-}
-
-const char* ImageLoader::getRealPath() const 
-{ 
-	if ( fRealPath != NULL ) 
-		return fRealPath;
-	else
-		return fPath; 
 }
 
 
@@ -262,6 +243,8 @@
 
 bool ImageLoader::containsAddress(const void* addr) const
 {
+	if ( ! this->isLinked() )
+		return false;
 	for(unsigned int i=0, e=segmentCount(); i < e; ++i) {
 		const uint8_t* start = (const uint8_t*)segActualLoadAddress(i);
 		const uint8_t* end = (const uint8_t*)segActualEndAddress(i);
@@ -318,6 +301,7 @@
 			const ImageLoader** dsiStart, const ImageLoader**& dsiCur, const ImageLoader** dsiEnd, const ImageLoader** foundIn) const
 {
 	const ImageLoader::Symbol* sym;
+	
 	// search self
 	if ( notInImgageList(this, dsiStart, dsiCur) ) {
 		sym = this->findExportedSymbol(name, false, foundIn);
@@ -497,7 +481,7 @@
 		unsigned int minDependentDepth = maxDepth;
 		for(unsigned int i=0; i < libraryCount(); ++i) {
 			ImageLoader* dependentImage = libImage(i);
-			if ( (dependentImage != NULL) && !libIsUpward(i) ) {
+			if ( dependentImage != NULL ) {
 				unsigned int d = dependentImage->recursiveUpdateDepth(maxDepth);
 				if ( d < minDependentDepth )
 					minDependentDepth = d;
@@ -554,13 +538,8 @@
 				}
 				if ( fNeverUnload )
 					dependentLib->setNeverUnload();
-				if ( requiredLibInfo.upward ) {
-					dependentLib->fIsReferencedUpward = true;
-				}
-				else { 
+				if ( ! requiredLibInfo.upward )
 					dependentLib->fStaticReferenceCount += 1;
-					dependentLib->fIsReferencedDownward = true;
-				}
 				LibraryInfo actualInfo = dependentLib->doGetLibraryInfo();
 				depLibReRequired = requiredLibInfo.required;
 				depLibCheckSumsMatch = ( actualInfo.checksum == requiredLibInfo.info.checksum );
@@ -570,8 +549,7 @@
 					depLibReExported = dependentLib->isSubframeworkOf(context, this) || this->hasSubLibrary(context, dependentLib);
 				}
 				// check found library version is compatible
-				// <rdar://problem/89200806> 0xFFFFFFFF is wildcard that matches any version
-				if ( (requiredLibInfo.info.minVersion != 0xFFFFFFFF) && (actualInfo.minVersion < requiredLibInfo.info.minVersion) ) {
+				if ( actualInfo.minVersion < requiredLibInfo.info.minVersion ) {
 					// record values for possible use by CrashReporter or Finder
 					dyld::throwf("Incompatible library version: %s requires version %d.%d.%d or later, but %s provides version %d.%d.%d",
 							this->getShortName(), requiredLibInfo.info.minVersion >> 16, (requiredLibInfo.info.minVersion >> 8) & 0xff, requiredLibInfo.info.minVersion & 0xff,
@@ -604,7 +582,7 @@
 						(*context.setErrorStrings)(dyld_error_kind_dylib_wrong_arch, this->getPath(), requiredLibInfo.name, NULL);
 					else
 						(*context.setErrorStrings)(dyld_error_kind_dylib_missing, this->getPath(), requiredLibInfo.name, NULL);
-					dyld::throwf("Library not loaded: %s\n  Referenced from: %s\n  Reason: %s", requiredLibInfo.name, this->getRealPath(), msg);
+					dyld::throwf("Library not loaded: %s\n  Referenced from: %s\n  Reason: %s", requiredLibInfo.name, this->getPath(), msg);
 				}
 				// ok if weak library not found
 				dependentLib = NULL;
@@ -894,25 +872,20 @@
 		// break cycles
 		fState = dyld_image_state_dependents_initialized-1;
 		try {
-			bool hasUpwards = false;
 			// initialize lower level libraries first
 			for(unsigned int i=0; i < libraryCount(); ++i) {
 				ImageLoader* dependentImage = libImage(i);
-				if ( dependentImage != NULL ) {
-					// don't try to initialize stuff "above" me
-					bool isUpward = libIsUpward(i);
-					if ( (dependentImage->fDepth >= fDepth) && !isUpward ) {
-						dependentImage->recursiveInitialization(context, this_thread, timingInfo);
-					}
-					hasUpwards |= isUpward;
-                }
+				if ( dependentImage != NULL )
+				// don't try to initialize stuff "above" me
+				if ( (dependentImage != NULL) && (dependentImage->fDepth >= fDepth) && !libIsUpward(i) )
+					dependentImage->recursiveInitialization(context, this_thread, timingInfo);
 			}
 			
 			// record termination order
 			if ( this->needsTermination() )
 				context.terminationRecorder(this);
 			
-			// let objc know we are about to initialize this image
+			// let objc know we are about to initalize this image
 			uint64_t t1 = mach_absolute_time();
 			fState = dyld_image_state_dependents_initialized;
 			oldState = fState;
@@ -921,19 +894,7 @@
 			// initialize this image
 			bool hasInitializers = this->doInitialization(context);
 			
-			// <rdar://problem/10491874> initialize any upward depedencies
-			if ( hasUpwards ) {
-				for(unsigned int i=0; i < libraryCount(); ++i) {
-					ImageLoader* dependentImage = libImage(i);
-					// <rdar://problem/10643239> ObjC CG hang
-					// only init upward lib here if lib is not downwardly referenced somewhere 
-					if ( (dependentImage != NULL) && libIsUpward(i) && !dependentImage->isReferencedDownward() ) {
-						dependentImage->recursiveInitialization(context, this_thread, timingInfo);
-					}
-				}
-			}
-            
-			// let anyone know we finished initializing this image
+			// let anyone know we finished initalizing this image
 			fState = dyld_image_state_initialized;
 			oldState = fState;
 			context.notifySingle(dyld_image_state_initialized, this);