[Runtime][IRGen] Sign type context descriptor pointers.

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
This commit is contained in:
Mike Ash
2023-06-30 11:58:17 -04:00
parent 6f8fd07bdf
commit fe7e13bba5
29 changed files with 519 additions and 75 deletions

View File

@@ -888,6 +888,24 @@ namespace RuntimeConstants {
return RuntimeAvailability::AlwaysAvailable;
}
RuntimeAvailability SignedConformsToProtocolAvailability(ASTContext &context) {
auto featureAvailability =
context.getSignedConformsToProtocolAvailability();
if (!isDeploymentAvailabilityContainedIn(context, featureAvailability)) {
return RuntimeAvailability::ConditionallyAvailable;
}
return RuntimeAvailability::AlwaysAvailable;
}
RuntimeAvailability SignedDescriptorAvailability(ASTContext &context) {
auto featureAvailability =
context.getSignedDescriptorAvailability();
if (!isDeploymentAvailabilityContainedIn(context, featureAvailability)) {
return RuntimeAvailability::ConditionallyAvailable;
}
return RuntimeAvailability::AlwaysAvailable;
}
RuntimeAvailability TaskRunInlineAvailability(ASTContext &context) {
if (context.LangOpts.isConcurrencyModelTaskToThread()) {
return RuntimeAvailability::AlwaysAvailable;