@@ -372,7 +372,7 @@ MachOReader::EnumerateModules(mach_vm_address_t dyldInfoAddress)
372372 Trace (" MOD: infoArray %p infoArrayCount %d\n " , dyldInfo.infoArray , dyldInfo.infoArrayCount );
373373
374374 // Create the dyld module info
375- if (!CreateModule (dyldInfo.dyldImageLoadAddress , dyldInfo.dyldPath ))
375+ if (!TryRegisterModule (dyldInfo.dyldImageLoadAddress , dyldInfo.dyldPath , true ))
376376 {
377377 Trace (" ERROR: Failed to read dyld header at %p\n " , dyldInfo.dyldImageLoadAddress );
378378 return false ;
@@ -393,13 +393,13 @@ MachOReader::EnumerateModules(mach_vm_address_t dyldInfoAddress)
393393 for (int i = 0 ; i < dyldInfo.infoArrayCount ; i++)
394394 {
395395 // Ignore any errors and continue to next module
396- CreateModule (imageInfos[i].imageLoadAddress , imageInfos[i].imageFilePath );
396+ TryRegisterModule (imageInfos[i].imageLoadAddress , imageInfos[i].imageFilePath , false );
397397 }
398398 return true ;
399399}
400400
401401bool
402- MachOReader::CreateModule (const struct mach_header * imageAddress, const char * imageFilePathAddress)
402+ MachOReader::TryRegisterModule (const struct mach_header * imageAddress, const char * imageFilePathAddress, bool dylinker )
403403{
404404 std::string imagePath;
405405 if (!ReadString (imageFilePathAddress, imagePath))
@@ -413,6 +413,18 @@ MachOReader::CreateModule(const struct mach_header* imageAddress, const char* im
413413 }
414414 Trace (" MOD: %016llx %08x %s\n " , imageAddress, module .Header ().flags , imagePath.c_str ());
415415 VisitModule (module );
416+ if (dylinker)
417+ {
418+ // Make sure the memory for the symbol and string tables are in the core dump for our
419+ // dump readers which still use this symbol to enumerate modules.
420+ uint64_t dyldInfoAddress = 0 ;
421+ if (!module .TryLookupSymbol (" dyld_all_image_infos" , &dyldInfoAddress))
422+ {
423+ Trace (" ERROR: Can not find the _dyld_all_image_infos symbol\n " );
424+ return false ;
425+ }
426+ Trace (" MOD: dyldInfoAddress %016llx\n " , dyldInfoAddress);
427+ }
416428 return true ;
417429}
418430
0 commit comments