Determining a descriptor's size requires reading its contents, but reading its contents from out of process requires knowing its size.
Build up the size incrementally by walking over the TrailingObjects. Take advantage of the fact that each trailing object's presence/count depends only on data that comes before it. This allows us to read prefixes that we gradually expand until we've covered the whole thing.
Add calls to TrailingObjects to allow iterating over the prefix sizes, and modify readContextDescriptor to use them. This replaces the old code which attempted to determine the descriptor size in an ad-hoc fashion that didn't always get it right.
rdar://146006006
Ensure that context descriptor pointers are signed in the runtime by putting the ptrauth_struct attribute on the types.
We use the new __builtin_ptrauth_struct_key/disc to conditionally apply ptrauth_struct to TrailingObjects based on the signing of the base type, so that pointers to TrailingObjects get signed when used with a context descriptor pointer.
We add new runtime entrypoints that take signed pointers where appropriate, and have the compiler emit calls to the new entrypoints when targeting a sufficiently new OS.
rdar://111480914
In our ABI, we’re using some C++ ABI tricks to simplify the
implementation of the runtime. One of them, in FullMetadata, requires
that we inherit from classes that we would also like to make use
TrailingObjects. Remove the “final” assertion from TrailingObjects
so we can do so.
We promise to be careful.
NFC intended. The layout of trailing matter here is getting fairly complex, so it's good to use LLVM's existing library code to keep track of it. We use a fork of llvm's TrailingObjects.h header so that future changes to LLVM don't disturb the ABI of Swift runtime objects that use the template.