Loading...
--- dyld/dyld-1122.1.2/common/MachOAnalyzer.cpp
+++ dyld/dyld-1235.2/common/MachOAnalyzer.cpp
@@ -290,18 +290,8 @@
return false;
}
} else if ( reqPlatform == Platform::unknown ) {
- // Unfortunately the static kernel has a platform, but kext's don't, so we can't
- // verify the platform of the kernel.
- if ( !isStaticExecutable() ) {
- __block bool foundPlatform = false;
- forEachSupportedPlatform(^(Platform platform, uint32_t minOS, uint32_t sdk) {
- foundPlatform = true;
- });
- if (foundPlatform) {
- diag.error("could not use '%s' because we expected it to have no platform", path);
- return false;
- }
- }
+ // This is handled elsewhere in the kernel collection builder, where we have access
+ // to the kernel binary and can infer its platform
} else
#endif
if ( !this->loadableIntoProcess(reqPlatform, path, internalInstall) ) {
@@ -601,6 +591,16 @@
// except for dylibs in libSystem.dylib which are ok to link with nothing (they are on bottom)
bool isNotLibSystem = (installName == nullptr) || (strncmp(installName, libSystemDir, strlen(libSystemDir)) != 0);
+ if ( internalInstall && (this->builtForPlatform(Platform::macOSExclaveKit, true)
+ || this->builtForPlatform(Platform::iOSExclaveKit, true)
+ || this->builtForPlatform(Platform::tvOSExclaveKit, true)) ) {
+ // The path of ExclaveKit libSystem libraries starts with /System/ExclaveKit
+ const size_t prefixLength = 18;
+ isNotLibSystem = true;
+ if ( installName != nullptr && strlen(installName) > prefixLength )
+ if ( strncmp(installName + prefixLength, "/usr/lib/system/", 16) == 0 )
+ isNotLibSystem = false;
+ }
if ( this->isDyldManaged() && isNotLibSystem ) {
diag.error("in '%s' missing LC_LOAD_DYLIB (must link with at least libSystem.dylib)", path);
return false;
@@ -683,7 +683,6 @@
if ( mainCount+threadCount == 1 )
return true;
-
if ( mainCount + threadCount == 0 )
diag.error("missing LC_MAIN or LC_UNIXTHREAD");
else
@@ -1049,7 +1048,7 @@
for (const relocation_info* reloc=relocsStart; (reloc < relocsEnd) && !stop; ++reloc) {
if ( reloc->r_length != relocSize ) {
bool shouldEmitError = true;
-#if BUILDING_APP_CACHE_UTIL
+#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
if ( usesClassicRelocationsInKernelCollection() && (reloc->r_length == 2) && (relocSize == 3) )
shouldEmitError = false;
#endif
@@ -1071,7 +1070,7 @@
uint32_t segIndex = 0;
uint64_t segOffset = 0;
uint64_t addr = 0;
-#if BUILDING_APP_CACHE_UTIL
+#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
// xnu for x86_64 has __HIB mapped before __DATA, so offsets appear to be
// negative
if ( isStaticExecutable() || isFileSet() ) {
@@ -1131,7 +1130,7 @@
uint64_t MachOAnalyzer::localRelocBaseAddress(const SegmentInfo segmentsInfos[], uint32_t segCount) const
{
if ( isArch("x86_64") || isArch("x86_64h") ) {
-#if BUILDING_APP_CACHE_UTIL
+#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
if ( isKextBundle() ) {
// for kext bundles the reloc base address starts at __TEXT segment
return segmentsInfos[0].vmAddr;
@@ -1157,7 +1156,7 @@
return preferredLoadAddress();
}
-#if BUILDING_APP_CACHE_UTIL
+#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
if ( isKextBundle() ) {
// for kext bundles the reloc base address starts at __TEXT segment
return preferredLoadAddress();
@@ -1356,7 +1355,7 @@
case BIND_TYPE_TEXT_PCREL32: {
// Text relocations are permitted in x86_64 kexts
bool forceAllowTextRelocs = false;
-#if BUILDING_APP_CACHE_UTIL
+#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
if ( isKextBundle() && (isArch("x86_64") || isArch("x86_64h")) )
forceAllowTextRelocs = true;
#endif
@@ -1721,7 +1720,7 @@
uint32_t poolSize = leInfo.symTab->strsize;
for (const relocation_info* reloc=relocsStart; (reloc < relocsEnd) && !stop; ++reloc) {
bool isBranch = false;
-#if BUILDING_APP_CACHE_UTIL
+#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
if ( isKextBundle() ) {
// kext's may have other kinds of relocations, eg, branch relocs. Skip them
if ( isArch("x86_64") || isArch("x86_64h") ) {
@@ -1905,7 +1904,7 @@
diag.error("chained fixups, page_size not 4KB or 16KB in segment #%d", i);
return false;
}
- if ( segInfo->pointer_format > 12 ) {
+ if ( segInfo->pointer_format > 13 ) {
diag.error("chained fixups, unknown pointer_format in segment #%d", i);
return false;
}
@@ -2318,6 +2317,18 @@
}
break;
}
+ case VMAddrConverter::SharedCacheFormat::v5: {
+ // Just use the chained pointer format for arm64e
+ if ( value == 0 )
+ return 0;
+ auto* chainedValue = (MachOAnalyzer::ChainedFixupPointerOnDisk*)&value;
+ uint64_t targetRuntimeOffset;
+ if ( chainedValue->isRebase(DYLD_CHAINED_PTR_ARM64E_SHARED_CACHE, preferredLoadAddress,
+ targetRuntimeOffset) ) {
+ value = preferredLoadAddress + targetRuntimeOffset;
+ }
+ break;
+ }
}
return value;
}
@@ -4788,7 +4799,7 @@
bool stop = false;
for (const relocation_info* reloc=relocsStart; (reloc < relocsEnd) && !stop; ++reloc) {
bool isBranch = false;
-#if BUILDING_APP_CACHE_UTIL
+#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
if ( isKextBundle() ) {
// kext's may have other kinds of relocations, eg, branch relocs. Skip them
if ( isArch("x86_64") || isArch("x86_64h") ) {
@@ -5321,8 +5332,8 @@
void MachOAnalyzer::sortRelocations(Array<relocation_info>& relocs) const
{
// The kernel linker has malloc, and old-style relocations are extremely common. So use qsort
-#if BUILDING_APP_CACHE_UTIL
- ::qsort(&relocs[0], relocs.count(), sizeof(relocation_info),
+#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
+ ::qsort(&relocs[0], (size_t)relocs.count(), sizeof(relocation_info),
[](const void* l, const void* r) -> int {
if ( ((relocation_info*)l)->r_address < ((relocation_info*)r)->r_address )
return -1;
@@ -5330,10 +5341,10 @@
return 1;
});
#else
- uintptr_t count = relocs.count();
- for (uintptr_t i=0; i < count-1; ++i) {
+ uint64_t count = relocs.count();
+ for (uint64_t i=0; i < count-1; ++i) {
bool done = true;
- for (uintptr_t j=0; j < count-i-1; ++j) {
+ for (uint64_t j=0; j < count-i-1; ++j) {
if ( relocs[j].r_address > relocs[j+1].r_address ) {
relocation_info temp = relocs[j];
relocs[j] = relocs[j+1];
@@ -5361,7 +5372,7 @@
for (const relocation_info* reloc=relocsStart; (reloc < relocsEnd) && !stop; ++reloc) {
if ( reloc->r_length != relocSize ) {
bool shouldEmitError = true;
-#if BUILDING_APP_CACHE_UTIL
+#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
if ( usesClassicRelocationsInKernelCollection() && (reloc->r_length == 2) && (relocSize == 3) )
shouldEmitError = false;
#endif
@@ -5383,7 +5394,7 @@
uint32_t segIndex = 0;
uint64_t segOffset = 0;
uint64_t addr = 0;
-#if BUILDING_APP_CACHE_UTIL
+#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
// xnu for x86_64 has __HIB mapped before __DATA, so offsets appear to be
// negative
if ( isStaticExecutable() || isFileSet() ) {