[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
This commit is contained in:
Sam Clegg 2019-10-28 15:24:52 -07:00
parent 4d06ea83cc
commit baff8ec2e1
2 changed files with 1 additions and 3 deletions

View File

@ -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

View File

@ -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;