diff options
author | jgravelle-google <jgravelle@google.com> | 2016-11-30 15:34:39 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-30 15:34:39 -0800 |
commit | 4caea4872aed6d1cb7ef42c9a2364870eb574e41 (patch) | |
tree | fdaf20b77bd46d1da14d57a7401525ddf9f6850e /src/wasm-linker.cpp | |
parent | 36be3e0151dd7357e47b2d8f432bdd706a30466c (diff) | |
download | binaryen-4caea4872aed6d1cb7ef42c9a2364870eb574e41.tar.gz binaryen-4caea4872aed6d1cb7ef42c9a2364870eb574e41.tar.bz2 binaryen-4caea4872aed6d1cb7ef42c9a2364870eb574e41.zip |
Handle importing globals in s2wasm (#843)
* Handle importing globals in s2wasm
* Make importedGlobals a set of Names, make Names hashable
* Revert "Make importedGlobals a set of Names, make Names hashable"
This reverts commit 1d0ca7a5e3839b15ca60593330979864c9c3ed60.
* Refactor relocation parsing to handle expressions directly
* PR Feedback
- Move comment where it belongs
- Add comment about ownership to addRelocation
- Remove do-nothing parseImportGlobal
* Reword "imported globals" to "imported objects"
- Flip isObjectImported to isObjectImplemented, for consistency
* Add tests for s2wasm globals.
Also implement import relocation expression handling
* Simplify globals.s test
* Fix memory leak of relocation
* Use unique_ptr instead of delete in getRelocatableExpression
Diffstat (limited to 'src/wasm-linker.cpp')
-rw-r--r-- | src/wasm-linker.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp index 56ec03851..76bf8942d 100644 --- a/src/wasm-linker.cpp +++ b/src/wasm-linker.cpp @@ -40,7 +40,9 @@ void Linker::placeStackPointer(Address stackAllocation) { // stack pointer to point to one past-the-end of the stack allocation. std::vector<char> raw; raw.resize(pointerSize); - out.addRelocation(LinkerObject::Relocation::kData, (uint32_t*)&raw[0], ".stack", stackAllocation); + auto relocation = new LinkerObject::Relocation( + LinkerObject::Relocation::kData, (uint32_t*)&raw[0], ".stack", stackAllocation); + out.addRelocation(relocation); assert(out.wasm.memory.segments.empty()); out.addSegment("__stack_pointer", raw); } @@ -327,6 +329,8 @@ void Linker::emscriptenGlue(std::ostream& o) { exportFunction(f->name, true); } + emscripten::addObjectImports(out.wasm, out.symbolInfo.importedObjects); + auto staticBump = nextStatic - globalBase; emscripten::generateEmscriptenMetadata(o, out.wasm, segmentsByAddress, staticBump, out.initializerFunctions); } |