Loading...
common/ProcessAtlas.cpp dyld-1162 dyld-1066.8
--- dyld/dyld-1162/common/ProcessAtlas.cpp
+++ dyld/dyld-1066.8/common/ProcessAtlas.cpp
@@ -24,8 +24,6 @@
 
 #include <TargetConditionals.h>
 
-#if !TARGET_OS_EXCLAVEKIT
-
 #include <atomic>
 #include <cstring>
 #include <Block.h>
@@ -41,8 +39,8 @@
 #include <sys/stat.h>
 #include <sys/fsgetpath.h>
 
+#include <mach/mach_vm.h>
 #include <mach/mach_time.h> // mach_absolute_time()
-#include <mach/mach_vm.h>
 #include <mach-o/dyld_priv.h> // FIXME: We can remove this once we fully integrate into dyld4
 #include "dyld_cache_format.h"
 //FIXME: We should remove this header
@@ -590,9 +588,9 @@
 #if BUILDING_DYLD
 Image::Image(RuntimeState* state, Allocator& ephemeralAllocator, SharedPtr<Mapper>& mapper, const Loader* ldr)
     :   _ephemeralAllocator(ephemeralAllocator), _mapper(mapper), _rebasedAddress((void*)ldr->loadAddress(*state)) {
-        auto fileID = ldr->fileID(*state);
+        auto fileID = ldr->fileID(state->fileManager);
         if (fileID.inode() &&  fileID.device()) {
-            _file = state->fileManager.fileRecordForFileID(ldr->fileID(*state));
+            _file = state->fileManager.fileRecordForFileID(ldr->fileID(state->fileManager));
             if ( _file.volume().empty() ) {
                 _file = state->fileManager.fileRecordForPath(ephemeralAllocator, ldr->path());
             }
@@ -1888,7 +1886,7 @@
     }
 }
 
-bool ProcessSnapshot::Serializer::readMappedFileInfo(std::span<std::byte>& data, uint64_t& rebasedAddress, UUID& uuid, FileRecord& file) {
+void ProcessSnapshot::Serializer::readMappedFileInfo(std::span<std::byte>& data, uint64_t& rebasedAddress, UUID& uuid, FileRecord& file) {
     uint64_t flags = readPVLEUInt64(data);
     rebasedAddress = readPVLEUInt64(data);
     if (flags & kMappedFileFlagsHasUUID) {
@@ -1898,17 +1896,12 @@
     if (flags & kMappedFileFlagsHasFileID) {
         uint64_t volumeIndex = readPVLEUInt64(data);
         uint64_t objectID = readPVLEUInt64(data);
-        if (volumeIndex >= _volumeUUIDs.size() )
-            return false;
         file = _fileManager.fileRecordForVolumeUUIDAndObjID(_volumeUUIDs[(size_t)volumeIndex], objectID);
     }
     if (flags & kMappedFileFlagsHasFilePath) {
         uint64_t pathOffset = readPVLEUInt64(data);
-        if ( pathOffset >= _stringTableBuffer.size() )
-            return false;
         file = _fileManager.fileRecordForPath(_ephemeralAllocator, &_stringTableBuffer[(size_t)pathOffset]);
     }
-    return true;
 }
 
 Vector<std::byte> ProcessSnapshot::Serializer::serialize() {
@@ -2012,17 +2005,17 @@
     _timestamp          = read<uint64_t>(i);
     _crc32c             = read<uint32_t>(i);
     if (_magic != kMagic) {
-        return false;
+        assert(0);
     }
     if (_version != 0) {
-        return false;
+        assert(0);
     }
     CRC32c checksumer;
     checksumer(std::span(&data[0], 32));
     checksumer((uint32_t)0); // Zero out the actual checksum
     checksumer(std::span(&data[36], data.size() - 36));
     if (_crc32c != checksumer) {
-        return false;
+        assert(0);
     }
     _processFlags           = readPVLEUInt64(i);
     _platform               = readPVLEUInt64(i);
@@ -2043,8 +2036,7 @@
         uint64_t rebasedAddress;
         UUID uuid;
         FileRecord file;
-        if ( !readMappedFileInfo(i, rebasedAddress, uuid, file) )
-            return false;
+        readMappedFileInfo(i, rebasedAddress, uuid, file);
         rebasedAddress = rebasedAddress * ((_processFlags & kProcessFlagsHas16kPages) ? 16384 : 4096);
         SharedPtr<Mapper> mapper = nullptr;
         if (_processSnapshot._useIdentityMapper) {
@@ -2070,8 +2062,7 @@
         uint64_t rebasedAddress;
         UUID uuid;
         FileRecord file;
-        if ( !readMappedFileInfo(i, rebasedAddress, uuid, file) )
-            return false;
+        readMappedFileInfo(i, rebasedAddress, uuid, file);
         rebasedAddress = (rebasedAddress * ((_processFlags & kProcessFlagsHas16kPages) ? 16384 : 4096)) + lastAddress;
         lastAddress = rebasedAddress;
         SharedPtr<Mapper> mapper = nullptr;
@@ -2091,4 +2082,3 @@
 
 };
 };
-#endif // !TARGET_OS_EXCLAVEKIT