Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp =================================================================== --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1417,6 +1417,10 @@ Group = C->getName(); } + if (isa(GO)) { + return SelectSectionForGlobal(GO, Kind, TM); + } + return getContext().getWasmSection(Name, Kind, Group, MCContext::GenericSectionID); } Index: test/MC/WebAssembly/function-sections.ll =================================================================== --- /dev/null +++ test/MC/WebAssembly/function-sections.ll @@ -0,0 +1,29 @@ +; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s + +target triple = "wasm32-unknown-unknown" + +define hidden i32 @foo() section "baz" { +entry: + ret i32 2 +} + +define hidden i32 @bar() section "baz" { +entry: + ret i32 1 +} + +; CHECK: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: Version: 1 +; CHECK-NEXT: SymbolTable: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Name: foo +; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] +; CHECK-NEXT: Function: 0 +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Name: bar +; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] +; CHECK-NEXT: Function: 1 +