[lld][WebAssembly] Fix for string merging + negative addends
authorSam Clegg <sbc@chromium.org>
Tue, 11 May 2021 15:58:13 +0000 (08:58 -0700)
committerSam Clegg <sbc@chromium.org>
Wed, 12 May 2021 00:47:57 +0000 (17:47 -0700)
commit19cedd3cd3ab2144f7e477bb90d5f7ba8e500abb
treed13ac652591a42d024d4de7125eb20b1113db07c
parentbb726383ac7554857c62edd2d19e83dc713165ee
[lld][WebAssembly] Fix for string merging + negative addends

Don't include the relocation addend when calculating the
virtual address of a symbol.  Instead just pass the symbol's
offset and add the addend afterwards.

Without this fix we hit the `offset is outside the section`
error in MergeInputSegment::getSegmentPiece.

This fixes a real world error we were are seeing in emscripten.

Differential Revision: https://reviews.llvm.org/D102271
lld/test/wasm/merge-string.s
lld/wasm/InputFiles.cpp
lld/wasm/Symbols.cpp
lld/wasm/Symbols.h