Loading...
--- dyld/dyld-625.13/dyld3/shared-cache/make_ios_dyld_cache.cpp
+++ dyld/dyld-551.3/dyld3/shared-cache/make_ios_dyld_cache.cpp
@@ -55,7 +55,7 @@
#include <iostream>
#include <fstream>
-#include "MachOFile.h"
+#include "MachOParser.h"
#include "FileUtils.h"
#include "StringUtils.h"
#include "DyldSharedCache.h"
@@ -86,24 +86,21 @@
Diagnostics diag;
bool usedWholeFile = false;
for (MappedMachOsByCategory& file : files) {
- uint64_t sliceOffset = 0;
- uint64_t sliceLength = statBuf.st_size;
+ size_t sliceOffset;
+ size_t sliceLength;
bool fatButMissingSlice;
const void* slice = MAP_FAILED;
- const dyld3::FatFile* fh = (dyld3::FatFile*)wholeFile;
- const dyld3::MachOFile* mh = (dyld3::MachOFile*)wholeFile;
- if ( fh->isFatFileWithSlice(diag, statBuf.st_size, file.archName.c_str(), sliceOffset, sliceLength, fatButMissingSlice) ) {
+ if ( dyld3::FatUtil::isFatFileWithSlice(diag, wholeFile, statBuf.st_size, file.archName, sliceOffset, sliceLength, fatButMissingSlice) ) {
slice = ::mmap(NULL, sliceLength, PROT_READ, MAP_PRIVATE, fd, sliceOffset);
if ( slice != MAP_FAILED ) {
//fprintf(stderr, "mapped slice at %p size=0x%0lX, offset=0x%0lX for %s\n", p, len, offset, fullPath.c_str());
- mh = (dyld3::MachOFile*)slice;
- if ( !mh->isMachO(diag, sliceLength) ) {
+ if ( !dyld3::MachOParser::isValidMachO(diag, file.archName, platform, slice, sliceLength, fullPath.c_str(), false) ) {
::munmap((void*)slice, sliceLength);
slice = MAP_FAILED;
}
}
}
- else if ( !fatButMissingSlice && mh->isMachO(diag, sliceLength) ) {
+ else if ( !fatButMissingSlice && dyld3::MachOParser::isValidMachO(diag, file.archName, platform, wholeFile, statBuf.st_size, fullPath.c_str(), false) ) {
slice = wholeFile;
sliceLength = statBuf.st_size;
sliceOffset = 0;
@@ -111,20 +108,24 @@
//fprintf(stderr, "mapped whole file at %p size=0x%0lX for %s\n", p, len, inputPath.c_str());
}
if ( slice != MAP_FAILED ) {
- mh = (dyld3::MachOFile*)slice;
- if ( mh->platform() != platform ) {
+ const mach_header* mh = (mach_header*)slice;
+ dyld3::MachOParser parser(mh);
+ if ( parser.platform() != platform ) {
fprintf(stderr, "skipped wrong platform binary: %s\n", fullPath.c_str());
result = false;
}
else {
bool sip = true; // assume anything found in the simulator runtime is a platform binary
- if ( mh->isDynamicExecutable() ) {
+ if ( parser.isDynamicExecutable() ) {
bool issetuid = (statBuf.st_mode & (S_ISUID|S_ISGID));
file.mainExecutables.emplace_back(runtimePath, mh, sliceLength, issetuid, sip, sliceOffset, statBuf.st_mtime, statBuf.st_ino);
}
else {
if ( parser.canBePlacedInDyldCache(runtimePath) ) {
file.dylibsForCache.emplace_back(runtimePath, mh, sliceLength, false, sip, sliceOffset, statBuf.st_mtime, statBuf.st_ino);
+ }
+ else {
+ file.otherDylibsAndBundles.emplace_back(runtimePath, mh, sliceLength, false, sip, sliceOffset, statBuf.st_mtime, statBuf.st_ino);
}
}
result = true;
@@ -274,7 +275,6 @@
break;
case dyld3::Platform::watchOS:
archStrs.insert("armv7k");
- archStrs.insert("arm64_32");
break;
case dyld3::Platform::unknown:
case dyld3::Platform::macOS:
@@ -289,8 +289,6 @@
std::vector<MappedMachOsByCategory> allFileSets;
if ( archStrs.count("arm64") )
allFileSets.push_back({"arm64"});
- if ( archStrs.count("arm64_32") )
- allFileSets.push_back({"arm64_32"});
if ( archStrs.count("armv7k") )
allFileSets.push_back({"armv7k"});
std::vector<std::string> paths;
@@ -322,7 +320,6 @@
options.inodesAreSameAsRuntime = false;
options.cacheSupportsASLR = true;
options.forSimulator = false;
- options.isLocallyBuiltCache = true;
options.verbose = verbose;
options.evictLeafDylibsOnOverflow = false;
options.pathPrefixes = { rootPath };