diff options
| author | matt rice <ratmice@gmail.com> | 2024-02-23 16:05:28 -0800 |
|---|---|---|
| committer | matt rice <ratmice@gmail.com> | 2024-02-23 17:47:15 -0800 |
| commit | a85700a1a8f5aa729bd19e5a2a78f8a80d623093 (patch) | |
| tree | b7f38945fd88ca60bc610fc44010099271213d6f /compiler/rustc_codegen_llvm/src | |
| parent | 2dbd6233ccdb2cd4b621a5e839a95c3fbbc0c375 (diff) | |
| download | rust-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.rs | 10 |
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, |
