[WebAssembly] Add new relocation type for TLS data symbols
authorSam Clegg <sbc@chromium.org>
Wed, 11 Nov 2020 01:46:52 +0000 (17:46 -0800)
committerSam Clegg <sbc@chromium.org>
Fri, 13 Nov 2020 15:59:29 +0000 (07:59 -0800)
commita28a466210199559d38251c11f30515cc83eadd6
treef3b16673063e5964614ba875fa5f47d18fb23575
parent0fd6a04ba4dbf039fbd11eca29886d9d06bc736a
[WebAssembly] Add new relocation type for TLS data symbols

These relocations represent offsets from the __tls_base symbol.

Previously we were just using normal MEMORY_ADDR relocations and relying
on the linker to select a segment-offset rather and absolute value in
Symbol::getVirtualAddress().  Using an explicit relocation type allows
allow us to clearly distinguish absolute from relative relocations based
on the relocation information alone.

One place this is useful is being able to reject absolute relocation in
the PIC case, but still accept TLS relocations.

Differential Revision: https://reviews.llvm.org/D91276
23 files changed:
lld/test/wasm/relocation-bad-tls.s [new file with mode: 0644]
lld/test/wasm/tls.s
lld/wasm/InputChunks.cpp
lld/wasm/InputFiles.cpp
lld/wasm/OutputSections.cpp
lld/wasm/Relocations.cpp
lld/wasm/Symbols.cpp
lld/wasm/Writer.cpp
llvm/include/llvm/BinaryFormat/WasmRelocs.def
llvm/include/llvm/MC/MCExpr.h
llvm/lib/BinaryFormat/Wasm.cpp
llvm/lib/MC/MCExpr.cpp
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Object/WasmObjectFile.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll
llvm/test/CodeGen/WebAssembly/tls-local-exec.ll
llvm/test/MC/WebAssembly/tls.s [new file with mode: 0644]