From 6c2a61de9bf56509cc827c6fcda911a792e0656c Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Mon, 6 Aug 2018 14:47:56 +0100 Subject: [PATCH] Improve protocol reference loading. Now all @protocol references will refer to precisely the same instance, even across shared libraries. --- loader.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/loader.c b/loader.c index cdb435b..fc0bf27 100644 --- a/loader.c +++ b/loader.c @@ -228,6 +228,17 @@ PUBLIC void __objc_load(struct objc_init *init) } registerProtocol((struct objc_protocol*)proto); } + for (struct objc_protocol **proto = init->proto_ref_begin ; proto < init->proto_ref_end ; + proto++) + { + if (*proto == NULL) + { + continue; + } + struct objc_protocol *p = objc_getProtocol((*proto)->name); + assert(p); + *proto = p; + } for (Class *cls = init->cls_begin ; cls < init->cls_end ; cls++) { if (*cls == NULL)