Files
rust/tests/codegen-llvm/wasm_custom_section.rs
bjorn3 281be7d22d Put data segment in specified section with link_section on wasm
This is the normal behavior on other targets, but previously on wasm the
data segment would be in the default section and instead a custom
section with the given name would be added to the wasm module.
2026-08-27 12:57:37 +02:00

20 lines
627 B
Rust

//@ only-wasm32
// Check that link_section on wasm emits both a data segment in the given
// section and a custom section.
#![crate_type = "lib"]
#![feature(core_intrinsics, link_llvm_intrinsics)]
#[unsafe(link_section = "foo")]
#[unsafe(no_mangle)]
#[used]
static FOO: [u8; 22] = *b"custom section content";
// Data segment in foo section
// CHECK: @FOO = dso_local constant [22 x i8] c"custom section content", section "foo"
// CHECK: @llvm.used = appending global [1 x ptr] [ptr @FOO], section "llvm.metadata"
// Custom section
// CHECK: !wasm.custom_sections = !{!3}
// CHECK: !3 = !{!"foo", !"custom section content"}