diff options
-rw-r--r-- | src/wasm/wasm-binary.cpp | 4 | ||||
-rw-r--r-- | src/wasm/wasm-emscripten.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index c8568e469..37fa1ab78 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1926,17 +1926,17 @@ void WasmBinaryBuilder::getResizableLimits(Address& initial, Type& indexType, Address defaultIfNoMax) { auto flags = getU32LEB(); - initial = getU32LEB(); bool hasMax = (flags & BinaryConsts::HasMaximum) != 0; bool isShared = (flags & BinaryConsts::IsShared) != 0; bool is64 = (flags & BinaryConsts::Is64) != 0; + initial = is64 ? getU64LEB() : getU32LEB(); if (isShared && !hasMax) { throwError("shared memory must have max size"); } shared = isShared; indexType = is64 ? Type::i64 : Type::i32; if (hasMax) { - max = getU32LEB(); + max = is64 ? getU64LEB() : getU32LEB(); } else { max = defaultIfNoMax; } diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index 684c789c3..bcf9539a6 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -450,9 +450,9 @@ std::string EmscriptenGlueGenerator::generateEmscriptenMetadata() { for (const auto& ex : wasm.exports) { if (ex->kind == ExternalKind::Global) { const Global* g = wasm.getGlobal(ex->value); - assert(g->type == Type::i32); + assert(g->type == Type::i32 || g->type == Type::i64); Const* init = g->init->cast<Const>(); - uint32_t addr = init->value.geti32(); + uint64_t addr = init->value.getInteger(); meta << nextElement() << '"' << ex->name.str << "\" : \"" << addr << '"'; } |