@@ -239,8 +239,8 @@ struct SWTTypeMetadataRecord {
239
239
}
240
240
};
241
241
242
- #if defined(__APPLE__)
243
242
#if !defined(SWT_NO_DYNAMIC_LINKING)
243
+ #if defined(__APPLE__)
244
244
#pragma mark - Apple implementation
245
245
246
246
// / Get a copy of the currently-loaded type metadata sections list.
@@ -318,28 +318,6 @@ static void enumerateTypeMetadataSections(const SectionEnumerator& body) {
318
318
}
319
319
}
320
320
321
- #else
322
- #pragma mark - Apple implementation (statically linked)
323
-
324
- // This environment does not have a dynamic linker/loader. Therefore, there is
325
- // only one image (this one) with Swift code in it.
326
- // SEE: https://github.com/swiftlang/swift/tree/main/stdlib/public/runtime/ImageInspectionStatic.cpp
327
-
328
- extern " C" const char sectionBegin __asm (" section$start$__TEXT$__swift5_types" );
329
- extern " C" const char sectionEnd __asm (" section$end$__TEXT$__swift5_types" );
330
-
331
- template <typename SectionEnumerator>
332
- static void enumerateTypeMetadataSections (const SectionEnumerator& body) {
333
- SWTSectionBounds<SWTTypeMetadataRecord> sb = {
334
- nullptr ,
335
- §ionBegin,
336
- static_cast <size_t >(std::distance (§ionBegin, §ionEnd))
337
- };
338
- bool stop = false ;
339
- body (sb, &stop);
340
- }
341
- #endif
342
-
343
321
#elif defined(_WIN32)
344
322
#pragma mark - Windows implementation
345
323
@@ -434,29 +412,6 @@ static void enumerateTypeMetadataSections(const SectionEnumerator& body) {
434
412
}
435
413
}
436
414
437
- #elif defined(__wasi__)
438
- #pragma mark - WASI implementation (statically linked)
439
-
440
- extern " C" const char __start_swift5_type_metadata;
441
- extern " C" const char __stop_swift5_type_metadata;
442
-
443
- template <typename SectionEnumerator>
444
- static void enumerateTypeMetadataSections (const SectionEnumerator& body) {
445
- // WASI only has a single image (so far) and it is statically linked, so all
446
- // Swift metadata ends up in the same section bounded by the named symbols
447
- // above. So we can just yield the section betwixt them.
448
- const auto & sectionBegin = __start_swift5_type_metadata;
449
- const auto & sectionEnd = __stop_swift5_type_metadata;
450
-
451
- SWTSectionBounds<SWTTypeMetadataRecord> sb = {
452
- nullptr ,
453
- §ionBegin,
454
- static_cast <size_t >(std::distance (§ionBegin, §ionEnd))
455
- };
456
- bool stop = false ;
457
- body (sb, &stop);
458
- }
459
-
460
415
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__ANDROID__)
461
416
#pragma mark - ELF implementation
462
417
@@ -517,11 +472,38 @@ static void enumerateTypeMetadataSections(const SectionEnumerator& body) {
517
472
}, const_cast <SectionEnumerator *>(&body));
518
473
}
519
474
#else
520
- #warning Platform-specific implementation missing: Runtime test discovery unavailable
475
+ #warning Platform-specific implementation missing: Runtime test discovery unavailable (dynamic)
521
476
template <typename SectionEnumerator>
522
477
static void enumerateTypeMetadataSections (const SectionEnumerator& body) {}
523
478
#endif
524
479
480
+ #else
481
+ #pragma mark - Statically-linked implementation
482
+
483
+ #if defined(__APPLE__)
484
+ extern " C" const char sectionBegin __asm__ (" section$start$__TEXT$__swift5_types" );
485
+ extern " C" const char sectionEnd __asm__ (" section$end$__TEXT$__swift5_types" );
486
+ #elif defined(__wasi__)
487
+ extern " C" const char sectionBegin __asm__ (" __start_swift5_type_metadata" );
488
+ extern " C" const char sectionEnd __asm__ (" __stop_swift5_type_metadata" );
489
+ #else
490
+ #warning Platform-specific implementation missing: Runtime test discovery unavailable (static)
491
+ static const char sectionBegin = 0 ;
492
+ static const char & sectionEnd = sectionBegin;
493
+ #endif
494
+
495
+ template <typename SectionEnumerator>
496
+ static void enumerateTypeMetadataSections (const SectionEnumerator& body) {
497
+ SWTSectionBounds<SWTTypeMetadataRecord> sb = {
498
+ nullptr ,
499
+ §ionBegin,
500
+ static_cast <size_t >(std::distance (§ionBegin, §ionEnd))
501
+ };
502
+ bool stop = false ;
503
+ body (sb, &stop);
504
+ }
505
+ #endif
506
+
525
507
#pragma mark -
526
508
527
509
void swt_enumerateTypesWithNamesContaining (const char *nameSubstring, void *context, SWTTypeEnumerator body) {
0 commit comments