Allow attempting to load a module twice.

This is necessary because FreeBSD/ARM and possibly other platforms use
.init_array and not .ctors, so never call the init functions.  As a
result, we will need the compiler to move to putting the load function
in .init_array and may end up with it being called by both variants.
main
David Chisnall 7 years ago
parent 6eb1e51a49
commit 318ae27d8b

@ -212,6 +212,13 @@ OBJC_PUBLIC void __objc_load(struct objc_init *init)
case NewABI:
break;
}
// If we've already loaded this module, don't load it again.
if (init->version == ULONG_MAX)
{
return;
}
assert(init->version == 0);
assert((((uintptr_t)init->sel_end-(uintptr_t)init->sel_begin) % sizeof(*init->sel_begin)) == 0);
assert((((uintptr_t)init->cls_end-(uintptr_t)init->cls_begin) % sizeof(*init->cls_begin)) == 0);
@ -315,7 +322,7 @@ OBJC_PUBLIC void __objc_load(struct objc_init *init)
}
}
#endif
init->version = 0xffffffffffffffffULL;
init->version = ULONG_MAX;
}
#ifdef OLDABI_COMPAT

Loading…
Cancel
Save