From 90e839df9c48ce19dbd089a88dc944b0b026445a Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 28 Jan 2021 00:41:03 +0000 Subject: [PATCH] dyld-832.7.3.tar.gz --- dyld3/shared-cache/mrm_shared_cache_builder.cpp | 98 ------------------------- src/dyld2.cpp | 12 +-- 2 files changed, 7 insertions(+), 103 deletions(-) diff --git a/dyld3/shared-cache/mrm_shared_cache_builder.cpp b/dyld3/shared-cache/mrm_shared_cache_builder.cpp index 5e58cbf..e6e90be 100644 --- a/dyld3/shared-cache/mrm_shared_cache_builder.cpp +++ b/dyld3/shared-cache/mrm_shared_cache_builder.cpp @@ -33,12 +33,6 @@ #include #include -#if __has_include() -#include -asm(".linker_option \"-lcambria_sharedcache\""); -asm(".linker_option \"-lcodedirectory_static\""); -#endif - static const uint64_t kMinBuildVersion = 1; //The minimum version BuildOptions struct we can support static const uint64_t kMaxBuildVersion = 2; //The maximum version BuildOptions struct we can support @@ -259,11 +253,6 @@ struct MRMSharedCacheBuilder { std::vector cacheResults; std::vector cacheResultStorage; -#if __has_include() - // Storage for translated shared caches - std::vector translationResults; -#endif - // The files to remove. These are in every copy of the caches we built std::vector filesToRemove; @@ -709,93 +698,6 @@ bool runSharedCacheBuilder(struct MRMSharedCacheBuilder* builder) { buildInstance.builder.reset(); } -#if __has_include() - // Only build the cambria caches if we have x86_64(h) and at least one other arch - bool gotX86Cache = false; - bool gotOtherCache = false; - for (uint64_t i = 0; i != builder->options->numArchs; ++i) { - const char* arch = builder->options->archs[i]; - if ( !strcmp(arch, "x86_64") || !strcmp(arch, "x86_64h") ) { - gotX86Cache = true; - continue; - } - gotOtherCache = true; - } - - if ( (builder->options->platform == Platform::macOS) && gotX86Cache && gotOtherCache ) { - // Now create an Aot shared cache for any applicable caches - for (const auto& buildInstance : builder->builders) { - // Only convert the x86_64 cache - if ( buildInstance.options->archs != &dyld3::GradedArchs::x86_64) - continue; - - // Skip failed caches - if (!buildInstance.errors.empty()) - continue; - - const uint8_t* aotCacheData; - size_t aotCacheSize; - std::string cdHashStr; - - // Translate this shared cache file. - cambria::TranslationOptions options; - -#if !defined(RC_HIDE_J274) || !RC_HIDE_J274 - // Don't generate a Tonga shared cache translation in the seed trains - cambria::translate_shared_cache(options, buildInstance.cacheData, buildInstance.cacheSize, - &aotCacheData, &aotCacheSize, &cdHashStr); - - builder->translationResults.push_back({ - .data = aotCacheData, - .size = aotCacheSize, - .cdHash = cdHashStr, - .path = std::string(cambria::kAotSharedCachePath), - .bufferWasMalloced = false - }); -#endif - - // Now translate again for aruba based systems - options.is_aruba_shared_cache = true; - cambria::translate_shared_cache(options, buildInstance.cacheData, buildInstance.cacheSize, - &aotCacheData, &aotCacheSize, &cdHashStr); - - bool bufferWasMalloced = false; -#if !defined(RC_HIDE_J274) || !RC_HIDE_J274 - // For GM we don't need to ship the Aruba AOT any more. It will be converted on the fly - // for the DTK. We'll just put a 0-byte placeholder instead and record the cdHash - vm_deallocate(mach_task_self(), (vm_address_t)aotCacheData, aotCacheSize); - aotCacheData = (uint8_t*)calloc(1, 1); - aotCacheSize = 0; - bufferWasMalloced = true; -#endif - - builder->translationResults.push_back({ - .data = aotCacheData, - .size = aotCacheSize, - .cdHash = cdHashStr, - .path = std::string(cambria::kAotSharedCachePathAruba), - .bufferWasMalloced = bufferWasMalloced - }); - } - - // Convert translation results into File results - for (auto& translationResult : builder->translationResults) { - FileResult cacheFileResult; - cacheFileResult.version = 1; - cacheFileResult.behavior = AddFile; - cacheFileResult.path = translationResult.path.c_str(); - cacheFileResult.data = translationResult.data; - cacheFileResult.size = translationResult.size; - cacheFileResult.hashArch = "x86_64"; - cacheFileResult.hashType = "sha256"; - cacheFileResult.hash = translationResult.cdHash.c_str(); - - builder->fileResultBuffers.push_back({ builder->fileResultStorage.size(), translationResult.bufferWasMalloced }); - builder->fileResultStorage.emplace_back(cacheFileResult); - } - } -#endif - // Now that we have run all of the builds, collect the results // First push file results for each of the shared caches we built for (auto& buildInstance : builder->builders) { diff --git a/src/dyld2.cpp b/src/dyld2.cpp index 65caa13..ec0af73 100644 --- a/src/dyld2.cpp +++ b/src/dyld2.cpp @@ -4897,7 +4897,9 @@ static bool isFairPlayEncrypted(const macho_header* mh) #if SUPPORT_VERSIONED_PATHS -static bool readFirstPage(const char* dylibPath, uint8_t firstPage[4096]) +#define FIRST_PAGE_BUFFER_SIZE 16384 + +static bool readFirstPage(const char* dylibPath, uint8_t firstPage[FIRST_PAGE_BUFFER_SIZE]) { firstPage[0] = 0; // open file (automagically closed when this function exits) @@ -4906,7 +4908,7 @@ static bool readFirstPage(const char* dylibPath, uint8_t firstPage[4096]) if ( file.getFileDescriptor() == -1 ) return false; - if ( pread(file.getFileDescriptor(), firstPage, 4096, 0) != 4096 ) + if ( pread(file.getFileDescriptor(), firstPage, FIRST_PAGE_BUFFER_SIZE, 0) != FIRST_PAGE_BUFFER_SIZE ) return false; // if fat wrapper, find usable sub-file @@ -4915,7 +4917,7 @@ static bool readFirstPage(const char* dylibPath, uint8_t firstPage[4096]) uint64_t fileOffset; uint64_t fileLength; if ( fatFindBest(fileStartAsFat, &fileOffset, &fileLength) ) { - if ( pread(file.getFileDescriptor(), firstPage, 4096, fileOffset) != 4096 ) + if ( pread(file.getFileDescriptor(), firstPage, FIRST_PAGE_BUFFER_SIZE, fileOffset) != FIRST_PAGE_BUFFER_SIZE ) return false; } else { @@ -4932,7 +4934,7 @@ static bool readFirstPage(const char* dylibPath, uint8_t firstPage[4096]) // static bool getDylibVersionAndInstallname(const char* dylibPath, uint32_t* version, char* installName) { - uint8_t firstPage[4096]; + uint8_t firstPage[FIRST_PAGE_BUFFER_SIZE]; const macho_header* mh = (macho_header*)firstPage; if ( !readFirstPage(dylibPath, firstPage) ) { // If file cannot be read, check to see if path is in shared cache @@ -4953,7 +4955,7 @@ static bool getDylibVersionAndInstallname(const char* dylibPath, uint32_t* versi // scan load commands for LC_ID_DYLIB const uint32_t cmd_count = mh->ncmds; const struct load_command* const cmds = (struct load_command*)(((char*)mh)+sizeof(macho_header)); - const struct load_command* const cmdsReadEnd = (struct load_command*)(((char*)mh)+4096); + const struct load_command* const cmdsReadEnd = (struct load_command*)(((char*)mh)+FIRST_PAGE_BUFFER_SIZE); const struct load_command* cmd = cmds; for (uint32_t i = 0; i < cmd_count; ++i) { switch (cmd->cmd) { -- 2.7.4