summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2023-05-03 14:53:24 -0700
committerGitHub <noreply@github.com>2023-05-03 14:53:24 -0700
commit070542f9f30cc262ac741fb3a620037900ac6381 (patch)
tree9cdfa3f78bf1cd72c5ce2830336c9c36a8954ee3 /src
parent345b2498b78cb14e9cb87a63f511ef6f55044e9c (diff)
downloadbinaryen-070542f9f30cc262ac741fb3a620037900ac6381.tar.gz
binaryen-070542f9f30cc262ac741fb3a620037900ac6381.tar.bz2
binaryen-070542f9f30cc262ac741fb3a620037900ac6381.zip
Emit memory segment index for data segments (#5699)
Before this fix we would flip all data segments to use the first memory.
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);
}