dyld 库加载
_objc_init 加断点 -> lldb bt
dyld 加载
在load 中加断点
+ (void)load{
NSLog(@"%s",__func__);
}
lldb bt
具体调用是从_dyld_start 开始的
_dyld_start -> dyldbootstrap::start -> dyld::_main
_mian 往下走
dyld加载 ->ImageLoader::recursiveInitialization -> this->doInitialization -> libobjc源码中 _objc_init -> _dyld_objc_notify_register (dyld 源码) -> registerObjCNotifiers -> 初始化 sNotifyObjCMapped ,sNotifyObjCInit,sNotifyObjCUnmapped
void registerObjCNotifiers(_dyld_objc_notify_mapped mapped, _dyld_objc_notify_init init, _dyld_objc_notify_unmapped unmapped)
{
// record functions to call
sNotifyObjCMapped = mapped;
sNotifyObjCInit = init;
sNotifyObjCUnmapped = unmapped;
}
dyld加载 ->ImageLoader::recursiveInitialization -> context.notifySingle(dyld_image_state_dependents_initialized, ...) -> 调用sNotifyObjCInit方法