voidinitializeMainExecutable() { // record that we've reached this step gLinkContext.startedInitializingMainExecutable = true;
// run initialzers for any inserted dylibs ImageLoader::InitializerTimingList initializerTimes[allImagesCount()]; initializerTimes[0].count = 0; constsize_t rootCount = sImageRoots.size(); if ( rootCount > 1 ) { for(size_t i=1; i < rootCount; ++i) { sImageRoots[i]->runInitializers(gLinkContext, initializerTimes[0]); } } // run initializers for main executable and everything it brings up sMainExecutable->runInitializers(gLinkContext, initializerTimes[0]); // register cxa_atexit() handler to run static terminators in all loaded images when this process exits if ( gLibSystemHelpers != NULL ) (*gLibSystemHelpers->cxa_atexit)(&runAllStaticTerminators, NULL, NULL);
// dump info if requested // ⬇️ 🔔🔔🔔 这里就是我们分析的重点❗️❗️❗️ if ( sEnv.DYLD_PRINT_STATISTICS ) ImageLoader::printStatistics((unsignedint)allImagesCount(), initializerTimes[0]); if ( sEnv.DYLD_PRINT_STATISTICS_DETAILS ) ImageLoaderMachO::printStatisticsDetails((unsignedint)allImagesCount(), initializerTimes[0]); }