Index: llvm/lib/MC/MCParser/WasmAsmParser.cpp =================================================================== --- llvm/lib/MC/MCParser/WasmAsmParser.cpp +++ llvm/lib/MC/MCParser/WasmAsmParser.cpp @@ -21,6 +21,7 @@ #include "llvm/MC/MCParser/MCAsmLexer.h" #include "llvm/MC/MCParser/MCAsmParser.h" #include "llvm/MC/MCParser/MCAsmParserExtension.h" +#include "llvm/MC/MCObjectFileInfo.h" #include "llvm/MC/MCSectionWasm.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbolWasm.h" @@ -52,6 +53,7 @@ this->MCAsmParserExtension::Initialize(*Parser); addDirectiveHandler<&WasmAsmParser::parseSectionDirectiveText>(".text"); + addDirectiveHandler<&WasmAsmParser::parseSectionDirectiveData>(".data"); addDirectiveHandler<&WasmAsmParser::parseSectionDirective>(".section"); addDirectiveHandler<&WasmAsmParser::parseDirectiveSize>(".size"); addDirectiveHandler<&WasmAsmParser::parseDirectiveType>(".type"); @@ -89,6 +91,12 @@ return false; } + bool parseSectionDirectiveData(StringRef, SMLoc) { + auto *S = getContext().getObjectFileInfo()->getDataSection(); + getStreamer().SwitchSection(S); + return false; + } + uint32_t parseSectionFlags(StringRef FlagStr, bool &Passive, bool &Group) { uint32_t flags = 0; for (char C : FlagStr) { Index: llvm/test/MC/WebAssembly/basic-assembly.s =================================================================== --- llvm/test/MC/WebAssembly/basic-assembly.s +++ llvm/test/MC/WebAssembly/basic-assembly.s @@ -137,6 +137,9 @@ .int32 2000000000 .size .L.str, 28 + .data + .int8 73 + .section .init_array.42,"",@ .p2align 2 .int32 test0 @@ -272,6 +275,10 @@ # CHECK-NEXT: .int32 2000000000 # CHECK-NEXT: .size .L.str, 28 +# CHECK: .data +# CHECK-EMPTY: +# CHECK-NEXT: .int8 73 + # CHECK: .section .init_array.42,"",@ # CHECK-NEXT: .p2align 2 # CHECK-NEXT: .int32 test0