Skip to content

Understanding the load order of binaries with DYLD_INSERT_LIBRARIES

License

Notifications You must be signed in to change notification settings

leptos-null/LoadOrder

Repository files navigation

LoadOrder

When writing tweaks, it's important to understand "the order of initialization." Apple describes the order in the +[NSObject load] documentation.

This project includes an app, a framework linked against by the app, and a library loaded by Substrate. Each function and method is logged to stdout. The output is below:

+[LSTweakClass load]
void tweakConstructor()
+[LSFrameworkClass load]
void frameworkConstructor()
+[LSAppDelegate load]
void appConstructor()
int main(int, char **)
+[LSFrameworkClass initialize]
+[LSFrameworkClass exampleCallMeFromMain]
+[LSAppDelegate initialize]

MobileSubstrate uses the DYLD_INSERT_LIBRARIES enviornment variable (more information availible in dyld(1)) to load itself into processes (which subsequently dlopen(lib, RTLD_NOW)s other libraries). The above output shows that libraries listed in DYLD_INSERT_LIBRARIES are initialized before the process that it's set for.

Interesting Reading

Blocking Code Injection on iOS and OS X (mirror)

About

Understanding the load order of binaries with DYLD_INSERT_LIBRARIES

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published