Loading...
--- dyld/dyld-1284.13/cache-builder/update_dyld_sim_shared_cache.cpp
+++ dyld/dyld-1162/cache-builder/update_dyld_sim_shared_cache.cpp
@@ -409,31 +409,33 @@
return true;
}
-static mach_o::Platform getPlatform(Diagnostics& diags, std::string_view rootPath)
+static dyld3::Platform getPlatform(Diagnostics& diags, std::string_view rootPath)
{
// Infer the platform from dyld_sim
std::string dyldSimPath = std::string(rootPath) + "/usr/lib/dyld_sim";
std::optional<MappedFile> mappedFile = loadFile(diags, dyldSimPath.c_str());
if ( !mappedFile.has_value() )
- return mach_o::Platform();
-
- __block mach_o::Platform platform = mach_o::Platform();
+ return dyld3::Platform::unknown;
+
+ __block dyld3::Platform platform = dyld3::Platform::unknown;
if ( dyld3::FatFile::isFatFile(mappedFile->buffer) ) {
const dyld3::FatFile* ff = (dyld3::FatFile*)mappedFile->buffer;
ff->forEachSlice(diags, mappedFile->bufferSize,
^(uint32_t sliceCpuType, uint32_t sliceCpuSubType, const void* sliceStart, uint64_t sliceSize, bool& stop) {
- const mach_o::Header* mh = (mach_o::Header*)sliceStart;
- mach_o::PlatformAndVersions pvs = mh->platformAndVersions();
- if ( platform.empty() )
- platform = pvs.platform;
+ const dyld3::MachOFile* mf = (dyld3::MachOFile*)sliceStart;
+ mf->forEachSupportedPlatform(^(dyld3::Platform plat, uint32_t minOS, uint32_t sdk) {
+ if ( platform == dyld3::Platform::unknown)
+ platform = plat;
+ });
});
} else {
- const mach_o::Header* mh = (mach_o::Header*)mappedFile->buffer;
- if ( mh->valid(mappedFile->bufferSize) ) {
- mach_o::PlatformAndVersions pvs = mh->platformAndVersions();
- if ( platform.empty() )
- platform = pvs.platform;
+ const dyld3::MachOFile* mf = (dyld3::MachOFile*)mappedFile->buffer;
+ if ( mf->isMachO(diags, mappedFile->bufferSize) ) {
+ mf->forEachSupportedPlatform(^(dyld3::Platform plat, uint32_t minOS, uint32_t sdk) {
+ if ( platform == dyld3::Platform::unknown)
+ platform = plat;
+ });
}
}
@@ -568,7 +570,7 @@
// The platform comes from dyld_sim now
Diagnostics diags;
- mach_o::Platform platform = getPlatform(diags, rootPath);
+ dyld3::Platform platform = getPlatform(diags, rootPath);
if ( diags.hasError() ) {
fprintf(stderr, "update_dyld_sim_shared_cache: error: could not find sim platform because: %s\n",
diags.errorMessageCStr());
@@ -581,7 +583,7 @@
buildOptions.updateName = "sim";
buildOptions.deviceName = "sim";
buildOptions.disposition = InternalMinDevelopment;
- buildOptions.platform = (Platform)platform.value();
+ buildOptions.platform = (Platform)platform;
buildOptions.archs = buildArchs.data();
buildOptions.numArchs = buildArchs.size();
buildOptions.verboseDiagnostics = verbose;