Loading...
--- dyld/dyld-239.3/launch-cache/dsc_iterator.cpp
+++ dyld/dyld-655.1/launch-cache/dsc_iterator.cpp
@@ -33,8 +33,7 @@
#include "Architectures.hpp"
#include "MachOFileAbstraction.hpp"
#include "CacheFileAbstraction.hpp"
-
-
+#include "SupportedArchs.h"
namespace dyld {
@@ -47,7 +46,7 @@
const dyldCacheFileMapping<E>* mappings = (dyldCacheFileMapping<E>*)&cache[header->mappingOffset()];
for (uint32_t i=0; i < header->mappingCount(); ++i) {
if ( (mappings[i].address() <= addr) && (addr < (mappings[i].address() + mappings[i].size())) ) {
- uint32_t cacheOffset = mappings[i].file_offset() + addr - mappings[i].address();
+ uint64_t cacheOffset = mappings[i].file_offset() + addr - mappings[i].address();
const uint8_t* result = &cache[cacheOffset];
if ( result < cacheEnd )
return result;
@@ -60,17 +59,19 @@
// call the callback block on each segment in this image
template <typename A>
- int walkSegments(const uint8_t* cache, const uint8_t* cacheEnd, const uint8_t* firstSeg, const char* dylibPath, const uint8_t* machHeader,
+ int walkSegments(const uint8_t* cache, const uint8_t* cacheEnd, const uint8_t* firstSeg, const char* dylibPath, uint64_t inode,uint64_t modTime, const uint8_t* machHeader, uint64_t cache_unslid_base_address,
void (^callback)(const dyld_shared_cache_dylib_info* dylibInfo, const dyld_shared_cache_segment_info* segInfo))
{
typedef typename A::P P;
typedef typename A::P::E E;
dyld_shared_cache_dylib_info dylibInfo;
dyld_shared_cache_segment_info segInfo;
- dylibInfo.version = 1;
+ dylibInfo.version = 2;
dylibInfo.isAlias = (dylibPath < (char*)firstSeg); // paths for aliases are store between cache header and first segment
dylibInfo.machHeader = machHeader;
dylibInfo.path = dylibPath;
+ dylibInfo.inode = inode;
+ dylibInfo.modTime = modTime;
const macho_header<P>* mh = (const macho_header<P>*)machHeader;
const macho_load_command<P>* const cmds = (macho_load_command<P>*)(machHeader + sizeof(macho_header<P>));
if ( (machHeader+ mh->sizeofcmds()) > cacheEnd )
@@ -103,11 +104,14 @@
if ( (fileOffset+sizem) > (uint64_t)(cacheEnd-cache) )
sizem = (cacheEnd-cache)-fileOffset;
}
- segInfo.version = 1;
+ segInfo.version = 2;
segInfo.name = segCmd->segname();
segInfo.fileOffset = fileOffset;
segInfo.fileSize = sizem;
+ if ( segCmd->filesize() > segCmd->vmsize() )
+ return -1;
segInfo.address = segCmd->vmaddr();
+ segInfo.addressOffset = segInfo.address - cache_unslid_base_address;
callback(&dylibInfo, &segInfo);
}
cmd = (const macho_load_command<P>*)(((uint8_t*)cmd)+cmd->cmdsize());
@@ -128,6 +132,7 @@
const dyldCacheHeader<E>* header = (dyldCacheHeader<E>*)cache;
const dyldCacheImageInfo<E>* dylibs = (dyldCacheImageInfo<E>*)&cache[header->imagesOffset()];
const dyldCacheFileMapping<E>* mappings = (dyldCacheFileMapping<E>*)&cache[header->mappingOffset()];
+ uint64_t unslid_base_address = mappings[0].address();
uint64_t greatestMappingOffset = 0;
for (uint32_t i=0; i < header->mappingCount(); ++i) {
if ( (size != 0) && (mappings[i].file_offset() > size) )
@@ -154,6 +159,8 @@
const uint8_t* firstSeg = NULL;
for (uint32_t i=0; i < header->imagesCount(); ++i) {
const char* dylibPath = (char*)cache + dylibs[i].pathFileOffset();
+ uint64_t inode = dylibs[i].inode();
+ uint64_t modTime = dylibs[i].modTime();
if ( (const uint8_t*)dylibPath > cacheEnd )
return -1;
const uint8_t* machHeader = mappedAddress<E>(cache, cacheEnd, dylibs[i].address());
@@ -163,7 +170,7 @@
return -1;
if ( firstSeg == NULL )
firstSeg = machHeader;
- int result = walkSegments<A>(cache, cacheEnd, firstSeg, dylibPath, machHeader, callback);
+ int result = walkSegments<A>(cache, cacheEnd, firstSeg, dylibPath, inode, modTime, machHeader, unslid_base_address, callback);
if ( result != 0 )
return result;
}
@@ -184,6 +191,8 @@
return dyld::walkImages<x86>(cache, shared_cache_size, callback);
else if ( strcmp((char*)cache, "dyld_v1 x86_64") == 0 )
return dyld::walkImages<x86_64>(cache, shared_cache_size, callback);
+ else if ( strcmp((char*)cache, "dyld_v1 x86_64h") == 0 )
+ return dyld::walkImages<x86_64>(cache, shared_cache_size, callback);
else if ( strcmp((char*)cache, "dyld_v1 armv5") == 0 )
return dyld::walkImages<arm>(cache, shared_cache_size, callback);
else if ( strcmp((char*)cache, "dyld_v1 armv6") == 0 )
@@ -192,6 +201,16 @@
return dyld::walkImages<arm>(cache, shared_cache_size, callback);
else if ( strncmp((char*)cache, "dyld_v1 armv7", 14) == 0 )
return dyld::walkImages<arm>(cache, shared_cache_size, callback);
+ else if ( strcmp((char*)cache, "dyld_v1 arm64") == 0 )
+ return dyld::walkImages<arm64>(cache, shared_cache_size, callback);
+#if SUPPORT_ARCH_arm64_32
+ else if ( strcmp((char*)cache, "dyld_v1arm64_32") == 0 )
+ return dyld::walkImages<arm64_32>(cache, shared_cache_size, callback);
+#endif
+#if SUPPORT_ARCH_arm64e
+ else if ( strcmp((char*)cache, "dyld_v1 arm64e") == 0 )
+ return dyld::walkImages<arm64>(cache, shared_cache_size, callback);
+#endif
else
return -1;
}