[lld][WebAssembly] Fix for TLS + --relocatable
authorSam Clegg <sbc@chromium.org>
Fri, 18 Dec 2020 18:02:29 +0000 (10:02 -0800)
committerSam Clegg <sbc@chromium.org>
Wed, 13 Jan 2021 15:49:39 +0000 (07:49 -0800)
commit07b6aeb5685fa6474cbeae797ebc5ea1f17da0f7
treeb718dc472b0b28d38d31d5e89c1b89141f5d5582
parent4e8e888905a4258932dcb593a5531a6329cc821a
[lld][WebAssembly] Fix for TLS + --relocatable

When running in `-r/--relocatable` we output relocations but the
new TLS relocations type was missing from `ObjFile::calcNewAddend`
causing this combination of inputs/flags to crash the linker.

Also avoid creating tls variables in relocatable mode.  These variables
are only needed when linking final executables.

Fixes: https://github.com/emscripten-core/emscripten/issues/12934
Fixes: PR48506

Differential Revision: https://reviews.llvm.org/D93554
lld/test/wasm/tls-no-shared.s
lld/test/wasm/tls.s
lld/wasm/Driver.cpp
lld/wasm/InputFiles.cpp
lld/wasm/Writer.cpp