[lld][WebAssembly] Split __wasm_apply_relocs function in two
authorSam Clegg <sbc@chromium.org>
Thu, 10 Dec 2020 02:14:31 +0000 (18:14 -0800)
committerSam Clegg <sbc@chromium.org>
Fri, 11 Dec 2020 01:07:39 +0000 (17:07 -0800)
commite52881a2870234f0dad6e338a0f084eddeaa9356
tree745933b647a11e062765a409914938623b65ffe9
parenta3fe12dc58aa2a0dd7292d748b7c104225f863ba
[lld][WebAssembly] Split __wasm_apply_relocs function in two

We have two types of relocations that we apply on startup:
1. Relocations that apply to wasm globals
2. Relocations that apply to wasm memory

The first set of relocations use only the `__memory_base` import to
update a set of internal globals.  Because wasm globals are thread local
these need to run on each thread.  Memory relocations, like static
constructors, must only be run once.

To ensure global relocations run on all threads and because the only
depend on the immutable `__memory_base` import we can run them during
the WebAssembly start functions, instead of waiting until the
post-instantiation __wasm_call_ctors.

Differential Revision: https://reviews.llvm.org/D93066
lld/test/wasm/bsymbolic.s
lld/test/wasm/data-segments.ll
lld/test/wasm/pie.ll
lld/test/wasm/weak-undefined-pic.s
lld/wasm/Driver.cpp
lld/wasm/MarkLive.cpp
lld/wasm/Symbols.cpp
lld/wasm/Symbols.h
lld/wasm/SyntheticSections.cpp
lld/wasm/SyntheticSections.h
lld/wasm/Writer.cpp