Loading...
--- dyld/dyld-1231.3/common/MachOAnalyzer.cpp
+++ dyld/dyld-1122.1/common/MachOAnalyzer.cpp
@@ -290,8 +290,18 @@
return false;
}
} else if ( reqPlatform == Platform::unknown ) {
- // This is handled elsewhere in the kernel collection builder, where we have access
- // to the kernel binary and can infer its platform
+ // 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;
+ }
+ }
} else
#endif
if ( !this->loadableIntoProcess(reqPlatform, path, internalInstall) ) {
@@ -591,16 +601,6 @@
// 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,6 +683,7 @@
if ( mainCount+threadCount == 1 )
return true;
+
if ( mainCount + threadCount == 0 )
diag.error("missing LC_MAIN or LC_UNIXTHREAD");
else
@@ -1048,7 +1049,7 @@
for (const relocation_info* reloc=relocsStart; (reloc < relocsEnd) && !stop; ++reloc) {
if ( reloc->r_length != relocSize ) {
bool shouldEmitError = true;
-#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
+#if BUILDING_APP_CACHE_UTIL
if ( usesClassicRelocationsInKernelCollection() && (reloc->r_length == 2) && (relocSize == 3) )
shouldEmitError = false;
#endif
@@ -1070,7 +1071,7 @@
uint32_t segIndex = 0;
uint64_t segOffset = 0;
uint64_t addr = 0;
-#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
+#if BUILDING_APP_CACHE_UTIL
// xnu for x86_64 has __HIB mapped before __DATA, so offsets appear to be
// negative
if ( isStaticExecutable() || isFileSet() ) {
@@ -1130,7 +1131,7 @@
uint64_t MachOAnalyzer::localRelocBaseAddress(const SegmentInfo segmentsInfos[], uint32_t segCount) const
{
if ( isArch("x86_64") || isArch("x86_64h") ) {
-#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
+#if BUILDING_APP_CACHE_UTIL
if ( isKextBundle() ) {
// for kext bundles the reloc base address starts at __TEXT segment
return segmentsInfos[0].vmAddr;
@@ -1156,7 +1157,7 @@
return preferredLoadAddress();
}
-#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
+#if BUILDING_APP_CACHE_UTIL
if ( isKextBundle() ) {
// for kext bundles the reloc base address starts at __TEXT segment
return preferredLoadAddress();
@@ -1355,7 +1356,7 @@
case BIND_TYPE_TEXT_PCREL32: {
// Text relocations are permitted in x86_64 kexts
bool forceAllowTextRelocs = false;
-#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
+#if BUILDING_APP_CACHE_UTIL
if ( isKextBundle() && (isArch("x86_64") || isArch("x86_64h")) )
forceAllowTextRelocs = true;
#endif
@@ -1720,7 +1721,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 || BUILDING_DYLDINFO
+#if BUILDING_APP_CACHE_UTIL
if ( isKextBundle() ) {
// kext's may have other kinds of relocations, eg, branch relocs. Skip them
if ( isArch("x86_64") || isArch("x86_64h") ) {
@@ -1904,7 +1905,7 @@
diag.error("chained fixups, page_size not 4KB or 16KB in segment #%d", i);
return false;
}
- if ( segInfo->pointer_format > 13 ) {
+ if ( segInfo->pointer_format > 12 ) {
diag.error("chained fixups, unknown pointer_format in segment #%d", i);
return false;
}
@@ -2317,18 +2318,6 @@
}
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;
}
@@ -4799,7 +4788,7 @@
bool stop = false;
for (const relocation_info* reloc=relocsStart; (reloc < relocsEnd) && !stop; ++reloc) {
bool isBranch = false;
-#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
+#if BUILDING_APP_CACHE_UTIL
if ( isKextBundle() ) {
// kext's may have other kinds of relocations, eg, branch relocs. Skip them
if ( isArch("x86_64") || isArch("x86_64h") ) {
@@ -5332,8 +5321,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 || BUILDING_DYLDINFO
- ::qsort(&relocs[0], (size_t)relocs.count(), sizeof(relocation_info),
+#if BUILDING_APP_CACHE_UTIL
+ ::qsort(&relocs[0], 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;
@@ -5341,10 +5330,10 @@
return 1;
});
#else
- uint64_t count = relocs.count();
- for (uint64_t i=0; i < count-1; ++i) {
+ uintptr_t count = relocs.count();
+ for (uintptr_t i=0; i < count-1; ++i) {
bool done = true;
- for (uint64_t j=0; j < count-i-1; ++j) {
+ for (uintptr_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];
@@ -5372,7 +5361,7 @@
for (const relocation_info* reloc=relocsStart; (reloc < relocsEnd) && !stop; ++reloc) {
if ( reloc->r_length != relocSize ) {
bool shouldEmitError = true;
-#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
+#if BUILDING_APP_CACHE_UTIL
if ( usesClassicRelocationsInKernelCollection() && (reloc->r_length == 2) && (relocSize == 3) )
shouldEmitError = false;
#endif
@@ -5394,7 +5383,7 @@
uint32_t segIndex = 0;
uint64_t segOffset = 0;
uint64_t addr = 0;
-#if BUILDING_APP_CACHE_UTIL || BUILDING_DYLDINFO
+#if BUILDING_APP_CACHE_UTIL
// xnu for x86_64 has __HIB mapped before __DATA, so offsets appear to be
// negative
if ( isStaticExecutable() || isFileSet() ) {