diff options
author | Derek Schuff <dschuff@chromium.org> | 2016-04-25 13:16:18 -0700 |
---|---|---|
committer | Derek Schuff <dschuff@chromium.org> | 2016-04-25 13:16:18 -0700 |
commit | 27ef6de772ca90824018819b91b8a230136f56c3 (patch) | |
tree | 265bcdc03489f1f6f844422cc03f6a0528cafa93 /src/s2wasm-main.cpp | |
parent | 0d17b75113d4f50d4b05ef3b243dcad962483def (diff) | |
download | binaryen-27ef6de772ca90824018819b91b8a230136f56c3.tar.gz binaryen-27ef6de772ca90824018819b91b8a230136f56c3.tar.bz2 binaryen-27ef6de772ca90824018819b91b8a230136f56c3.zip |
Separate LinkerObject from Linker (#383)
Create the LinkerObject class, which has a wasm Module and represents the module plus the information needed to relocate and lay it out. Each Linker owns a "main executable" LinkerObject, and S2WasmBuilder requires a LinkerObject instead of just a Module because LLVM asm files require relocation/linking before they represent a full wasm module.
No merging support yet, but the real functionality for #370 is coming soon.
Diffstat (limited to 'src/s2wasm-main.cpp')
-rw-r--r-- | src/s2wasm-main.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/s2wasm-main.cpp b/src/s2wasm-main.cpp index c6a77c583..435eb560f 100644 --- a/src/s2wasm-main.cpp +++ b/src/s2wasm-main.cpp @@ -84,7 +84,6 @@ int main(int argc, const char *argv[]) { auto input(read_file<std::string>(options.extra["infile"], Flags::Text, options.debug ? Flags::Debug : Flags::Release)); if (options.debug) std::cerr << "Parsing and wasming..." << std::endl; - Module wasm; uint64_t globalBase = options.extra.find("global-base") != options.extra.end() ? std::stoull(options.extra["global-base"]) : 0; @@ -101,21 +100,24 @@ int main(int argc, const char *argv[]) { ? std::stoull(options.extra["max-memory"]) : 0; if (options.debug) std::cerr << "Global base " << globalBase << '\n'; - Linker lm(wasm, globalBase, stackAllocation, initialMem, maxMem, - ignoreUnknownSymbols, startFunction, options.debug); - S2WasmBuilder s2wasm(wasm, input.c_str(), options.debug, lm); + Linker linker(globalBase, stackAllocation, initialMem, maxMem, + ignoreUnknownSymbols, startFunction, options.debug); + + S2WasmBuilder s2wasm(linker.getOutput(), input.c_str(), options.debug); + + linker.layout(); std::stringstream meta; if (generateEmscriptenGlue) { if (options.debug) std::cerr << "Emscripten gluing..." << std::endl; // dyncall thunks - lm.emscriptenGlue(meta); + linker.emscriptenGlue(meta); } if (options.debug) std::cerr << "Printing..." << std::endl; Output output(options.extra["output"], Flags::Text, options.debug ? Flags::Debug : Flags::Release); - WasmPrinter::printModule(&wasm, output.getStream()); + WasmPrinter::printModule(&linker.getOutput().wasm, output.getStream()); output << meta.str() << std::endl; if (options.debug) std::cerr << "Done." << std::endl; |