diff options
Diffstat (limited to 'src/wasm-linker.cpp')
-rw-r--r-- | src/wasm-linker.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp index 45615fd59..d8bae7558 100644 --- a/src/wasm-linker.cpp +++ b/src/wasm-linker.cpp @@ -210,6 +210,19 @@ void Linker::layout() { auto* func = out.wasm.getFunction(name); func->type = ensureFunctionType(getSig(func), &out.wasm)->name; } + + // Export malloc and free whenever availble. JavsScript version of malloc has + // some issues and it cannot be called once _sbrk() is called. + // TODO This should get the list of exported functions from emcc.py - it has + // EXPORTED_FUNCTION metadata to keep track of this. Get the list of exported + // functions using a command-line argument from emcc.py and export all of + // them. + if (out.symbolInfo.implementedFunctions.count("malloc")) { + exportFunction("malloc", true); + } + if (out.symbolInfo.implementedFunctions.count("free")) { + exportFunction("free", true); + } } bool Linker::linkObject(S2WasmBuilder& builder) { |