]> git.saurik.com Git - apple/dyld.git/commitdiff
dyld-655.1.tar.gz macos-10143 v655.1
authorApple <opensource@apple.com>
Mon, 17 Jun 2019 20:50:25 +0000 (20:50 +0000)
committerApple <opensource@apple.com>
Mon, 17 Jun 2019 20:50:25 +0000 (20:50 +0000)
dyld3/ClosureBuilder.cpp
dyld3/shared-cache/update_dyld_shared_cache.cpp

index d9dd60c2084bc443763ddc513231024cf68239ff..02bdc853845fa0865ffaaec5861cd2ae912b9074 100644 (file)
@@ -1724,6 +1724,9 @@ const LaunchClosure* ClosureBuilder::makeLaunchClosure(const LoadedFileInfo& fil
     for (uint32_t i=0; i <= _mainProgLoadIndex; ++i)
         computeInitOrder(writers[i], i);
 
+    if ( _diag.hasError() )
+        return nullptr;
+
     // combine all Image objects into one ImageArray
     ImageArrayWriter imageArrayWriter(_startImageNum, (uint32_t)writers.count());
     for (ImageWriter& writer : writers) {
@@ -1969,6 +1972,9 @@ const DlopenClosure* ClosureBuilder::makeDlopenClosure(const char* path, const L
         }
     }
 
+    if ( _diag.hasError() )
+        return nullptr;
+
     // check if top image loaded is in shared cache along with everything it depends on
     *topImageNum = foundTopImage->imageNum;
     if ( writers.count() == 0 ) {
@@ -1982,6 +1988,9 @@ const DlopenClosure* ClosureBuilder::makeDlopenClosure(const char* path, const L
     // add initializer order into top level Image
     computeInitOrder(writers[0], (uint32_t)alreadyLoadedList.count());
 
+    if ( _diag.hasError() )
+        return nullptr;
+
     // combine all Image objects into one ImageArray
     ImageArrayWriter imageArrayWriter(_startImageNum, (uint32_t)writers.count());
     for (ImageWriter& writer : writers) {
index 6a0113e979f68932c3827e9d7d9e1d7c24ac8cb5..b906f989ab01ebad7f356f9afcfc412018c46545 100644 (file)
@@ -359,7 +359,10 @@ static bool dontCache(const std::string& volumePrefix, const std::string& archNa
 
     const char* installName = aFile.mh->installName();
     if ( (pathsWithDuplicateInstallName.count(aFile.runtimePath) != 0) && (aFile.runtimePath != installName) ) {
-        if (warn) fprintf(stderr, "update_dyld_shared_cache: warning: %s skipping because of duplicate install name %s\n", archName.c_str(), aFile.runtimePath.c_str());
+        // <rdar://problem/46431467> if a dylib moves and a symlink is installed into its place, bom iterator will see both and issue a warning
+        struct stat statBuf;
+        bool isSymLink = ( (lstat(aFile.runtimePath.c_str(), &statBuf) == 0) && S_ISLNK(statBuf.st_mode) );
+        if (!isSymLink && warn) fprintf(stderr, "update_dyld_shared_cache: warning: %s skipping because of duplicate install name %s\n", archName.c_str(), aFile.runtimePath.c_str());
         return true;
     }
 
@@ -411,8 +414,11 @@ static void pruneCachedDylibs(const std::string& volumePrefix, const std::unorde
     }
 
     for (DyldSharedCache::MappedMachO& aFile : fileSet.dylibsForCache) {
-        if ( dontCache(volumePrefix, fileSet.archName, pathsWithDuplicateInstallName, aFile, true, skipDylibs) )
-            fileSet.otherDylibsAndBundles.push_back(aFile);
+        if ( dontCache(volumePrefix, fileSet.archName, pathsWithDuplicateInstallName, aFile, true, skipDylibs) ) {
+            // <rdar://problem/46423929> don't build dlopen closures for symlinks to something in the dyld cache
+            if ( pathsWithDuplicateInstallName.count(aFile.runtimePath) == 0 )
+                fileSet.otherDylibsAndBundles.push_back(aFile);
+        }
     }
     fileSet.dylibsForCache.erase(std::remove_if(fileSet.dylibsForCache.begin(), fileSet.dylibsForCache.end(),
         [&](const DyldSharedCache::MappedMachO& aFile) { return dontCache(volumePrefix, fileSet.archName, pathsWithDuplicateInstallName, aFile, false, skipDylibs); }),