diff options
author | Heejin Ahn <aheejin@users.noreply.github.com> | 2016-08-26 08:56:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-26 08:56:42 -0700 |
commit | 2cb8b275caf090bf56cc78424aaa97766cd02fb6 (patch) | |
tree | c01c751c22a76a670e76a30cf0af0cd8e0901902 /src | |
parent | e168e2b9b6dd099c97c7ec313c3062d80fa1a9a8 (diff) | |
download | binaryen-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')
-rw-r--r-- | src/s2wasm.h | 5 |
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() { |