about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authormatt rice <ratmice@gmail.com>2024-02-23 16:05:28 -0800
committermatt rice <ratmice@gmail.com>2024-02-23 17:47:15 -0800
commita85700a1a8f5aa729bd19e5a2a78f8a80d623093 (patch)
treeb7f38945fd88ca60bc610fc44010099271213d6f /compiler/rustc_codegen_llvm/src
parent2dbd6233ccdb2cd4b621a5e839a95c3fbbc0c375 (diff)
downloadrust-a85700a1a8f5aa729bd19e5a2a78f8a80d623093.tar.gz
rust-a85700a1a8f5aa729bd19e5a2a78f8a80d623093.zip
Handle .init_array link_section specially on wasm
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/consts.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs
index ec2fb2c6e54..55477ff5d29 100644
--- a/compiler/rustc_codegen_llvm/src/consts.rs
+++ b/compiler/rustc_codegen_llvm/src/consts.rs
@@ -481,8 +481,14 @@ impl<'ll> StaticMethods for CodegenCx<'ll, '_> {
             }
 
             // Wasm statics with custom link sections get special treatment as they
-            // go into custom sections of the wasm executable.
-            if self.tcx.sess.target.is_like_wasm {
+            // go into custom sections of the wasm executable. The exception to this
+            // is the `.init_array` section which are treated specially by the wasm linker.
+            if self.tcx.sess.target.is_like_wasm
+                && attrs
+                    .link_section
+                    .map(|link_section| !link_section.as_str().starts_with(".init_array"))
+                    .unwrap_or(true)
+            {
                 if let Some(section) = attrs.link_section {
                     let section = llvm::LLVMMDStringInContext2(
                         self.llcx,