[JITLink] Add initial native TLS support to ELFNix platform
authorluxufan <932494295@qq.com>
Sat, 11 Sep 2021 03:11:48 +0000 (11:11 +0800)
committerluxufan <932494295@qq.com>
Mon, 13 Sep 2021 06:35:49 +0000 (14:35 +0800)
commitff6069b89114325b1904e55d3987701567d522d4
tree2df2cc4458133b2fff1eb7641edaac4f7a2a852e
parent802bf02a738e091d5bf22c03e83204a38d2c7950
[JITLink] Add initial native TLS support to ELFNix platform

This patch use the same way as the https://reviews.llvm.org/rGfe1fa43f16beac1506a2e73a9f7b3c81179744eb to handle the thread local variable.

It allocates 2 * pointerSize space in GOT to represent the thread key and data address. Instead of using the _tls_get_addr function, I customed a function __orc_rt_elfnix_tls_get_addr to get the address of thread local varible. Currently, this is a wip patch, only one TLS relocation R_X86_64_TLSGD is supported and I need to add the corresponding test cases.

To allocate the TLS  descriptor in GOT, I need to get the edge kind information in PerGraphGOTAndPLTStubBuilder, So I add a `Edge::Kind K` argument in some functions in PerGraphGOTAndPLTStubBuilder.h. If it is not suitable, I can think further to solve this problem.

Differential Revision: https://reviews.llvm.org/D109293
12 files changed:
compiler-rt/lib/orc/CMakeLists.txt
compiler-rt/lib/orc/elfnix_platform.cpp
compiler-rt/lib/orc/elfnix_tls.x86-64.S [new file with mode: 0644]
compiler-rt/test/orc/TestCases/FreeBSD/x86-64/trivial-tls.S [new file with mode: 0644]
compiler-rt/test/orc/TestCases/Linux/x86-64/trivial-tls.S [new file with mode: 0644]
llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h
llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h
llvm/include/llvm/ExecutionEngine/Orc/ELFNixPlatform.h
llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
llvm/lib/ExecutionEngine/JITLink/PerGraphTLSInfoEntryBuilder.h [new file with mode: 0644]
llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp