diff options
Diffstat (limited to 'src/tools/wasm-opt.cpp')
-rw-r--r-- | src/tools/wasm-opt.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index c4443bde4..6fd3b7c8d 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -37,6 +37,7 @@ #include "wasm-printing.h" #include "wasm-s-parser.h" #include "wasm-validator.h" +#include "wasm2c-wrapper.h" #define DEBUG_TYPE "opt" @@ -87,6 +88,7 @@ int main(int argc, const char* argv[]) { bool fuzzOOB = true; std::string emitJSWrapper; std::string emitSpecWrapper; + std::string emitWasm2CWrapper; std::string inputSourceMapFilename; std::string outputSourceMapFilename; std::string outputSourceMapUrl; @@ -185,6 +187,14 @@ int main(int argc, const char* argv[]) { [&](Options* o, const std::string& arguments) { emitSpecWrapper = arguments; }) + .add("--emit-wasm2c-wrapper", + "-esw", + "Emit a C wrapper file that can run the wasm after it is compiled " + "with wasm2c, useful for fuzzing", + Options::Arguments::One, + [&](Options* o, const std::string& arguments) { + emitWasm2CWrapper = arguments; + }) .add("--input-source-map", "-ism", "Consume source map from the specified file", @@ -293,13 +303,18 @@ int main(int argc, const char* argv[]) { outfile << generateJSWrapper(wasm); outfile.close(); } - if (emitSpecWrapper.size() > 0) { std::ofstream outfile; outfile.open(emitSpecWrapper, std::ofstream::out); outfile << generateSpecWrapper(wasm); outfile.close(); } + if (emitWasm2CWrapper.size() > 0) { + std::ofstream outfile; + outfile.open(emitWasm2CWrapper, std::ofstream::out); + outfile << generateWasm2CWrapper(wasm); + outfile.close(); + } std::string firstOutput; |