Loading...
cache_builder/CacheDylib.cpp dyld-1122.1 dyld-1125.5
--- dyld/dyld-1122.1/cache_builder/CacheDylib.cpp
+++ dyld/dyld-1125.5/cache_builder/CacheDylib.cpp
@@ -2164,9 +2164,18 @@
         if ( objcClass.getMethodCachePropertiesVMAddr(objcVisitor).has_value() )
             return;
 
+        MachOFile::PointerMetaData PMD;
+        if ( config.layout.hasAuthRegion && (objcIMPCachesOptimizer.libobjcImpCachesVersion >= 4) ) {
+            PMD.diversity         = 0x9cff; // hash of "originalPreoptCache"
+            PMD.high8             = 0;
+            PMD.authenticated     = 1;
+            PMD.key               = 2;     // DA
+            PMD.usesAddrDiversity = 1;
+        }
+
         // Set the "vtable" to point to the cache
         CacheVMAddress impCacheVMAddr = objcIMPCachesOptimizer.impCachesChunk->cacheVMAddress + impCacheOffset;
-        objcClass.setMethodCachePropertiesVMAddr(objcVisitor, VMAddress(impCacheVMAddr.rawValue()));
+        objcClass.setMethodCachePropertiesVMAddr(objcVisitor, VMAddress(impCacheVMAddr.rawValue()), PMD);
 
         // Tell the slide info emitter to slide this location
         metadata_visitor::ResolvedValue vtableField = objcClass.getMethodCachePropertiesField(objcVisitor);