[lld][WebAssembly] Allow references to __tls_base without shared memory
authorSam Clegg <sbc@chromium.org>
Tue, 10 Nov 2020 01:52:39 +0000 (17:52 -0800)
committerSam Clegg <sbc@chromium.org>
Wed, 11 Nov 2020 01:58:06 +0000 (17:58 -0800)
commit29a3056bb5346d9b38e4dcb13700576efbff9425
tree14acd6e42cbfeed08a735c6de6f81c0fe11031e2
parente1eeb026e66c38add2a1f8f1271e1f618c2f7a72
[lld][WebAssembly] Allow references to __tls_base without shared memory

Previously we limited the use of atomics and TLS to programs
linked with `--shared-memory`.

However, as of https://reviews.llvm.org/D79530 we now allow
programs that use atomic to be linked without `--shared-memory`.
For this to be useful we also want to all TLS usage in such
programs.  In this case, since we know we are single threaded
we simply include the TLS data as a regular active segment
and create an immutable `__tls_base` global that point to the
start of this segment.

Fixes: https://github.com/emscripten-core/emscripten/issues/12489

Differential Revision: https://reviews.llvm.org/D91115
lld/test/wasm/no-tls.s
lld/test/wasm/tls-no-shared.s [new file with mode: 0644]
lld/wasm/Driver.cpp
lld/wasm/SymbolTable.cpp
lld/wasm/SymbolTable.h
lld/wasm/Writer.cpp