Skip to content

Commit 1747fb0

Browse files
authored
Remove arm64e ptrauth resigning from test content discovery. (#919)
Finally got around to double-checking and we don't need to do ptrauth resigning on the `accessor` function pointers in the new test content section as dyld already does it for us at load time. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent a5921e0 commit 1747fb0

File tree

4 files changed

+4
-39
lines changed

4 files changed

+4
-39
lines changed

Sources/Testing/Discovery.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extension TestContentRecord where T: TestContent & ~Copyable {
116116
/// If this function is called more than once on the same instance, a new
117117
/// value is created on each call.
118118
func load(withHint hint: T.TestContentAccessorHint? = nil) -> T.TestContentAccessorResult? {
119-
guard let accessor = _record.accessor.map(swt_resign) else {
119+
guard let accessor = _record.accessor else {
120120
return nil
121121
}
122122

Sources/_TestingInternals/Discovery.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const void *_Nonnull const SWTTypeMetadataSectionBounds[2] = {
4747
#pragma mark - Swift ABI
4848

4949
#if defined(__PTRAUTH_INTRINSICS__)
50+
#include <ptrauth.h>
5051
#define SWT_PTRAUTH_SWIFT_TYPE_DESCRIPTOR __ptrauth(ptrauth_key_process_independent_data, 1, 0xae86)
5152
#else
5253
#define SWT_PTRAUTH_SWIFT_TYPE_DESCRIPTOR

Sources/_TestingInternals/include/Discovery.h

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,9 @@
1616

1717
SWT_ASSUME_NONNULL_BEGIN
1818

19-
#pragma mark - Test content records
20-
21-
/// The type of a test content accessor.
22-
///
23-
/// - Parameters:
24-
/// - outValue: On successful return, initialized to the value of the
25-
/// represented test content record.
26-
/// - hint: A hint value whose type and meaning depend on the type of test
27-
/// record being accessed.
28-
///
29-
/// - Returns: Whether or not the test record was initialized at `outValue`. If
30-
/// this function returns `true`, the caller is responsible for deinitializing
31-
/// the memory at `outValue` when done.
32-
typedef bool (* SWTTestContentAccessor)(void *outValue, const void *_Null_unspecified hint);
33-
34-
/// Resign an accessor function from a test content record.
35-
///
36-
/// - Parameters:
37-
/// - accessor: The accessor function to resign.
38-
///
39-
/// - Returns: A resigned copy of `accessor` on platforms that use pointer
40-
/// authentication, and an exact copy of `accessor` elsewhere.
41-
///
42-
/// - Bug: This C function is needed because Apple's pointer authentication
43-
/// intrinsics are not available in Swift. ([141465242](rdar://141465242))
44-
SWT_SWIFT_NAME(swt_resign(_:))
45-
static SWTTestContentAccessor swt_resignTestContentAccessor(SWTTestContentAccessor accessor) {
46-
#if defined(__APPLE__) && __has_include(<ptrauth.h>)
47-
accessor = ptrauth_strip(accessor, ptrauth_key_function_pointer);
48-
accessor = ptrauth_sign_unauthenticated(accessor, ptrauth_key_function_pointer, 0);
49-
#endif
50-
return accessor;
51-
}
52-
5319
#if defined(__ELF__) && defined(__swift__)
20+
#pragma mark - ELF image enumeration
21+
5422
/// A function exported by the Swift runtime that enumerates all metadata
5523
/// sections loaded into the current process.
5624
///

Sources/_TestingInternals/include/Includes.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@
127127
#if !SWT_NO_LIBDISPATCH
128128
#include <dispatch/dispatch.h>
129129
#endif
130-
131-
#if __has_include(<ptrauth.h>)
132-
#include <ptrauth.h>
133-
#endif
134130
#endif
135131

136132
#if defined(__FreeBSD__)

0 commit comments

Comments
 (0)