Loading...
dyld3/shared-cache/DyldSharedCache.cpp dyld-832.7.3 dyld-732.8
--- dyld/dyld-832.7.3/dyld3/shared-cache/DyldSharedCache.cpp
+++ dyld/dyld-732.8/dyld3/shared-cache/DyldSharedCache.cpp
@@ -41,7 +41,7 @@
 #include <vector>
 #include <unordered_map>
 #include <unordered_set>
-#include "SharedCacheBuilder.h"
+#include "CacheBuilder.h"
 #include "FileUtils.h"
 #endif
 
@@ -67,8 +67,8 @@
                                                        const std::vector<MappedMachO>&    otherOsDylibs,
                                                        const std::vector<MappedMachO>&    osExecutables)
 {
-    CreateResults       results;
-    SharedCacheBuilder  cache(options, fileSystem);
+    CreateResults  results;
+    CacheBuilder   cache(options, fileSystem);
     if (!cache.errorMessage().empty()) {
         results.errorMessage = cache.errorMessage();
         return results;
@@ -115,7 +115,7 @@
 
 bool DyldSharedCache::verifySelfContained(std::vector<MappedMachO>& dylibsToCache,
                                           std::unordered_set<std::string>& badZippered,
-                                          MappedMachO (^loader)(const std::string& runtimePath, Diagnostics& diag),
+                                          MappedMachO (^loader)(const std::string& runtimePath),
                                           std::vector<std::pair<DyldSharedCache::MappedMachO, std::set<std::string>>>& rejected)
 {
     // build map of dylibs
@@ -132,7 +132,6 @@
     }
 
     // check all dependencies to assure every dylib in cache only depends on other dylibs in cache
-    __block std::set<std::string> missingWeakDylibs;
     __block bool doAgain = true;
     while ( doAgain ) {
         __block std::vector<DyldSharedCache::MappedMachO> foundMappings;
@@ -142,8 +141,6 @@
             if ( badDylibs.count(dylib.runtimePath) != 0 )
                 continue;
             dylib.mh->forEachDependentDylib(^(const char* loadPath, bool isWeak, bool isReExport, bool isUpward, uint32_t compatVersion, uint32_t curVersion, bool& stop) {
-                if ( isWeak && (missingWeakDylibs.count(loadPath) != 0) )
-                    return;
                 if ( knownDylibs.count(loadPath) == 0 ) {
                     doAgain = true;
                     if ( badZippered.count(loadPath) != 0 ) {
@@ -154,24 +151,11 @@
                         badZippered.insert(dylib.mh->installName());
                         return;
                     }
-                    Diagnostics diag;
                     MappedMachO foundMapping;
                     if ( badDylibs.count(loadPath) == 0 )
-                        foundMapping = loader(loadPath, diag);
+                        foundMapping = loader(loadPath);
                     if ( foundMapping.length == 0 ) {
-                        // We allow weakly linked dylibs to be missing only if they are not present on disk
-                        // The shared cache doesn't contain enough information to patch them in later if they are
-                        // found on disk, so we don't want to pull something in to cache and cut it off from a dylib it
-                        // could have used.
-                        if ( isWeak ) {
-                            missingWeakDylibs.insert(loadPath);
-                            return;
-                        }
-
-                        if (diag.hasError())
-                            badDylibs[dylib.runtimePath].insert(diag.errorMessage());
-                        else
-                            badDylibs[dylib.runtimePath].insert(std::string("Could not find dependency '") + loadPath +"'");
+                        badDylibs[dylib.runtimePath].insert(std::string("Could not find dependency '") + loadPath +"'");
                         knownDylibs.erase(dylib.runtimePath);
                         knownDylibs.erase(dylib.mh->installName());
                     }
@@ -225,14 +209,7 @@
     return (const T)(addr + slide);
 }
 
-uint64_t DyldSharedCache::getCodeSignAddress() const
-{
-    auto mappings = (const dyld_cache_mapping_info*)((uint8_t*)this + header.mappingOffset);
-    return mappings[header.mappingCount-1].address + mappings[header.mappingCount-1].size;
-}
-
-void DyldSharedCache::forEachRegion(void (^handler)(const void* content, uint64_t vmAddr, uint64_t size, uint32_t permissions,
-                                                    uint64_t flags)) const
+void DyldSharedCache::forEachRegion(void (^handler)(const void* content, uint64_t vmAddr, uint64_t size, uint32_t permissions)) const
 {
     // <rdar://problem/49875993> sanity check cache header
     if ( strncmp(header.magic, "dyld_v1", 7) != 0 )
@@ -241,18 +218,10 @@
         return;
     if ( header.mappingCount > 20 )
         return;
-    if ( header.mappingOffset <= __offsetof(dyld_cache_header, mappingWithSlideOffset) ) {
-        const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((char*)this + header.mappingOffset);
-        const dyld_cache_mapping_info* mappingsEnd = &mappings[header.mappingCount];
-        for (const dyld_cache_mapping_info* m=mappings; m < mappingsEnd; ++m) {
-            handler((char*)this + m->fileOffset, m->address, m->size, m->initProt, 0);
-        }
-    } else {
-        const dyld_cache_mapping_and_slide_info* mappings = (const dyld_cache_mapping_and_slide_info*)((char*)this + header.mappingWithSlideOffset);
-        const dyld_cache_mapping_and_slide_info* mappingsEnd = &mappings[header.mappingCount];
-        for (const dyld_cache_mapping_and_slide_info* m=mappings; m < mappingsEnd; ++m) {
-            handler((char*)this + m->fileOffset, m->address, m->size, m->initProt, m->flags);
-        }
+    const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((char*)this + header.mappingOffset);
+    const dyld_cache_mapping_info* mappingsEnd = &mappings[header.mappingCount];
+    for (const dyld_cache_mapping_info* m=mappings; m < mappingsEnd; ++m) {
+        handler((char*)this + m->fileOffset, m->address, m->size, m->initProt);
     }
 }
 
@@ -267,8 +236,7 @@
     uintptr_t unslidStart = (uintptr_t)addr - slide;
 
     // quick out if after end of cache
-    const dyld_cache_mapping_info* lastMapping = &mappings[header.mappingCount - 1];
-    if ( unslidStart > (lastMapping->address + lastMapping->size) )
+    if ( unslidStart > (mappings[2].address + mappings[2].size) )
         return false;
 
     // walk cache regions
@@ -282,13 +250,6 @@
     }
 
     return false;
-}
-
-bool DyldSharedCache::isAlias(const char* path) const {
-    const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((char*)this + header.mappingOffset);
-    uintptr_t slide = (uintptr_t)this - (uintptr_t)(mappings[0].address);
-    // paths for aliases are store between cache header and first segment
-    return path < ((char*)mappings[0].address + slide);
 }
 
 void DyldSharedCache::forEachImage(void (^handler)(const mach_header* mh, const char* installName)) const
@@ -332,62 +293,6 @@
     }
 }
 
-const bool DyldSharedCache::hasLocalSymbolsInfo() const
-{
-    return (header.localSymbolsOffset != 0 && header.mappingOffset > offsetof(dyld_cache_header,localSymbolsSize));
-}
-
-const void* DyldSharedCache::getLocalNlistEntries() const
-{
-    // check for cache without local symbols info
-    if (!this->hasLocalSymbolsInfo())
-        return nullptr;
-    const auto localInfo = (dyld_cache_local_symbols_info*)((uint8_t*)this + header.localSymbolsOffset);
-    return (uint8_t*)localInfo + localInfo->nlistOffset;
-}
-
-const uint32_t DyldSharedCache::getLocalNlistCount() const
-{
-    // check for cache without local symbols info
-     if (!this->hasLocalSymbolsInfo())
-        return 0;
-    const auto localInfo = (dyld_cache_local_symbols_info*)((uint8_t*)this + header.localSymbolsOffset);
-    return localInfo->nlistCount;
-}
-
-const char* DyldSharedCache::getLocalStrings() const
-{
-    // check for cache without local symbols info
-     if (!this->hasLocalSymbolsInfo())
-        return nullptr;
-    const auto localInfo = (dyld_cache_local_symbols_info*)((uint8_t*)this + header.localSymbolsOffset);
-    return (char*)localInfo + localInfo->stringsOffset;
-}
-
-const uint32_t DyldSharedCache::getLocalStringsSize() const
-{
-    // check for cache without local symbols info
-     if (!this->hasLocalSymbolsInfo())
-        return 0;
-    const auto localInfo = (dyld_cache_local_symbols_info*)((uint8_t*)this + header.localSymbolsOffset);
-    return localInfo->stringsSize;
-}
-
- void DyldSharedCache::forEachLocalSymbolEntry(void (^handler)(uint32_t dylibOffset, uint32_t nlistStartIndex, uint32_t nlistCount, bool& stop)) const
-{
-    // check for cache without local symbols info
-     if (!this->hasLocalSymbolsInfo())
-        return;
-    const auto localInfo = (dyld_cache_local_symbols_info*)((uint8_t*)this + header.localSymbolsOffset);
-    const auto localEntries = (dyld_cache_local_symbols_entry*)((uint8_t*)localInfo + localInfo->entriesOffset);
-    bool stop = false;
-    for (uint32_t i = 0; i < localInfo->entriesCount; i++) {
-        dyld_cache_local_symbols_entry localEntry = localEntries[i];
-        handler(localEntry.dylibOffset, localEntry.nlistStartIndex, localEntry.nlistCount, stop);
-    }
-}
-
-
 const mach_header* DyldSharedCache::getIndexedImageEntry(uint32_t index, uint64_t& mTime, uint64_t& inode) const
 {
     const dyld_cache_image_info*   dylibs   = (dyld_cache_image_info*)((char*)this + header.imagesOffset);
@@ -397,17 +302,10 @@
     return (mach_header*)((uint8_t*)this + dylibs[index].address - mappings[0].address);
 }
 
-
- const char* DyldSharedCache::getIndexedImagePath(uint32_t index) const
-{
-    auto dylibs = (const dyld_cache_image_info*)((char*)this + header.imagesOffset);
-    return (char*)this + dylibs[index].pathFileOffset;
-}
-
 void DyldSharedCache::forEachImageTextSegment(void (^handler)(uint64_t loadAddressUnslid, uint64_t textSegmentSize, const uuid_t dylibUUID, const char* installName, bool& stop)) const
 {
     // check for old cache without imagesText array
-    if ( (header.mappingOffset <= __offsetof(dyld_cache_header, imagesTextOffset)) || (header.imagesTextCount == 0) )
+    if ( header.mappingOffset < 123 )
         return;
 
     // walk imageText table and call callback for each entry
@@ -460,8 +358,7 @@
     __block std::vector<uint64_t>   regionFileOffsets;
 
     result.reserve(256*1024);
-    forEachRegion(^(const void* content, uint64_t vmAddr, uint64_t size, uint32_t permissions,
-                    uint64_t flags) {
+    forEachRegion(^(const void* content, uint64_t vmAddr, uint64_t size, uint32_t permissions) {
         regionStartAddresses.push_back(vmAddr);
         regionSizes.push_back(size);
         regionFileOffsets.push_back((uint8_t*)content - (uint8_t*)this);
@@ -512,8 +409,7 @@
 {
     __block uint64_t startAddr = 0;
     __block uint64_t endAddr = 0;
-    forEachRegion(^(const void* content, uint64_t vmAddr, uint64_t size, uint32_t permissions,
-                    uint64_t flags) {
+    forEachRegion(^(const void* content, uint64_t vmAddr, uint64_t size, uint32_t permissions) {
         if ( startAddr == 0 )
             startAddr = vmAddr;
         uint64_t end = vmAddr+size;
@@ -577,16 +473,6 @@
     return false;
 }
 
-bool DyldSharedCache::isOverridablePath(const char* dylibPath) const
-{
-    // all dylibs in customer dyld cache cannot be overridden except libdispatch.dylib
-    if ( header.cacheType == kDyldSharedCacheTypeProduction ) {
-        return (strcmp(dylibPath, "/usr/lib/system/libdispatch.dylib") == 0);
-    }
-    // in dev caches we can override all paths
-    return true;
-}
-
 bool DyldSharedCache::hasNonOverridablePath(const char* dylibPath) const
 {
     // all dylibs in customer dyld cache cannot be overridden except libdispatch.dylib
@@ -594,19 +480,18 @@
     if ( header.cacheType == kDyldSharedCacheTypeProduction ) {
         uint32_t imageIndex;
         pathIsInDyldCacheWhichCannotBeOverridden = this->hasImagePath(dylibPath, imageIndex);
-        if ( pathIsInDyldCacheWhichCannotBeOverridden && isOverridablePath(dylibPath) )
+        if ( pathIsInDyldCacheWhichCannotBeOverridden && (strcmp(dylibPath, "/usr/lib/system/libdispatch.dylib") == 0) )
             pathIsInDyldCacheWhichCannotBeOverridden = false;
     }
     return pathIsInDyldCacheWhichCannotBeOverridden;
 }
 
-#if !BUILDING_LIBDSC
 const dyld3::closure::Image* DyldSharedCache::findDlopenOtherImage(const char* path) const
 {
     const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((char*)this + header.mappingOffset);
     if ( mappings[0].fileOffset != 0 )
         return nullptr;
-    if ( header.mappingOffset < __offsetof(dyld_cache_header, otherImageArrayAddr) )
+    if ( header.mappingOffset < sizeof(dyld_cache_header) )
         return nullptr;
     if ( header.otherImageArrayAddr == 0 )
         return nullptr;
@@ -626,6 +511,9 @@
     return nullptr;
 }
 
+
+
+
 const dyld3::closure::LaunchClosure* DyldSharedCache::findClosure(const char* executablePath) const
 {
     const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((char*)this + header.mappingOffset);
@@ -687,23 +575,7 @@
         }
     }
 }
-
-void DyldSharedCache::forEachDylibPath(void (^handler)(const char* dylibPath, uint32_t index)) const
-{
-    const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((char*)this + header.mappingOffset);
-    uintptr_t      slide                = (uintptr_t)this - (uintptr_t)(mappings[0].address);
-    const uint8_t* dylibTrieStart       = (uint8_t*)(this->header.dylibsTrieAddr + slide);
-    const uint8_t* dylibTrieEnd         = dylibTrieStart + this->header.dylibsTrieSize;
-
-   std::vector<DylibIndexTrie::Entry> dylibEntries;
-    if ( Trie<DylibIndex>::parseTrie(dylibTrieStart, dylibTrieEnd, dylibEntries) ) {
-        for (DylibIndexTrie::Entry& entry : dylibEntries ) {
-            handler(entry.name.c_str(), entry.info.index);
-        }
-    }
-}
-#endif // !BUILDING_LIBDYLD && !BUILDING_DYLD
-#endif // !BUILDING_LIBDSC
+#endif
 
 const dyld3::closure::ImageArray* DyldSharedCache::cachedDylibsImageArray() const
 {
@@ -722,7 +594,7 @@
 const dyld3::closure::ImageArray* DyldSharedCache::otherOSImageArray() const
 {
     // check for old cache without imagesArray
-    if ( header.mappingOffset < __offsetof(dyld_cache_header, otherImageArrayAddr) )
+    if ( header.mappingOffset < sizeof(dyld_cache_header) )
         return nullptr;
 
     if ( header.otherImageArrayAddr == 0 )
@@ -866,68 +738,25 @@
 
 #endif
 
-#if !(BUILDING_LIBDYLD || BUILDING_DYLD)
-dyld3::MachOAnalyzer::VMAddrConverter DyldSharedCache::makeVMAddrConverter(bool contentRebased) const {
-    typedef dyld3::MachOAnalyzer::VMAddrConverter VMAddrConverter;
-
-    __block VMAddrConverter::SharedCacheFormat pointerFormat = VMAddrConverter::SharedCacheFormat::none;
-    __block uint64_t pointerValueAdd = 0;;
-    forEachSlideInfo(^(uint64_t mappingStartAddress, uint64_t mappingSize, const uint8_t *mappingPagesStart, uint64_t slideInfoOffset, uint64_t slideInfoSize, const dyld_cache_slide_info *slideInfoHeader) {
-        assert(slideInfoHeader->version >= 2);
-        if ( slideInfoHeader->version == 2 ) {
-            const dyld_cache_slide_info2* slideInfo = (dyld_cache_slide_info2*)(slideInfoHeader);
-            assert(slideInfo->delta_mask == 0x00FFFF0000000000);
-            pointerFormat   = VMAddrConverter::SharedCacheFormat::v2_x86_64_tbi;
-            pointerValueAdd = slideInfo->value_add;
-        } else if ( slideInfoHeader->version == 3 ) {
-            pointerFormat   = VMAddrConverter::SharedCacheFormat::v3;
-            pointerValueAdd = unslidLoadAddress();
-        } else {
-            assert(false);
-        }
-    });
-
+
+
+const dyld_cache_slide_info* DyldSharedCache::slideInfo() const
+{
     const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((char*)this + header.mappingOffset);
     uintptr_t slide = (uintptr_t)this - (uintptr_t)(mappings[0].address);
 
-    VMAddrConverter vmAddrConverter;
-    vmAddrConverter.preferredLoadAddress            = pointerValueAdd;
-    vmAddrConverter.slide                           = slide;
-    vmAddrConverter.chainedPointerFormat            = 0;
-    vmAddrConverter.sharedCacheChainedPointerFormat = pointerFormat;
-    vmAddrConverter.contentRebased                  = contentRebased;
-
-    return vmAddrConverter;
-}
-#endif
-
-const dyld_cache_slide_info* DyldSharedCache::legacyCacheSlideInfo() const
-{
-    assert(header.mappingOffset <= __offsetof(dyld_cache_header, mappingWithSlideOffset));
-    const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((char*)this + header.mappingOffset);
-    uintptr_t slide = (uintptr_t)this - (uintptr_t)(mappings[0].address);
-
-    uint64_t offsetInLinkEditRegion = (header.slideInfoOffsetUnused - mappings[2].fileOffset);
+    uint64_t offsetInLinkEditRegion = (header.slideInfoOffset - mappings[2].fileOffset);
     return (dyld_cache_slide_info*)((uint8_t*)(mappings[2].address) + slide + offsetInLinkEditRegion);
 }
 
-const dyld_cache_mapping_info* DyldSharedCache::legacyCacheDataRegionMapping() const
-{
-    assert(header.mappingOffset <= __offsetof(dyld_cache_header, mappingWithSlideOffset));
-    const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((char*)this + header.mappingOffset);
-    return &mappings[1];
-}
-
-const uint8_t* DyldSharedCache::legacyCacheDataRegionBuffer() const
-{
-    assert(header.mappingOffset <= __offsetof(dyld_cache_header, mappingWithSlideOffset));
+const uint8_t* DyldSharedCache::dataRegionStart() const
+{
     const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((char*)this + header.mappingOffset);
     uintptr_t slide = (uintptr_t)this - (uintptr_t)(mappings[0].address);
     
-    return (uint8_t*)(legacyCacheDataRegionMapping()->address) + slide;
-}
-
-#if !BUILDING_LIBDSC
+    return (uint8_t*)(mappings[1].address) + slide;
+}
+
 const objc_opt::objc_opt_t* DyldSharedCache::objcOpt() const {
     // Find the objc image
     const dyld3::MachOAnalyzer* objcMA = nullptr;
@@ -981,7 +810,7 @@
     int64_t slide = objcMA->getSlide();
     uint32_t pointerSize = objcMA->pointerSize();
     objcMA->forEachSection(^(const dyld3::MachOAnalyzer::SectionInfo& info, bool malformedSectionRange, bool& stop) {
-        if ( (strncmp(info.segInfo.segName, "__DATA", 6) != 0) && (strncmp(info.segInfo.segName, "__AUTH", 6) != 0) )
+        if ( strncmp(info.segInfo.segName, "__DATA", 6) != 0 )
             return;
         if (strcmp(info.sectName, "__objc_opt_ptrs") != 0)
             return;
@@ -998,97 +827,6 @@
 
     return objcPointersContent;
 }
-#endif
-
-std::pair<const void*, uint64_t> DyldSharedCache::getObjCConstantRange() const {
-    const dyld3::MachOAnalyzer* libDyldMA = nullptr;
-    uint32_t imageIndex;
-    if ( hasImagePath("/usr/lib/system/libdyld.dylib", imageIndex) ) {
-        const dyld3::closure::ImageArray* images = cachedDylibsImageArray();
-        const dyld3::closure::Image* image = images->imageForNum(imageIndex+1);
-        libDyldMA = (const dyld3::MachOAnalyzer*)((uintptr_t)this + image->cacheOffset());
-
-        std::pair<const void*, uint64_t> ranges = { nullptr, 0 };
-#if TARGET_OS_OSX
-        ranges.first = libDyldMA->findSectionContent("__DATA", "__objc_ranges", ranges.second);
-#else
-        ranges.first = libDyldMA->findSectionContent("__DATA_CONST", "__objc_ranges", ranges.second);
-#endif
-        return ranges;
-    }
-
-    return { nullptr, 0 };
-}
-
-bool DyldSharedCache::hasSlideInfo() const {
-    if ( header.mappingOffset <= __offsetof(dyld_cache_header, mappingWithSlideOffset) ) {
-        return header.slideInfoSizeUnused != 0;
-    } else {
-        const dyld_cache_mapping_and_slide_info* slidableMappings = (const dyld_cache_mapping_and_slide_info*)((char*)this + header.mappingWithSlideOffset);
-        for (uint32_t i = 0; i != header.mappingWithSlideCount; ++i) {
-            if ( slidableMappings[i].slideInfoFileSize != 0 ) {
-                return true;
-            }
-        }
-    }
-    return false;
-}
-
-void DyldSharedCache::forEachSlideInfo(void (^handler)(uint64_t mappingStartAddress, uint64_t mappingSize,
-                                                       const uint8_t* mappingPagesStart,
-                                                       uint64_t slideInfoOffset, uint64_t slideInfoSize,
-                                                       const dyld_cache_slide_info* slideInfoHeader)) const {
-    if ( header.mappingOffset <= __offsetof(dyld_cache_header, mappingWithSlideOffset) ) {
-        // Old caches should get the slide info from the cache header and assume a single data region.
-        const dyld_cache_mapping_info* dataMapping = legacyCacheDataRegionMapping();
-        uint64_t dataStartAddress = dataMapping->address;
-        uint64_t dataSize = dataMapping->size;
-        const uint8_t* dataPagesStart = legacyCacheDataRegionBuffer();
-        const dyld_cache_slide_info* slideInfoHeader = legacyCacheSlideInfo();
-
-        handler(dataStartAddress, dataSize, dataPagesStart,
-                header.slideInfoOffsetUnused, header.slideInfoSizeUnused, slideInfoHeader);
-    } else {
-        const dyld_cache_mapping_and_slide_info* slidableMappings = (const dyld_cache_mapping_and_slide_info*)((char*)this + header.mappingWithSlideOffset);
-        const dyld_cache_mapping_and_slide_info* linkeditMapping = &slidableMappings[header.mappingWithSlideCount - 1];
-        uint64_t sharedCacheSlide = (uint64_t)this - unslidLoadAddress();
-
-        for (uint32_t i = 0; i != header.mappingWithSlideCount; ++i) {
-            if ( slidableMappings[i].slideInfoFileOffset != 0 ) {
-                // Get the data pages
-                uint64_t dataStartAddress = slidableMappings[i].address;
-                uint64_t dataSize = slidableMappings[i].size;
-                const uint8_t* dataPagesStart = (uint8_t*)dataStartAddress + sharedCacheSlide;
-
-                // Get the slide info
-                uint64_t offsetInLinkEditRegion = (slidableMappings[i].slideInfoFileOffset - linkeditMapping->fileOffset);
-                const dyld_cache_slide_info* slideInfoHeader = (dyld_cache_slide_info*)((uint8_t*)(linkeditMapping->address) + sharedCacheSlide + offsetInLinkEditRegion);
-                handler(dataStartAddress, dataSize, dataPagesStart,
-                        slidableMappings[i].slideInfoFileOffset, slidableMappings[i].slideInfoFileSize, slideInfoHeader);
-            }
-        }
-    }
-}
-
-#if BUILDING_LIBDYLD
-const char* DyldSharedCache::getCanonicalPath(const char *path) const {
-    uint32_t dyldCacheImageIndex;
-    if ( hasImagePath(path, dyldCacheImageIndex) )
-        return getIndexedImagePath(dyldCacheImageIndex);
-#if TARGET_OS_OSX
-    // on macOS support "Foo.framework/Foo" symlink
-    char resolvedPath[PATH_MAX];
-    realpath(path, resolvedPath);
-    int realpathErrno = errno;
-    // If realpath() resolves to a path which does not exist on disk, errno is set to ENOENT
-    if ( (realpathErrno == ENOENT) || (realpathErrno == 0) ) {
-        if ( hasImagePath(resolvedPath, dyldCacheImageIndex) )
-            return getIndexedImagePath(dyldCacheImageIndex);
-    }
-#endif
-    return nullptr;
-}
-#endif
 
 #if !(BUILDING_LIBDYLD || BUILDING_DYLD)
 void DyldSharedCache::fillMachOAnalyzersMap(std::unordered_map<std::string,dyld3::MachOAnalyzer*> & dylibAnalyzers) const {