Skip to content
Draft
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
11 changes: 5 additions & 6 deletions Sources/_TestDiscovery/SectionBounds.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,12 @@ private func _sectionBounds(_ kind: SectionBounds.Kind) -> [SectionBounds] {
#if _runtime(_ObjC)
if #available(_objcCopyImageHeadersAPI, *) {
var imageCount = UInt32(0)
if let imageHeaders = swt_objc_copyImageHeaders(&imageCount) {
defer {
free(imageHeaders)
}
return UnsafeBufferPointer(start: imageHeaders, count: Int(clamping: imageCount))
.compactMap { _findSectionBounds(kind, in: $0) }
let imageHeaders = objc_copyImageHeaders(&imageCount)
defer {
free(imageHeaders)
}
return UnsafeBufferPointer(start: imageHeaders, count: Int(clamping: imageCount))
.compactMap { _findSectionBounds(kind, in: $0) }
}

var imageCount = UInt32(0)
Expand Down
17 changes: 0 additions & 17 deletions Sources/_TestingInternals/include/Stubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,6 @@ static mach_port_t swt_mach_task_self(void) {
#endif

#if defined(__APPLE__) && defined(__OBJC2__) && !SWT_NO_DYNAMIC_LINKING
/// Get an array of Mach headers that are loaded into the current process and
/// contain Objective-C or Swift code.
///
/// This function is provided because the testing library still needs to
/// build with older Apple SDKs that do not contain a declaration of the runtime
/// `objc_copyImageHeaders()` function.
///
/// - Bug: This declaration should be removed once Apple has shipped an updated
/// SDK that includes `objc_copyImageHeaders()`.
static struct mach_header const *_Nonnull *_Nullable swt_objc_copyImageHeaders(unsigned int *_Nullable outCount) {
__auto_type objc_copyImageHeaders = (__typeof__(&swt_objc_copyImageHeaders))dlsym(RTLD_DEFAULT, "objc_copyImageHeaders");
if (objc_copyImageHeaders) {
return (* objc_copyImageHeaders)(outCount);
}
return 0;
}

/// Get an array of the names of Mach images that are loaded into the current
/// process and contain Objective-C or Swift code.
///
Expand Down
Loading