Skip to content

Commit

Permalink
Merge pull request swiftlang#14378 from compnerd/windows-runtime-init…
Browse files Browse the repository at this point in the history
…ializer
  • Loading branch information
swift-ci authored Feb 3, 2018
2 parents d2862dd + 76d7bfd commit 5663b44
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions stdlib/public/runtime/SwiftRT-COFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
#define PRAGMA(pragma) _Pragma(#pragma)

#define DECLARE_SWIFT_SECTION(name) \
PRAGMA(section("." #name "$A", long, read, write)) \
PRAGMA(section("." #name "$A", long, read)) \
__declspec(allocate("." #name "$A")) \
static uintptr_t __start_##name = 0; \
\
PRAGMA(section("." #name "$C", long, read, write)) \
PRAGMA(section("." #name "$C", long, read)) \
__declspec(allocate("." #name "$C")) \
static uintptr_t __stop_##name = 0;

extern "C" {
DECLARE_SWIFT_SECTION(sw5prt)
DECLARE_SWIFT_SECTION(sw5prtc)
DECLARE_SWIFT_SECTION(sw5tymd)

Expand All @@ -59,6 +60,7 @@ static void swift_image_constructor() {
nullptr,
nullptr,

SWIFT_SECTION_RANGE(sw5prt),
SWIFT_SECTION_RANGE(sw5prtc),
SWIFT_SECTION_RANGE(sw5tymd),

Expand All @@ -73,6 +75,8 @@ static void swift_image_constructor() {
swift_addNewDSOImage(&sections);
}

#pragma section(".CRT$XCIS", long, read)

__declspec(allocate(".CRT$XCIS"))
extern "C" void (*pSwiftImageConstructor)(void) = &swift_image_constructor;
#pragma comment(linker, "/include:" STRING(C_LABEL(pSwiftImageConstructor)))
Expand Down

0 comments on commit 5663b44

Please sign in to comment.