Loading...
--- dyld/dyld-733.6/dyld3/libdyldEntryVector.cpp
+++ dyld/dyld-519.2.2/dyld3/libdyldEntryVector.cpp
@@ -22,19 +22,16 @@
*/
#include <stdarg.h>
-#include <mach-o/dyld_priv.h>
-#include <mach-o/dyld_images.h>
+#include "dyld_priv.h"
#include "libdyldEntryVector.h"
#include "AllImages.h"
-#include "Array.h"
-#include "Loading.h"
#include "Logging.h"
#include "PathOverrides.h"
-#include "StartGlue.h"
-#include "dyld_process_info_internal.h"
+#include "LaunchCacheFormat.h"
-extern "C" char start;
+extern "C" void start();
+
VIS_HIDDEN const char** appleParams;
@@ -92,41 +89,33 @@
gAllImages.setOldAllImageInfo(old);
}
-static void entry_setNotifyMonitoringDyldMain(void (*notifyMonitoringDyldMain)()) {
-#if !TARGET_OS_DRIVERKIT
- setNotifyMonitoringDyldMain(notifyMonitoringDyldMain);
-#endif
-}
-
-static void entry_setNotifyMonitoringDyld(void (*notifyMonitoringDyld)(bool unloading,unsigned imageCount,
- const struct mach_header* loadAddresses[],
- const char* imagePaths[])) {
-#if !TARGET_OS_DRIVERKIT
- setNotifyMonitoringDyld(notifyMonitoringDyld);
-#endif
-}
-
-static void entry_setInitialImageList(const closure::LaunchClosure* closure,
- const DyldSharedCache* dyldCacheLoadAddress, const char* dyldCachePath,
- const Array<LoadedImage>& initialImages, LoadedImage& libSystem)
+static void entry_setInitialImageList(const launch_cache::binary_format::Closure* closure,
+ const void* dyldCacheLoadAddress, const char* dyldCachePath,
+ const dyld3::launch_cache::DynArray<loader::ImageInfo>& initialImages,
+ const mach_header* libSystemMH, const launch_cache::binary_format::Image* libSystemImage)
{
gAllImages.init(closure, dyldCacheLoadAddress, dyldCachePath, initialImages);
- gAllImages.applyInterposingToDyldCache(closure);
+ gAllImages.applyInterposingToDyldCache(closure, initialImages);
+
+ const char* mainPath = _simple_getenv(appleParams, "executable_path");
+ if ( (mainPath != nullptr) && (mainPath[0] == '/') )
+ gAllImages.setMainPath(mainPath);
+
+ // ok to call before malloc is ready because 4 slots are reserved.
+ gAllImages.setInitialGroups();
// run initializer for libSytem.B.dylib
// this calls back into _dyld_initializer which calls gAllIimages.addImages()
- gAllImages.runLibSystemInitializer(libSystem);
+ gAllImages.runLibSystemInitializer(libSystemMH, libSystemImage);
// now that malloc is available, parse DYLD_ env vars
- closure::gPathOverrides.setEnvVars((const char**)environ, gAllImages.mainExecutable(), gAllImages.mainExecutableImage()->path());
+ gPathOverrides.setEnvVars((const char**)environ);
}
static void entry_runInitialzersBottomUp(const mach_header* mainExecutableImageLoadAddress)
{
- gAllImages.runStartupInitialzers();
-#if !TARGET_OS_DRIVERKIT
+ gAllImages.runInitialzersBottomUp(mainExecutableImageLoadAddress);
gAllImages.notifyMonitorMain();
-#endif
}
static void entry_setChildForkFunction(void (*func)() )
@@ -134,55 +123,22 @@
sChildForkFunction = func;
}
-static void entry_setRestrictions(bool allowAtPaths, bool allowEnvPaths, bool allowFallbackPaths)
-{
- gAllImages.setRestrictions(allowAtPaths, allowEnvPaths);
- closure::gPathOverrides.setFallbackPathHandling(allowFallbackPaths ?
- dyld3::closure::PathOverrides::FallbackPathMode::classic :
- dyld3::closure::PathOverrides::FallbackPathMode::restricted);
-}
-
-static void entry_setHasCacheOverrides(bool someCacheImageOverriden)
-{
- gAllImages.setHasCacheOverrides(someCacheImageOverriden);
-}
-
-static_assert((closure::kFormatVersion & LibDyldEntryVector::kBinaryFormatVersionMask) == closure::kFormatVersion, "binary format version overflow");
-
const LibDyldEntryVector entryVectorForDyld = {
LibDyldEntryVector::kCurrentVectorVersion,
- closure::kFormatVersion,
+ launch_cache::binary_format::kFormatVersion,
&entry_setVars,
&entry_setHaltFunction,
&entry_setOldAllImageInfo,
&entry_setInitialImageList,
&entry_runInitialzersBottomUp,
- (__typeof(LibDyldEntryVector::startFunc))address_of_start,
+ &start,
&entry_setChildForkFunction,
&entry_setLogFunction,
- &entry_setRestrictions,
- &entry_setNotifyMonitoringDyldMain,
- &entry_setNotifyMonitoringDyld,
- &entry_setHasCacheOverrides
};
-
-VIS_HIDDEN void _dyld_atfork_prepare()
-{
- gAllImages.takeLockBeforeFork();
-}
-
-VIS_HIDDEN void _dyld_atfork_parent()
-{
- gAllImages.releaseLockInForkParent();
-}
VIS_HIDDEN void _dyld_fork_child()
{
- // Note the child fork function updates the data structures inside dyld
(*sChildForkFunction)();
-
- // And we then need to update the structures for dyld3 in libdyld
- gAllImages.resetLockInForkChild();
}