[PATCH] D15060: [ELF] - Implemented some GD, LD and IE TLS access models for x86 target.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 30 11:04:02 PST 2015

grimar added inline comments.

Comment at: ELF/OutputSections.cpp:84
@@ -83,3 +83,3 @@
 template <class ELFT> void GotSection<ELFT>::addDynTlsEntry(SymbolBody *Sym) {
-  Sym->GotIndex = Target->getGotHeaderEntriesNum() + Entries.size();
+  Sym->GlobDynIndex = Target->getGotHeaderEntriesNum() + Entries.size();
   // Global Dynamic TLS entries take two GOT slots.
ruiu wrote:
> Why do we need a different member variable than GotIndex?
Thats needed for the next code sequence to work correctly:

leal tls0 at tlsgd(,%ebx,1),%eax
call __tls_get_addr at plt
movl %gs:0,%eax
addl tls0 at gotntpoff(%ebx),%eax

@tlsgd(x) - Allocates two contiguous entries in the GOT to hold a TLS_index structure.
@gotntpoff(x) - Allocates a entry in the GOT, and initializes it with the negative tlsoffset relative to the static TLS block. This is performed at runtime via the R_386_TLS_TPOFF relocation.

Problem is that next part of code terminates execution flow: 

void Writer<ELFT>::scanRelocs(
    if (Body && Body->isTLS() && Target->isTlsGlobalDynamicReloc(Type)) {
      if (Target->isTlsOptimized(Type, Body))
      if (Body->isInGot())
Make it continue and unable to move forward and create R_386_TLS_TPOFF relocation (and single entry) below at the end of that method.


More information about the llvm-commits mailing list