summaryrefslogtreecommitdiff
path: root/src/tools/wasm-opt.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-05-17 09:09:17 -0700
committerGitHub <noreply@github.com>2019-05-17 09:09:17 -0700
commit1095ef96673f4f33d76da6d58b0ad65c3c257f76 (patch)
treea8bf7d3a601aaa67c61f093560268b4a7e8745a1 /src/tools/wasm-opt.cpp
parent1dd37de69aae51edaf93219f31e736576f751191 (diff)
downloadbinaryen-1095ef96673f4f33d76da6d58b0ad65c3c257f76.tar.gz
binaryen-1095ef96673f4f33d76da6d58b0ad65c3c257f76.tar.bz2
binaryen-1095ef96673f4f33d76da6d58b0ad65c3c257f76.zip
Add a fuzzer option to not emit code with OOB loads/indirect calls (#2113)
This is useful for wasm2js, as we don't emit traps for OOB loads etc. like wasm (like we don't trap on bad float-to-int, as it's too hard in JS, and it's undefined behavior in C anyhow). It may also help general fuzzing, as those traps may make other interesting patterns less likely. Also add more wasm2js support in the fuzzer, which includes using this no-OOB option.
Diffstat (limited to 'src/tools/wasm-opt.cpp')
-rw-r--r--src/tools/wasm-opt.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp
index f7e8b5918..6d78a209b 100644
--- a/src/tools/wasm-opt.cpp
+++ b/src/tools/wasm-opt.cpp
@@ -73,6 +73,7 @@ int main(int argc, const char* argv[]) {
bool fuzzPasses = false;
bool fuzzNaNs = true;
bool fuzzMemory = true;
+ bool fuzzOOB = true;
std::string emitJSWrapper;
std::string emitSpecWrapper;
std::string inputSourceMapFilename;
@@ -157,6 +158,11 @@ int main(int argc, const char* argv[]) {
"don't emit memory ops when fuzzing",
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { fuzzMemory = false; })
+ .add("--no-fuzz-oob",
+ "",
+ "don't emit out-of-bounds loads/stores/indirect calls when fuzzing",
+ Options::Arguments::Zero,
+ [&](Options* o, const std::string& arguments) { fuzzOOB = false; })
.add("--emit-js-wrapper",
"-ejw",
"Emit a JavaScript wrapper file that can run the wasm with some test "
@@ -242,6 +248,7 @@ int main(int argc, const char* argv[]) {
}
reader.setAllowNaNs(fuzzNaNs);
reader.setAllowMemory(fuzzMemory);
+ reader.setAllowOOB(fuzzOOB);
reader.build();
if (options.passOptions.validate) {
if (!WasmValidator().validate(wasm)) {