[PATCH] D62577: [ELF] Support Local Dynamic style TLSDESC for x86-64
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 05:58:33 PDT 2019
MaskRay marked an inline comment as done.
MaskRay added inline comments.
Comment at: ELF/InputSection.cpp:599
+ // On targets that support TLSDESC, _TLS_MODULE_BASE_ at tpoff = 0.
+ if (S.getName() == "_TLS_MODULE_BASE_")
+ return 0;
> grimar wrote:
> > grimar wrote:
> > > ruiu wrote:
> > > > This line can be expensive if we have a lot of thread-local local symbols. getName() computes symbol names lazily, so if you call it on a local symbol, the function can be expensive. Maybe you should store TLSModuleBase symbol somewhere and compare S with the pointer?
> > > I thought about that too, but supposed that TLS symbols are not that common. Am I wrong?
> > Also we can probably avoid this check if create the symbol with value of `alignTo(Out::TlsPhdr->p_memsz, Out::TlsPhdr->p_align)` it seems.
> > I.e. I am thinking about using original `getTlsTpOffset()` helper and creating a symbol with the value of `-getTlsTpOffset()`.
> > Will this work?
> Maybe it's not a big deal in practice. But identifying a symbol by name always rings a bell, so it'd probably easier to identify by a pointer comparison than explaining why this is not a big deal.
As a R_X86_64_TLSDESC dynamic relocation, the formula is: Sym->getVA(Addend) (in DynamicReloc::computeAddend())
As @tpoff, the formula is: Sym->getVA(A) + getTlsTpOffset()
Both must equal to 0. So there is a conflict. At least one place has to be a special case.
I feel the most straightforward approach is to special case the @tpoff computation here.
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
More information about the llvm-commits