diff options
author | Yury Delendik <ydelendik@mozilla.com> | 2016-04-20 17:15:52 -0500 |
---|---|---|
committer | Yury Delendik <ydelendik@mozilla.com> | 2016-04-20 17:15:52 -0500 |
commit | b9637c4b74d340e1e8f5a3ab7a4f11e4fee7ce76 (patch) | |
tree | ebce9633b164db8424a8598bf96795e9cecee2bf /src | |
parent | 31dd39afd6197743d3ccbb2cfa4276134c6751d2 (diff) | |
download | binaryen-b9637c4b74d340e1e8f5a3ab7a4f11e4fee7ce76.tar.gz binaryen-b9637c4b74d340e1e8f5a3ab7a4f11e4fee7ce76.tar.bz2 binaryen-b9637c4b74d340e1e8f5a3ab7a4f11e4fee7ce76.zip |
Parses more than one entry in the .init_array section.
Diffstat (limited to 'src')
-rw-r--r-- | src/s2wasm.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h index d0dbe8c6a..2da99281c 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -480,24 +480,28 @@ class S2WasmBuilder { void parseToplevelSection() { auto section = getCommaSeparated(); // Initializers are anything in a section whose name begins with .init_array - if (!strncmp(section.c_str(), ".init_array", strlen(".init_array") - 1)) parseInitializer(); + if (!strncmp(section.c_str(), ".init_array", strlen(".init_array") - 1)) { + parseInitializer(); + return; + } s = strchr(s, '\n'); } void parseInitializer() { // Ignore the rest of the .section line s = strchr(s, '\n'); - while (*s) { + skipWhitespace(); + // The section may start with .p2align + if (match(".p2align")) { + s = strchr(s, '\n'); skipWhitespace(); - if (match(".p2align")) s = strchr(s, '\n'); - else if (match(".int32")) { - initializerFunctions.emplace_back(cleanFunction(getStr())); - assert(implementedFunctions.count(initializerFunctions.back())); - break; - } else { - abort_on("parseInitializer"); - } } + mustMatch(".int32"); + do { + initializerFunctions.emplace_back(cleanFunction(getStr())); + assert(implementedFunctions.count(initializerFunctions.back())); + skipWhitespace(); + } while (match(".int32")); } void parseText() { |