summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2021-03-19 15:39:01 -0700
committerGitHub <noreply@github.com>2021-03-19 15:39:01 -0700
commit6856f261d78ba245b0f6364ad4683778e022b5d2 (patch)
tree4c97f1a97822798014e8659fde7cb84c6e08991a /src
parent5d9a6049c08c3b9e7ddb0c061f15b2731c6bad77 (diff)
downloadbinaryen-6856f261d78ba245b0f6364ad4683778e022b5d2.tar.gz
binaryen-6856f261d78ba245b0f6364ad4683778e022b5d2.tar.bz2
binaryen-6856f261d78ba245b0f6364ad4683778e022b5d2.zip
Fixed reading 64-bit memories and output of globals (#3709)
Diffstat (limited to 'src')
-rw-r--r--src/wasm/wasm-binary.cpp4
-rw-r--r--src/wasm/wasm-emscripten.cpp4
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
<< '"';
}