Force linking the protocol classes.

We use the existence of the `Protocol` class in a set of loaded objects
to determine whether we are mixing ABIs in a safe way (i.e. only mixing
a new ABI runtime with old ABI everything else).  Unfortunately, in
static linking, the Protocol class was not being linked because it is
never directly referenced, which made this check fail.

Fixes #85
main
David Chisnall 7 years ago
parent afee197c67
commit 49bf9378fb

@ -36,3 +36,10 @@
@implementation ProtocolGCC @end @implementation ProtocolGCC @end
@implementation ProtocolGSv1 @end @implementation ProtocolGSv1 @end
PRIVATE void link_protocol_classes(void)
{
[Protocol class];
[ProtocolGCC class];
[ProtocolGSv1 class];
}

@ -45,6 +45,12 @@ __attribute__((weak)) void (*dispatch_end_thread_4GC)(void);
__attribute__((weak)) void *(*_dispatch_begin_NSAutoReleasePool)(void); __attribute__((weak)) void *(*_dispatch_begin_NSAutoReleasePool)(void);
__attribute__((weak)) void (*_dispatch_end_NSAutoReleasePool)(void *); __attribute__((weak)) void (*_dispatch_end_NSAutoReleasePool)(void *);
__attribute__((used))
static void link_protos(void)
{
link_protocol_classes();
}
static void init_runtime(void) static void init_runtime(void)
{ {
static BOOL first_run = YES; static BOOL first_run = YES;

@ -232,4 +232,12 @@ struct objc_protocol_list
}; };
// end: objc_protocol_list // end: objc_protocol_list
/**
* Function that ensures that protocol classes are linked. Calling this
* guarantees that the Protocol classes are linked into a statically linked
* runtime.
*/
void link_protocol_classes(void);
#endif // PROTOCOL_H_INCLUDED #endif // PROTOCOL_H_INCLUDED

Loading…
Cancel
Save