[PATCH] D128601: [ORC][ORC_RT][AArch64] Implement TLS descriptor in ELFNixPlatform.

Sunho Kim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 26 00:33:09 PDT 2022


sunho created this revision.
sunho added reviewers: lhames, sgraenitz, housel.
Herald added subscribers: Enna1, StephenFan, hiraditya, kristof.beyls, mgorny.
Herald added a project: All.
sunho requested review of this revision.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.

Implements TLS descriptor relocations in JITLink ELF/AARCH64 backend and support the relevant runtime functions in ELFNixPlatform.

Unlike traditional TLS model, TLS descriptor model requires linker to return the "offset" from thread pointer via relocaiton not the actual pointer to thread local variable. There is no public libc api for adding new allocations to TLS block which thread pointer points to. So, we can't support this model with straightforward approach. Codegen emits "mrs <dest>" instruction to set dest regisster to frame pointer. When accessing TLVs in aarch64 linux with PIC flag, llvm codegen always emit this instruction pattern with relevant TLS relocation entries. In this patch, it simply swaps mrs instruction with "mov xzr" which zeroes the dest register. This way tp + offset become just offset, we can return the actual address of thread local variable as offset.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128601

Files:
  compiler-rt/lib/orc/CMakeLists.txt
  compiler-rt/lib/orc/elfnix_platform.cpp
  compiler-rt/lib/orc/elfnix_tls.aarch64.S
  compiler-rt/test/orc/TestCases/Linux/aarch64/trivial-tls.S
  llvm/include/llvm/ExecutionEngine/JITLink/aarch64.h
  llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
  llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
  llvm/lib/ExecutionEngine/JITLink/aarch64.cpp
  llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
  llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_tp_nullifier.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128601.440039.patch
Type: text/x-patch
Size: 21552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220626/f04a3333/attachment.bin>


More information about the llvm-commits mailing list