Files
swift-mirror/stdlib/public/CompatibilityOverride/CompatibilityOverrideRuntime.def
Mike Ash fe7e13bba5 [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
2023-07-07 18:10:35 -04:00

268 lines
12 KiB
C++

//===--- CompatibilityOverridesRuntime.def - Overrides Database -*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines x-macros used for metaprogramming with the set of
// compatibility override functions. See CompatibilityOverride.h for
// a detailed explanation of how this system works.
//
//===----------------------------------------------------------------------===//
/// #define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs)
/// Provides information about an overridable function.
/// - name is the name of the function, without any leading swift_ or
/// namespace.
/// - ret is the return type of the function.
/// - attrs is the attributes, if any, applied to the function definition.
/// - ccAttrs is the calling convention attributes, if any, applied to the
/// function definition and corresponding typedefs
/// - namespace is the namespace, if any, the function is in, including a
/// trailing ::
/// - typedArgs is the argument list, including types, surrounded by
/// parentheses
/// - namedArgs is the list of argument names, with no types, surrounded by
/// parentheses
///
/// The entries are organized by group. A user may define OVERRIDE to get all
/// entries, or define one or more of the more specific OVERRIDE_* variants to
/// get only those entries. The more specific OVERRIDE_* variants group
/// entries into the functions that are emitted in the specified file;
/// for example, OVERRIDE_CASTING identifies the functions that are defined
/// in Casting.cpp.
// NOTE: the entries in this file are used to build the struct layout for
// the OverrideSection in the CompatibilityOverride.cpp that is built into
// the primary runtime. A matching file must be used to build the
// RuntimeOverrideSection in Overrides.cpp for future compatibility
// override libraries that target this release.
//
// Because compatibility override libraries target a specific release of
// Swift, there is no inherent reason the entries in this file cannot be
// arbitrarily rearranged between release cycles, as long as a matching
// file is used to build any future compatibility override library
// targeting this release. However, the targeting of compatibility
// override libraries is precise only to a specific major+minor release
// number (e.g. 5.6). Therefore, care must be taken to avoid ABI breaks
// in this file between patch releases, or else it will become impossible
// to create a compatibility override library for this release:
//
// - Moving or removing entries in this file will break the ABI.
//
// - Changing an entry to use a different implementation file is allowed,
// but do not move the entry to be grouped with the other entries for
// the implementation file, as this will break the ABI.
//
// - New entries can be added to the end without breaking the ABI. This
// is possible even if there have already been patch releases for this
// major+minor release, since older patch releases of the runtime will
// simply not read the new fields. It is not possible if a compatibility
// override library has already been released for this major+minor
// release, but that is unlikely for releases under active development.
//
// When creating a new compatibility override library, always clone the
// last .def files from the appropriate release branch and edit this comment.
#ifdef OVERRIDE
# define OVERRIDE_METADATALOOKUP OVERRIDE
# define OVERRIDE_CASTING OVERRIDE
# define OVERRIDE_DYNAMICCASTING OVERRIDE
# define OVERRIDE_OBJC OVERRIDE
# define OVERRIDE_FOREIGN OVERRIDE
# define OVERRIDE_PROTOCOLCONFORMANCE OVERRIDE
# define OVERRIDE_KEYPATH OVERRIDE
# define OVERRIDE_WITNESSTABLE OVERRIDE
#else
# ifndef OVERRIDE_METADATALOOKUP
# define OVERRIDE_METADATALOOKUP(...)
# endif
# ifndef OVERRIDE_CASTING
# define OVERRIDE_CASTING(...)
# endif
# ifndef OVERRIDE_DYNAMICCASTING
# define OVERRIDE_DYNAMICCASTING(...)
# endif
# ifndef OVERRIDE_OBJC
# define OVERRIDE_OBJC(...)
# endif
# ifndef OVERRIDE_FOREIGN
# define OVERRIDE_FOREIGN(...)
# endif
# ifndef OVERRIDE_PROTOCOLCONFORMANCE
# define OVERRIDE_PROTOCOLCONFORMANCE(...)
# endif
# ifndef OVERRIDE_KEYPATH
# define OVERRIDE_KEYPATH(...)
# endif
# ifndef OVERRIDE_WITNESSTABLE
# define OVERRIDE_WITNESSTABLE(...)
# endif
#endif
OVERRIDE_DYNAMICCASTING(dynamicCast, bool, , , swift::,
(OpaqueValue *dest, OpaqueValue *src,
const Metadata *srcType,
const Metadata *targetType,
DynamicCastFlags flags),
(dest, src, srcType, targetType, flags))
OVERRIDE_CASTING(dynamicCastClass, const void *, , , swift::,
(const void *object,
const ClassMetadata *targetType),
(object, targetType))
OVERRIDE_CASTING(dynamicCastClassUnconditional, const void *, , , swift::,
(const void *object,
const ClassMetadata *targetType,
const char *file, unsigned line, unsigned column),
(object, targetType, file, line, column))
OVERRIDE_CASTING(dynamicCastUnknownClass, const void *, , , swift::,
(const void *object, const Metadata *targetType),
(object, targetType))
OVERRIDE_CASTING(dynamicCastUnknownClassUnconditional, const void *, , , swift::,
(const void *object, const Metadata *targetType,
const char *file, unsigned line, unsigned column),
(object, targetType, file, line, column))
OVERRIDE_CASTING(dynamicCastMetatype, const Metadata *, , , swift::,
(const Metadata *sourceType,
const Metadata *targetType),
(sourceType, targetType))
OVERRIDE_CASTING(dynamicCastMetatypeUnconditional, const Metadata *, , , swift::,
(const Metadata *sourceType,
const Metadata *targetType,
const char *file, unsigned line, unsigned column),
(sourceType, targetType, file, line, column))
OVERRIDE_FOREIGN(dynamicCastForeignClassMetatype, const ClassMetadata *, , , swift::,
(const ClassMetadata *sourceType,
const ClassMetadata *targetType),
(sourceType, targetType))
OVERRIDE_FOREIGN(dynamicCastForeignClassMetatypeUnconditional,
const ClassMetadata *, , , swift::,
(const ClassMetadata *sourceType,
const ClassMetadata *targetType,
const char *file, unsigned line, unsigned column),
(sourceType, targetType, file, line, column))
OVERRIDE_PROTOCOLCONFORMANCE(conformsToProtocol, const WitnessTable *, , , swift::,
(const Metadata * const type,
const void *protocol),
(type, protocol))
OVERRIDE_PROTOCOLCONFORMANCE(conformsToProtocol2, const WitnessTable *, , , swift::,
(const Metadata * const type,
const ProtocolDescriptor *protocol),
(type, protocol))
OVERRIDE_PROTOCOLCONFORMANCE(conformsToProtocolCommon, const WitnessTable *, , , swift::,
(const Metadata * const type,
const ProtocolDescriptor *protocol),
(type, protocol))
OVERRIDE_KEYPATH(getKeyPath, const HeapObject *, , , swift::,
(const void *pattern, const void *arguments),
(pattern, arguments))
OVERRIDE_METADATALOOKUP(getTypeByMangledNode, TypeLookupErrorOr<TypeInfo>, , SWIFT_CC(swift), swift::,
(MetadataRequest request,
Demangler &demangler,
Demangle::NodePointer node,
const void * const *arguments,
SubstGenericParameterFn substGenericParam,
SubstDependentWitnessTableFn substWitnessTable),
(request, demangler, node, arguments, substGenericParam, substWitnessTable))
OVERRIDE_METADATALOOKUP(getTypeByMangledName, TypeLookupErrorOr<TypeInfo>, , SWIFT_CC(swift), swift::,
(MetadataRequest request,
StringRef typeName,
const void * const *arguments,
SubstGenericParameterFn substGenericParam,
SubstDependentWitnessTableFn substWitnessTable),
(request, typeName, arguments, substGenericParam, substWitnessTable))
OVERRIDE_WITNESSTABLE(getAssociatedTypeWitnessSlow, MetadataResponse,
SWIFT_RUNTIME_STDLIB_INTERNAL, SWIFT_CC(swift), swift::,
(MetadataRequest request, WitnessTable *wtable,
const Metadata *conformingType,
const ProtocolRequirement *reqBase,
const ProtocolRequirement *assocType),
(request, wtable, conformingType, reqBase, assocType))
OVERRIDE_WITNESSTABLE(getAssociatedConformanceWitnessSlow, const WitnessTable *,
SWIFT_RUNTIME_STDLIB_INTERNAL, SWIFT_CC(swift), swift::,
(WitnessTable *wtable, const Metadata *conformingType,
const Metadata *assocType,
const ProtocolRequirement *reqBase,
const ProtocolRequirement *assocConformance),
(wtable, conformingType, assocType, reqBase,
assocConformance))
#if SWIFT_OBJC_INTEROP
OVERRIDE_OBJC(dynamicCastObjCClass, const void *, , , swift::,
(const void *object,
const ClassMetadata *targetType),
(object, targetType))
OVERRIDE_OBJC(dynamicCastObjCClassUnconditional, const void *, , , swift::,
(const void *object,
const ClassMetadata *targetType,
const char *file, unsigned line, unsigned column),
(object, targetType, file, line, column))
OVERRIDE_OBJC(dynamicCastObjCClassMetatype, const ClassMetadata *, , , swift::,
(const ClassMetadata *sourceType,
const ClassMetadata *targetType),
(sourceType, targetType))
OVERRIDE_OBJC(dynamicCastObjCClassMetatypeUnconditional, const ClassMetadata *, , , swift::,
(const ClassMetadata *sourceType, const ClassMetadata *targetType,
const char *file, unsigned line, unsigned column),
(sourceType, targetType, file, line, column))
OVERRIDE_FOREIGN(dynamicCastForeignClass, const void *, , , swift::,
(const void *object,
const ForeignClassMetadata *targetType),
(object, targetType))
OVERRIDE_FOREIGN(dynamicCastForeignClassUnconditional, const void *, , , swift::,
(const void *object, const ForeignClassMetadata *targetType,
const char *file, unsigned line, unsigned column),
(object, targetType, file, line, column))
#endif
#undef OVERRIDE
#undef OVERRIDE_METADATALOOKUP
#undef OVERRIDE_CASTING
#undef OVERRIDE_DYNAMICCASTING
#undef OVERRIDE_OBJC
#undef OVERRIDE_FOREIGN
#undef OVERRIDE_PROTOCOLCONFORMANCE
#undef OVERRIDE_KEYPATH
#undef OVERRIDE_WITNESSTABLE