Skip to content

Commit 76d7bfd

Browse files
committed
runtime: ensure that the module constructor element is RO
The default attribute on the section is read/write. This would cause the section to have different attributes when compiled. The linker would then preserve the section rather than merge it into the right location. This was noticed when linking with `link.exe`.
1 parent bb55044 commit 76d7bfd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

stdlib/public/runtime/SwiftRT-COFF.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ static void swift_image_constructor() {
7575
swift_addNewDSOImage(&sections);
7676
}
7777

78+
#pragma section(".CRT$XCIS", long, read)
79+
7880
__declspec(allocate(".CRT$XCIS"))
7981
extern "C" void (*pSwiftImageConstructor)(void) = &swift_image_constructor;
8082
#pragma comment(linker, "/include:" STRING(C_LABEL(pSwiftImageConstructor)))

0 commit comments

Comments
 (0)