[PATCH] [RuntimeDyld] Initial limited TLS support

Keno Fischer kfischer at college.harvard.edu
Thu Apr 2 19:10:16 PDT 2015


Hi lhames,

This patch adds limited support for thread-local-storage relocations to MCJIT. The approach is to add a separate "TLS symbol resolver" that is orthogonal to the usual symbol resolver, for resolving TLS symbols. The reason to use a separate resolver rather than making this part of the symbol resolver is twofold. First, a TLS lookup will in general require more information than a regular symbol lookup (e.g. a module/offset id, rather than an address) and second, it may be sensible to use different TLSSymbolResolvers for the same symbol resolver, e.g. depending on the host platform, or C library, etc., so it would be preferable for the user to specify independently of the Symbol Resolver.

This patch only deals with references to thread local variables declared outside the JIT, i.e. it does not add support for declaring variables thread local and setting up the correct data structures (doing so would also require significant collaboration from the OS dynamic linker, which is not present in current systems). Even so, the exact implementation still depends on deeply on the system details and the ABI. Hopefully the TLSSymbolResolver interface should allow the user to write their own implementation if their system ABI differs.

The majority of this patch is targeted at ELF, which has several special relocations for TLS support. MachO uses a different scheme that uses more GOT space (three words rather than two), but gets away without a special relocation for TLS symbols. No attempt at supporting COFF was made at this point, but hopefully the interface is sufficiently general that COFF support can be added easily in the future.

Also note that this depends on my GOT changes in D8813 and D8814.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8815

Files:
  include/llvm/ExecutionEngine/ExecutionEngine.h
  include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h
  include/llvm/ExecutionEngine/RTDyldMemoryManager.h
  include/llvm/ExecutionEngine/RuntimeDyld.h
  lib/ExecutionEngine/ExecutionEngine.cpp
  lib/ExecutionEngine/MCJIT/MCJIT.cpp
  lib/ExecutionEngine/MCJIT/MCJIT.h
  lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt
  lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
  lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.cpp
  lib/ExecutionEngine/RuntimeDyld/RuntimeDyldCOFF.h
  lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
  lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.h
  lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
  lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
  lib/ExecutionEngine/RuntimeDyld/TLSSymbolResolverELF.cpp
  lib/MC/MCObjectFileInfo.cpp
  tools/llvm-rtdyld/llvm-rtdyld.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8815.23199.patch
Type: text/x-patch
Size: 38231 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150403/fa87d8b3/attachment.bin>


More information about the llvm-commits mailing list