From 5e92a4f1864c49867906624f1b16b14c57ee357a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 16 Oct 2020 01:42:56 -0500 Subject: finalize: add --mutable-sp flag (#3250) This flag disables the features of `wasm-emscripten-finalize` the replace the mutable global import of `__stack_pointer`. See the corresponding emscripten change that depends on this one: https://github.com/emscripten-core/emscripten/pull/12536 --- src/tools/wasm-emscripten-finalize.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp index a2322a8f3..172ce08ce 100644 --- a/src/tools/wasm-emscripten-finalize.cpp +++ b/src/tools/wasm-emscripten-finalize.cpp @@ -52,6 +52,7 @@ int main(int argc, const char* argv[]) { bool DWARF = false; bool sideModule = false; bool legacyPIC = true; + bool mutableSP = false; bool legalizeJavaScriptFFI = true; bool bigInt = false; bool checkStackOverflow = false; @@ -110,6 +111,13 @@ int main(int argc, const char* argv[]) { [&sideModule](Options* o, const std::string& argument) { sideModule = true; }) + .add("--mutable-sp", + "", + "Allow the import of __stack_pointer as a mutable global", + Options::Arguments::Zero, + [&mutableSP](Options* o, const std::string& argument) { + mutableSP = true; + }) .add("--new-pic-abi", "", "Use new/llvm PIC abi", @@ -278,7 +286,7 @@ int main(int argc, const char* argv[]) { passRunner.setDebug(options.debug); passRunner.setDebugInfo(debugInfo); - if (checkStackOverflow && !sideModule) { + if (checkStackOverflow) { if (!standaloneWasm) { // In standalone mode we don't set a handler at all.. which means // just trap on overflow. @@ -288,7 +296,7 @@ int main(int argc, const char* argv[]) { passRunner.add("stack-check"); } - if (sideModule) { + if (sideModule && !mutableSP) { passRunner.add("replace-stack-pointer"); } @@ -333,7 +341,9 @@ int main(int argc, const char* argv[]) { } else { BYN_TRACE("finalizing as regular module\n"); if (legacyPIC) { - generator.internalizeStackPointerGlobal(); + if (!mutableSP) { + generator.internalizeStackPointerGlobal(); + } // For side modules these gets called via __post_instantiate if (Function* F = wasm.getFunctionOrNull(ASSIGN_GOT_ENTRIES)) { auto* ex = new Export(); -- cgit v1.2.3