From 5fb669ac8cca51baff8b3a6478d6fd3ef92a7c97 Mon Sep 17 00:00:00 2001 From: Max Klein Date: Wed, 12 Apr 2017 22:15:31 +0200 Subject: s2wasm: Add command line option for importing memory (#963) This option allows to import the linear memory from JS code instead of exporting it. --emscripten-glue does this too but often the emscripten glue isn't needed, so this option only affects the memory. All the code necessary for importing the memory basically already exists, so nothing except for the command line option itself had to be added. --- src/tools/s2wasm.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/tools/s2wasm.cpp') diff --git a/src/tools/s2wasm.cpp b/src/tools/s2wasm.cpp index ef5d276d3..890d74bb4 100644 --- a/src/tools/s2wasm.cpp +++ b/src/tools/s2wasm.cpp @@ -34,6 +34,7 @@ int main(int argc, const char *argv[]) { bool ignoreUnknownSymbols = false; bool generateEmscriptenGlue = false; bool allowMemoryGrowth = false; + bool importMemory = false; std::string startFunction; std::vector archiveLibraries; Options options("s2wasm", "Link .s file into .wast"); @@ -85,6 +86,11 @@ int main(int argc, const char *argv[]) { [&generateEmscriptenGlue](Options *, const std::string &) { generateEmscriptenGlue = true; }) + .add("--import-memory", "", "Import the linear memory instead of exporting it", + Options::Arguments::Zero, + [&importMemory](Options *, const std::string &) { + importMemory = true; + }) .add("--library", "-l", "Add archive library", Options::Arguments::N, [&archiveLibraries](Options *o, const std::string &argument) { @@ -132,7 +138,7 @@ int main(int argc, const char *argv[]) { if (options.debug) std::cerr << "Global base " << globalBase << '\n'; Linker linker(globalBase, stackAllocation, initialMem, maxMem, - generateEmscriptenGlue, ignoreUnknownSymbols, startFunction, + importMemory || generateEmscriptenGlue, ignoreUnknownSymbols, startFunction, options.debug); S2WasmBuilder mainbuilder(input.c_str(), options.debug); -- cgit v1.2.3