summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2019-10-28 15:24:52 -0700
committerSam Clegg <sbc@chromium.org>2019-10-29 18:58:56 -0700
commitbaff8ec2e1d845d90580a0d85ad6ab43d929bcfe (patch)
treea1116c1637965e9f515b65a01a58755f7c24ed64
parent4d06ea83cc156ae8410316e56237eab5144b5fa5 (diff)
downloadbcm5719-llvm-baff8ec2e1d845d90580a0d85ad6ab43d929bcfe.tar.gz
bcm5719-llvm-baff8ec2e1d845d90580a0d85ad6ab43d929bcfe.zip
[WebAssembly][lld] Fix for static linking of PIC code
When statically linking PIC code we create an internalized __memory_base so that memory-base-relative relocation work correctly. The value of this global should be zero, and not the globalBase since the globalBase offset is already taken into account by getVirtualAddress. Fixes: https://github.com/emscripten-core/emscripten/issues/9013 Differential Revision: https://reviews.llvm.org/D69600
-rw-r--r--lld/test/wasm/pic-static.ll2
-rw-r--r--lld/wasm/Writer.cpp2
2 files changed, 1 insertions, 3 deletions
diff --git a/lld/test/wasm/pic-static.ll b/lld/test/wasm/pic-static.ll
index 83752f3bdb3..65b47175865 100644
--- a/lld/test/wasm/pic-static.ll
+++ b/lld/test/wasm/pic-static.ll
@@ -118,4 +118,4 @@ entry:
; CHECK-NEXT: Mutable: false
; CHECK-NEXT: InitExpr:
; CHECK-NEXT: Opcode: I32_CONST
-; CHECK-NEXT: Value: 1024
+; CHECK-NEXT: Value: 0
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index fe596257bea..5df3ae68e30 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -226,8 +226,6 @@ void Writer::layoutMemory() {
if (WasmSym::globalBase)
WasmSym::globalBase->setVirtualAddress(memoryPtr);
- if (WasmSym::definedMemoryBase)
- WasmSym::definedMemoryBase->setVirtualAddress(memoryPtr);
uint32_t dataStart = memoryPtr;
OpenPOWER on IntegriCloud