From d63486d0ef085f905dafdb14a76cfb2ca1fb452e Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Wed, 27 Apr 2016 09:18:37 -0700 Subject: Split construction, scanning, and building phases of S2WasmBuilder (#400) Instead of doing all of the S2Wasm work in the constructor, split construction, scanning (to determine implemented functions) and building of the wasm module. This allows the linker to get the symbol information (e.g. implemented functions) without having to build an entire module (which will be useful for archives) and to allow the linker to link a new object into the existing one by building the wasm module in place on the existing module. --- src/s2wasm-main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/s2wasm-main.cpp') diff --git a/src/s2wasm-main.cpp b/src/s2wasm-main.cpp index 435eb560f..7b0e4c179 100644 --- a/src/s2wasm-main.cpp +++ b/src/s2wasm-main.cpp @@ -104,7 +104,13 @@ int main(int argc, const char *argv[]) { Linker linker(globalBase, stackAllocation, initialMem, maxMem, ignoreUnknownSymbols, startFunction, options.debug); - S2WasmBuilder s2wasm(linker.getOutput(), input.c_str(), options.debug); + S2WasmBuilder mainbuilder(input.c_str(), options.debug); + linker.linkObject(mainbuilder); + + // In the future, there will be code to open additional files/buffers and + // link additional objects, as well as archive members (which only get linked if needed), e.g.: + // S2WasmBuilder lazyObject(some_other_buffer, options.debug) + // linker.linkLazyObject(lazyObject); // calls builder.scan to get symbol info, then build linker.layout(); -- cgit v1.2.3