We would like it if objc_copyClassList() would find non-generic
classes with generic ancestry, as long as they ultimately inherit
from an @objc class. Make this so by emitting class stubs in a
few more cases.
Fixes <rdar://problem/71194117>.
The Objective-C runtime expects a signed pointer here. The existing test
would have caught this, except it was always disabled because the
symbol name passed to the dlsym() check should not have had the leading
'_'.
Fixes <rdar://problem/57679510>.
Now that `swift-reflection-dump` correctly handles pointer values and unresolved
cross-image references (for Mach-O, at least), we can safely unconditionally use
symbolic references in runtime mangled names without regressing offline reflection
support.
If a class has resilient metadata from our point of view, it might
still not have a class stub, if its entire inheritance chain is
defined in a single module.
Note that inserting a superclass is still a resilient operation;
the only way to change a class from having static metadata to having
a class stub is to change it's root class, which is not something
we can do resiliently.
Non-generic classes with resilient ancestry do not have statically-emitted
metadata, so we can now emit an Objective-C resilient class stub instead.
Also, when emitting an Objective-C category, reference the class stub if
the class has resilient ancestry; previously this case would hit an assert.
Note that class stubs always start with a zero word, with the address point
pointing immediately after. This works around a linker issue, where the
linker tries to coalesce categories and gets confused upon encountering a
class stub.