From b61b273ad7ed9b6b27170f3726be79b527198788 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 15 Dec 2015 16:52:31 -0800 Subject: don't emit zero segments --- src/s2wasm.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/s2wasm.h b/src/s2wasm.h index a5e75c9cf..3a8dd7ddb 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -832,12 +832,14 @@ private: mustMatch(name.str); mustMatch(":"); auto raw = new std::vector(); // leaked intentionally, no new allocation in Memory + bool zero = false; if (match(".asciz")) { *raw = getQuoted(); raw->push_back(0); } else if (match(".ascii")) { *raw = getQuoted(); } else if (match(".zero")) { + zero = true; int32_t size = getInt(); for (size_t i = 0; i < size; i++) { raw->push_back(0); @@ -871,8 +873,10 @@ private: while (nextStatic % align) nextStatic++; // assign the address, add to memory staticAddresses[name] = nextStatic; - addressSegments[nextStatic] = wasm.memory.segments.size(); - wasm.memory.segments.emplace_back(nextStatic, (const char*)&(*raw)[0], size); + if (!zero) { + addressSegments[nextStatic] = wasm.memory.segments.size(); + wasm.memory.segments.emplace_back(nextStatic, (const char*)&(*raw)[0], size); + } nextStatic += size; } -- cgit v1.2.3