diff --git a/stdlib/public/runtime/SwiftRT-WASM.cpp b/stdlib/public/runtime/SwiftRT-WASM.cpp index 1b4c84f3f2ae9..24dc7130def4d 100644 --- a/stdlib/public/runtime/SwiftRT-WASM.cpp +++ b/stdlib/public/runtime/SwiftRT-WASM.cpp @@ -14,14 +14,10 @@ #include -// Create empty sections to ensure that the start/stop symbols are synthesized -// by the linker. Otherwise, we may end up with undefined symbol references as -// the linker table section was never constructed. - +// Link start/stop symbols weakly to link them if they aren't synthesized by the linker. #define DECLARE_SWIFT_SECTION(name) \ - __attribute__((__used__,__section__(#name),__aligned__(1))) const char __dummy_##name = 0x00; \ - __attribute__((__visibility__("hidden"),__aligned__(1))) extern const char __start_##name; \ - __attribute__((__visibility__("hidden"),__aligned__(1))) extern const char __stop_##name; + __attribute__((__visibility__("hidden"),__aligned__(1),weak)) extern const char __start_##name; \ + __attribute__((__visibility__("hidden"),__aligned__(1),weak)) extern const char __stop_##name; extern "C" { DECLARE_SWIFT_SECTION(swift5_protocols)