[WebAssembly][lld] Fix for static linking of PIC code
authorSam Clegg <sbc@chromium.org>
Mon, 28 Oct 2019 22:24:52 +0000 (15:24 -0700)
committerSam Clegg <sbc@chromium.org>
Wed, 30 Oct 2019 01:58:56 +0000 (18:58 -0700)
commitbaff8ec2e1d845d90580a0d85ad6ab43d929bcfe
treea1116c1637965e9f515b65a01a58755f7c24ed64
parent4d06ea83cc156ae8410316e56237eab5144b5fa5
[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
lld/test/wasm/pic-static.ll
lld/wasm/Writer.cpp