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

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 30 15:25:44 PST 2015


ruiu 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.
----------------
grimar wrote:
> 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))
>         continue;
>       if (Body->isInGot())
>         continue;
> ```
> 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.
Understood, but can you do that in a different way? I think the new variable is rather confusing, since symbols added to GOT using addDynTlsEntry are in GOT, but isInGot returns false for them (although they are in GOT).


http://reviews.llvm.org/D15060





More information about the llvm-commits mailing list