summaryrefslogtreecommitdiff
path: root/src/s2wasm.h
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@users.noreply.github.com>2016-08-26 08:56:42 -0700
committerGitHub <noreply@github.com>2016-08-26 08:56:42 -0700
commit2cb8b275caf090bf56cc78424aaa97766cd02fb6 (patch)
treec01c751c22a76a670e76a30cf0af0cd8e0901902 /src/s2wasm.h
parente168e2b9b6dd099c97c7ec313c3062d80fa1a9a8 (diff)
downloadbinaryen-2cb8b275caf090bf56cc78424aaa97766cd02fb6.tar.gz
binaryen-2cb8b275caf090bf56cc78424aaa97766cd02fb6.tar.bz2
binaryen-2cb8b275caf090bf56cc78424aaa97766cd02fb6.zip
Fix alignment bug in .lcomm (#680)
When parsing .lcomm directives, s2wasm does not parse the alignment number and skip it. This causes alignment bugs in some cases. (In the test case attached, 'buf' should be 4 bytes aligned, but it does not align it properly, so this code was generated: ``` (call $foo (i32.const 13) ) ``` 13 is not 4-bytes aligned. This patch fixes this bug.
Diffstat (limited to 'src/s2wasm.h')
-rw-r--r--src/s2wasm.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h
index 3a7cf31db..a45f3aab4 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -1328,11 +1328,12 @@ class S2WasmBuilder {
mustMatch(name.str);
skipComma();
Address size = getInt();
+ Address localAlign = 1;
if (*s == ',') {
skipComma();
- getInt();
+ localAlign = 1 << getInt();
}
- linkerObj->addStatic(size, align, name);
+ linkerObj->addStatic(size, std::max(align, localAlign), name);
}
void skipImports() {