1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[WebAssembly] Use data sections by default

This allows data sections that don't start with `.data` to be
used/created.

Without this, clang's `__attribute__((section("foo")))` would
generate assembly that would not parse.

Differential Revision: https://reviews.llvm.org/D96233
This commit is contained in:
Sam Clegg 2021-02-07 20:22:07 -08:00
parent 82af593e94
commit 4cf94ad9e7
2 changed files with 38 additions and 4 deletions

View File

@ -151,10 +151,7 @@ public:
// TargetLoweringObjectFileWasm
.StartsWith(".init_array", SectionKind::getData())
.StartsWith(".debug_", SectionKind::getMetadata())
.Default(Optional<SectionKind>());
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;

View File

@ -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 <test0>:
# 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