Add a SWIFT_RUNTIME_MACHO_NO_DYLD stdlib mode that doesn't dynamically look up sections in modules, and only assumes a single static module (#33441)

This commit is contained in:
Kuba (Brecka) Mracek
2020-08-18 11:46:42 -07:00
committed by GitHub
parent d463c7933e
commit db18deaf91
9 changed files with 126 additions and 18 deletions

View File

@@ -18,9 +18,11 @@
///
//===----------------------------------------------------------------------===//
#if defined(__APPLE__) && defined(__MACH__)
#if defined(__APPLE__) && defined(__MACH__) && \
!defined(SWIFT_RUNTIME_MACHO_NO_DYLD)
#include "ImageInspection.h"
#include "ImageInspectionCommon.h"
#include "swift/Runtime/Config.h"
#include <mach-o/dyld.h>
#include <mach-o/getsect.h>
@@ -31,21 +33,17 @@
using namespace swift;
namespace {
/// The Mach-O section name for the section containing protocol descriptor
/// references. This lives within SEG_TEXT.
constexpr const char ProtocolsSection[] = "__swift5_protos";
/// The Mach-O section name for the section containing protocol conformances.
/// This lives within SEG_TEXT.
constexpr const char ProtocolConformancesSection[] = "__swift5_proto";
/// The Mach-O section name for the section containing type references.
/// This lives within SEG_TEXT.
constexpr const char TypeMetadataRecordSection[] = "__swift5_types";
/// The Mach-O section name for the section containing dynamic replacements.
/// This lives within SEG_TEXT.
constexpr const char DynamicReplacementSection[] = "__swift5_replace";
constexpr const char DynamicReplacementSomeSection[] = "__swift5_replac2";
constexpr const char TextSegment[] = SEG_TEXT;
constexpr const char ProtocolsSection[] = MachOProtocolsSection;
constexpr const char ProtocolConformancesSection[] =
MachOProtocolConformancesSection;
constexpr const char TypeMetadataRecordSection[] =
MachOTypeMetadataRecordSection;
constexpr const char DynamicReplacementSection[] =
MachODynamicReplacementSection;
constexpr const char DynamicReplacementSomeSection[] =
MachODynamicReplacementSomeSection;
constexpr const char TextSegment[] = MachOTextSegment;
#if __POINTER_WIDTH__ == 64
using mach_header_platform = mach_header_64;
@@ -182,4 +180,5 @@ void *swift::lookupSection(const char *segment, const char *section, size_t *out
#endif // #ifndef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
#endif // defined(__APPLE__) && defined(__MACH__)
#endif // defined(__APPLE__) && defined(__MACH__) &&
// !defined(SWIFT_RUNTIME_MACHO_NO_DYLD)