From bf852438f1bd4a168f037d15b38c7d941bd26f52 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Fri, 23 Feb 2024 13:18:33 +0000 Subject: [PATCH] [Runtime][ELF] Mark metadata sections as retained. If section garbage collection is turned on in the linker, the metadata sections may be dropped as there are no external references to them. To fix this, we need to mark them as retained (add an 'R' to the declaration). rdar://123504095 --- stdlib/public/runtime/SwiftRT-ELF-WASM.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/public/runtime/SwiftRT-ELF-WASM.cpp b/stdlib/public/runtime/SwiftRT-ELF-WASM.cpp index b83a570631c48..26ba85f84f1cf 100644 --- a/stdlib/public/runtime/SwiftRT-ELF-WASM.cpp +++ b/stdlib/public/runtime/SwiftRT-ELF-WASM.cpp @@ -36,7 +36,7 @@ static const void *__backtraceRef __attribute__((used)) // by the linker. Otherwise, we may end up with undefined symbol references as // the linker table section was never constructed. #if defined(__ELF__) -# define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"a\"\n"); +# define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"aR\"\n"); #elif defined(__wasm__) # define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"R\",@\n"); #endif