Loading...
common/DyldSharedCache.cpp dyld-1042.1 dyld-1122.1
--- dyld/dyld-1042.1/common/DyldSharedCache.cpp
+++ dyld/dyld-1122.1/common/DyldSharedCache.cpp
@@ -22,6 +22,9 @@
  * @APPLE_LICENSE_HEADER_END@
  */
 
+#include <TargetConditionals.h>
+
+#if !TARGET_OS_EXCLAVEKIT
 
 #include <dirent.h>
 #include <sys/errno.h>
@@ -352,7 +355,7 @@
         return;
 
     for (uint32_t i = 0; i != header.subCacheArrayCount; ++i) {
-        const DyldSharedCache* cache = (const DyldSharedCache*)((uint8_t*)this + this->getSubCacheVmOffset(i));
+        const DyldSharedCache* cache = (const DyldSharedCache*)((uintptr_t)this + this->getSubCacheVmOffset(i));
         handler(cache, stop);
         if ( stop )
             return;
@@ -386,20 +389,20 @@
 
 void DyldSharedCache::getSubCacheUuid(uint8_t index, uint8_t uuid[]) const {
     if (header.mappingOffset <= __offsetof(dyld_cache_header, cacheSubType) ) {
-        const dyld_subcache_entry_v1* subCacheEntries = (dyld_subcache_entry_v1*)((uint8_t*)this + header.subCacheArrayOffset);
+        const dyld_subcache_entry_v1* subCacheEntries = (dyld_subcache_entry_v1*)((uintptr_t)this + header.subCacheArrayOffset);
         memcpy(uuid, subCacheEntries[index].uuid, 16);
     } else {
-        const dyld_subcache_entry* subCacheEntries = (dyld_subcache_entry*)((uint8_t*)this + header.subCacheArrayOffset);
+        const dyld_subcache_entry* subCacheEntries = (dyld_subcache_entry*)((uintptr_t)this + header.subCacheArrayOffset);
         memcpy(uuid, subCacheEntries[index].uuid, 16);
     }
 }
 
 uint64_t DyldSharedCache::getSubCacheVmOffset(uint8_t index) const {
     if (header.mappingOffset <= __offsetof(dyld_cache_header, cacheSubType) ) {
-        const dyld_subcache_entry_v1* subCacheEntries = (dyld_subcache_entry_v1*)((uint8_t*)this + header.subCacheArrayOffset);
+        const dyld_subcache_entry_v1* subCacheEntries = (dyld_subcache_entry_v1*)((uintptr_t)this + header.subCacheArrayOffset);
         return subCacheEntries[index].cacheVMOffset;
     } else {
-        const dyld_subcache_entry* subCacheEntries = (dyld_subcache_entry*)((uint8_t*)this + header.subCacheArrayOffset);
+        const dyld_subcache_entry* subCacheEntries = (dyld_subcache_entry*)((uintptr_t)this + header.subCacheArrayOffset);
         return subCacheEntries[index].cacheVMOffset;
     }
 }
@@ -542,7 +545,7 @@
     // 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);
+    const auto localInfo = (dyld_cache_local_symbols_info*)((uintptr_t)this + header.localSymbolsOffset);
     return getLocalNlistEntries(localInfo);
 }
 
@@ -551,7 +554,7 @@
     // 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);
+    const auto localInfo = (dyld_cache_local_symbols_info*)((uintptr_t)this + header.localSymbolsOffset);
     return localInfo->nlistCount;
 }
 
@@ -565,7 +568,7 @@
     // 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);
+    const auto localInfo = (dyld_cache_local_symbols_info*)((uintptr_t)this + header.localSymbolsOffset);
     return getLocalStrings(localInfo);
 }
 
@@ -574,7 +577,7 @@
     // 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);
+    const auto localInfo = (dyld_cache_local_symbols_info*)((uintptr_t)this + header.localSymbolsOffset);
     return localInfo->stringsSize;
 }
 
@@ -584,7 +587,7 @@
     const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((char*)this + header.mappingOffset);
     uint32_t dyldCacheImageIndex;
     if ( hasImagePath(dylibPath, dyldCacheImageIndex) )
-        return (dyld3::MachOFile*)((uint8_t*)this + dylibs[dyldCacheImageIndex].address - mappings[0].address);
+        return (dyld3::MachOFile*)((uintptr_t)this + dylibs[dyldCacheImageIndex].address - mappings[0].address);
     return nullptr;
 }
 
@@ -593,7 +596,7 @@
     // 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 localInfo = (dyld_cache_local_symbols_info*)((uintptr_t)this + header.localSymbolsOffset);
 
     if ( header.mappingOffset >= __offsetof(dyld_cache_header, symbolFileUUID) ) {
         // On new caches, the dylibOffset is 64-bits, and is a VM offset
@@ -618,10 +621,10 @@
 const mach_header* DyldSharedCache::getIndexedImageEntry(uint32_t index, uint64_t& mTime, uint64_t& inode) const
 {
     const dyld_cache_image_info*   dylibs   = images();
-    const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((char*)this + header.mappingOffset);
+    const dyld_cache_mapping_info* mappings = (dyld_cache_mapping_info*)((uintptr_t)this + header.mappingOffset);
     mTime = dylibs[index].modTime;
     inode = dylibs[index].inode;
-    return (mach_header*)((uint8_t*)this + dylibs[index].address - mappings[0].address);
+    return (mach_header*)((uintptr_t)this + dylibs[index].address - mappings[0].address);
 }
 
 const mach_header* DyldSharedCache::getIndexedImageEntry(uint32_t index) const
@@ -1135,7 +1138,8 @@
 #if BUILDING_SHARED_CACHE_UTIL
 void DyldSharedCache::forEachPatchableUseOfExport(uint32_t imageIndex, uint32_t dylibVMOffsetOfImpl,
                                                   void (^handler)(uint32_t userImageIndex, uint32_t userVMOffset,
-                                                                  MachOLoaded::PointerMetaData pmd, uint64_t addend)) const {
+                                                                  MachOLoaded::PointerMetaData pmd, uint64_t addend,
+                                                                  bool isWeakImport)) const {
     if ( header.patchInfoAddr == 0 )
         return;
 
@@ -1241,7 +1245,7 @@
                 pmd.key               = patchLocation.key;
                 pmd.usesAddrDiversity = patchLocation.usesAddressDiversity;
 
-                handler(userImageIndex, userVMOffset, pmd, patchLocation.getAddend());
+                handler(userImageIndex, userVMOffset, pmd, patchLocation.getAddend(), false);
             }
         }
         return;
@@ -1271,7 +1275,8 @@
 }
 
 void DyldSharedCache::forEachPatchableUseOfExportInImage(uint32_t imageIndex, uint32_t dylibVMOffsetOfImpl, uint32_t userImageIndex,
-                                                         void (^handler)(uint32_t userVMOffset, MachOLoaded::PointerMetaData pmd, uint64_t addend)) const {
+                                                         void (^handler)(uint32_t userVMOffset, MachOLoaded::PointerMetaData pmd, uint64_t addend,
+                                                                         bool isWeakImport)) const {
     if ( header.patchInfoAddr == 0 )
         return;
 
@@ -1379,7 +1384,7 @@
                     pmd.key               = patchLocation.key;
                     pmd.usesAddrDiversity = patchLocation.usesAddressDiversity;
 
-                    handler(userVMOffset, pmd, patchLocation.getAddend());
+                    handler(userVMOffset, pmd, patchLocation.getAddend(), false);
                 }
             }
         }
@@ -1394,7 +1399,8 @@
 
 void DyldSharedCache::forEachPatchableUseOfExport(uint32_t imageIndex, uint32_t dylibVMOffsetOfImpl,
                                                   void (^handler)(uint64_t cacheVMOffset,
-                                                                  MachOLoaded::PointerMetaData pmd, uint64_t addend)) const {
+                                                                  MachOLoaded::PointerMetaData pmd, uint64_t addend,
+                                                                  bool isWeakImport)) const {
     if ( header.patchInfoAddr == 0 )
         return;
 
@@ -1442,7 +1448,7 @@
                 pmd.key               = patchLocation.key;
                 pmd.usesAddrDiversity = patchLocation.usesAddressDiversity;
 
-                handler(patchLocation.cacheOffset, pmd, patchLocation.getAddend());
+                handler(patchLocation.cacheOffset, pmd, patchLocation.getAddend(), false);
             }
         }
         return;
@@ -1464,7 +1470,8 @@
 void DyldSharedCache::forEachPatchableGOTUseOfExport(uint32_t imageIndex, uint32_t dylibVMOffsetOfImpl,
                                                      void (^handler)(uint64_t cacheVMOffset,
                                                                      MachOFile::PointerMetaData pmd,
-                                                                     uint64_t addend)) const {
+                                                                     uint64_t addend,
+                                                                     bool isWeakImport)) const {
     if ( header.patchInfoAddr == 0 )
         return;
 
@@ -2200,3 +2207,5 @@
     });
 }
 #endif
+
+#endif // !TARGET_OS_EXCLAVEKIT