diff options
author | Sam Clegg <sbc@chromium.org> | 2018-01-18 23:57:55 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2018-01-18 23:57:55 +0000 |
commit | 14ae6e7c5cae6d054f23e8150c7f4537b2d1930e (patch) | |
tree | db3c1bc7c732edb14081dea2af9033d522080f79 | |
parent | 84b26b90d14abc404ff8a4305fbf9ab119f19232 (diff) | |
download | bcm5719-llvm-14ae6e7c5cae6d054f23e8150c7f4537b2d1930e.tar.gz bcm5719-llvm-14ae6e7c5cae6d054f23e8150c7f4537b2d1930e.zip |
[WebAssembly] Export the stack pointer when using --emit-relocs
This solves the problem that --emit-relocs needs the stack-pointer
to be exported, in order to write out any relocations that reference
the __stack_pointer symbol by its symbol index.
Patch by Nicholas Wilson!
Differential Revision: https://reviews.llvm.org/D42237
llvm-svn: 322911
-rw-r--r-- | lld/test/wasm/stack-pointer.ll | 3 | ||||
-rw-r--r-- | lld/wasm/Writer.cpp | 9 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lld/test/wasm/stack-pointer.ll b/lld/test/wasm/stack-pointer.ll index d37b96eb938..2eefb2c021b 100644 --- a/lld/test/wasm/stack-pointer.ll +++ b/lld/test/wasm/stack-pointer.ll @@ -58,6 +58,9 @@ entry: ; CHECK-NEXT: - Name: __wasm_call_ctors ; CHECK-NEXT: Kind: FUNCTION ; CHECK-NEXT: Index: 1 +; CHECK-NEXT: - Name: __stack_pointer +; CHECK-NEXT: Kind: GLOBAL +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: - Name: __heap_base ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 1 diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp index 4cefe3a473e..05bb4c78786 100644 --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -659,9 +659,12 @@ void Writer::calculateExports() { } for (const Symbol *Sym : DefinedGlobals) { - // Can't export the SP right now because it's mutable and mutable globals - // cannot be exported. - if (Sym == Config->StackPointerSymbol) + // Can't export the SP right now because its mutable, and mutuable globals + // are yet supported in the official binary format. However, for + // intermediate output we need to export it in case it is the target of any + // relocations. + // TODO(sbc): Remove this if/when the "mutable global" proposal is accepted. + if (Sym == Config->StackPointerSymbol && !Config->EmitRelocs) continue; ExportedSymbols.emplace_back(WasmExportEntry{Sym, BudgeLocalName(Sym)}); } |