Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Testing/Discovery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ extension TestContentRecord where T: TestContent & ~Copyable {
/// If this function is called more than once on the same instance, a new
/// value is created on each call.
func load(withHint hint: T.TestContentAccessorHint? = nil) -> T.TestContentAccessorResult? {
guard let accessor = _record.accessor.map(swt_resign) else {
guard let accessor = _record.accessor else {
return nil
}

Expand Down
1 change: 1 addition & 0 deletions Sources/_TestingInternals/Discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const void *_Nonnull const SWTTypeMetadataSectionBounds[2] = {
#pragma mark - Swift ABI

#if defined(__PTRAUTH_INTRINSICS__)
#include <ptrauth.h>
#define SWT_PTRAUTH_SWIFT_TYPE_DESCRIPTOR __ptrauth(ptrauth_key_process_independent_data, 1, 0xae86)
#else
#define SWT_PTRAUTH_SWIFT_TYPE_DESCRIPTOR
Expand Down
36 changes: 2 additions & 34 deletions Sources/_TestingInternals/include/Discovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,9 @@

SWT_ASSUME_NONNULL_BEGIN

#pragma mark - Test content records

/// The type of a test content accessor.
///
/// - Parameters:
/// - outValue: On successful return, initialized to the value of the
/// represented test content record.
/// - hint: A hint value whose type and meaning depend on the type of test
/// record being accessed.
///
/// - Returns: Whether or not the test record was initialized at `outValue`. If
/// this function returns `true`, the caller is responsible for deinitializing
/// the memory at `outValue` when done.
typedef bool (* SWTTestContentAccessor)(void *outValue, const void *_Null_unspecified hint);

/// Resign an accessor function from a test content record.
///
/// - Parameters:
/// - accessor: The accessor function to resign.
///
/// - Returns: A resigned copy of `accessor` on platforms that use pointer
/// authentication, and an exact copy of `accessor` elsewhere.
///
/// - Bug: This C function is needed because Apple's pointer authentication
/// intrinsics are not available in Swift. ([141465242](rdar://141465242))
SWT_SWIFT_NAME(swt_resign(_:))
static SWTTestContentAccessor swt_resignTestContentAccessor(SWTTestContentAccessor accessor) {
#if defined(__APPLE__) && __has_include(<ptrauth.h>)
accessor = ptrauth_strip(accessor, ptrauth_key_function_pointer);
accessor = ptrauth_sign_unauthenticated(accessor, ptrauth_key_function_pointer, 0);
#endif
return accessor;
}

#if defined(__ELF__) && defined(__swift__)
#pragma mark - ELF image enumeration

/// A function exported by the Swift runtime that enumerates all metadata
/// sections loaded into the current process.
///
Expand Down
4 changes: 0 additions & 4 deletions Sources/_TestingInternals/include/Includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@
#if !SWT_NO_LIBDISPATCH
#include <dispatch/dispatch.h>
#endif

#if __has_include(<ptrauth.h>)
#include <ptrauth.h>
#endif
#endif

#if defined(__FreeBSD__)
Expand Down