diff options
| author | Sam Clegg <sbc@chromium.org> | 2018-11-15 18:15:54 +0000 |
|---|---|---|
| committer | Sam Clegg <sbc@chromium.org> | 2018-11-15 18:15:54 +0000 |
| commit | 2dad4e2c6d494e997de41f5cc391e6bc6a171e35 (patch) | |
| tree | f9a91f02bb593a4912a9f79c95a428ef46d33bd7 /lld/wasm/Writer.cpp | |
| parent | aa3f2494b353aa4eac7d6dae8afcbc5c34d59656 (diff) | |
| download | bcm5719-llvm-2dad4e2c6d494e997de41f5cc391e6bc6a171e35.tar.gz bcm5719-llvm-2dad4e2c6d494e997de41f5cc391e6bc6a171e35.zip | |
[WebAssembly] Import the stack pointer when building shared libraries
Differential Revision: https://reviews.llvm.org/D54558
llvm-svn: 346974
Diffstat (limited to 'lld/wasm/Writer.cpp')
| -rw-r--r-- | lld/wasm/Writer.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp index 60485081249..b5abb6b141b 100644 --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -332,8 +332,7 @@ void Writer::createElemSection() { WasmInitExpr InitExpr; if (Config->Pic) { InitExpr.Opcode = WASM_OPCODE_GET_GLOBAL; - InitExpr.Value.Global = - cast<GlobalSymbol>(WasmSym::TableBase)->getGlobalIndex(); + InitExpr.Value.Global = WasmSym::TableBase->getGlobalIndex(); } else { InitExpr.Opcode = WASM_OPCODE_I32_CONST; InitExpr.Value.Int32 = TableBase; @@ -632,7 +631,8 @@ void Writer::layoutMemory() { log("mem: stack size = " + Twine(Config->ZStackSize)); log("mem: stack base = " + Twine(MemoryPtr)); MemoryPtr += Config->ZStackSize; - WasmSym::StackPointer->Global->Global.InitExpr.Value.Int32 = MemoryPtr; + auto *SP = cast<DefinedGlobal>(WasmSym::StackPointer); + SP->Global->Global.InitExpr.Value.Int32 = MemoryPtr; log("mem: stack top = " + Twine(MemoryPtr)); }; @@ -666,6 +666,11 @@ void Writer::layoutMemory() { log("mem: static data = " + Twine(MemoryPtr - DataStart)); + if (Config->Shared) { + MemSize = MemoryPtr; + return; + } + if (!Config->StackFirst) PlaceStack(); |

