summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wasm/wasm-binary.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 28c22aed3..3975dd390 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -590,11 +590,20 @@ void WasmBinaryWriter::writeDataSegments() {
o << U32LEB(wasm->dataSegments.size());
for (auto& segment : wasm->dataSegments) {
uint32_t flags = 0;
+ Index memoryIndex = 0;
if (segment->isPassive) {
flags |= BinaryConsts::IsPassive;
+ } else {
+ memoryIndex = getMemoryIndex(segment->memory);
+ if (memoryIndex) {
+ flags |= BinaryConsts::HasIndex;
+ }
}
o << U32LEB(flags);
if (!segment->isPassive) {
+ if (memoryIndex) {
+ o << U32LEB(memoryIndex);
+ }
writeExpression(segment->offset);
o << int8_t(BinaryConsts::End);
}