diff --git a/llvm/lib/MC/MCParser/WasmAsmParser.cpp b/llvm/lib/MC/MCParser/WasmAsmParser.cpp --- a/llvm/lib/MC/MCParser/WasmAsmParser.cpp +++ b/llvm/lib/MC/MCParser/WasmAsmParser.cpp @@ -151,10 +151,7 @@ // TargetLoweringObjectFileWasm .StartsWith(".init_array", SectionKind::getData()) .StartsWith(".debug_", SectionKind::getMetadata()) - .Default(Optional()); - if (!Kind.hasValue()) - return Parser->Error(Lexer->getLoc(), "unknown section kind: " + Name); - + .Default(SectionKind::getData()); // Update section flags if present in this .section directive bool Passive = false; diff --git a/llvm/test/MC/WebAssembly/data-section-combined.s b/llvm/test/MC/WebAssembly/data-section-combined.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/WebAssembly/data-section-combined.s @@ -0,0 +1,37 @@ +# Test that placing multiple data symbols in the same section works + +# RUN: llvm-mc -triple=wasm32-unknown-unknown < %s | FileCheck %s + +test0: + .functype test0 () -> (i32) + i32.const a + i32.const b + end_function + + .section mysec,"",@ +a: + .int32 42 + .int32 43 + .size a, 8 +b: + .int32 44 + .size b, 4 + +# CHECK: .section mysec,"",@ +# CHECK-NEXT: a: +# CHECK-NEXT: .int32 42 +# CHECK-NEXT: .int32 43 +# CHECK-NEXT: .size a, 8 +# CHECK-NEXT: b: +# CHECK-NEXT: .int32 44 +# CHECK-NEXT: .size b, 4 + +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown < %s | llvm-objdump --triple=wasm32-unknown-unknown -d -t -r - | FileCheck %s --check-prefix=OBJ + + +# OBJ: 00000001 : +# OBJ: 3: 41 80 80 80 80 00 i32.const 0 +# OBJ-NEXT: 00000004: R_WASM_MEMORY_ADDR_SLEB a+0 +# OBJ-NEXT: 9: 41 88 80 80 80 00 i32.const 8 +# OBJ-NEXT: 0000000a: R_WASM_MEMORY_ADDR_SLEB b+0 +# OBJ-NEXT: f: 0b end