[PATCH] D13986: [ELF2] - TLS relocations implemented
Michael Spencer via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 22 16:40:46 PDT 2015
Bigcheese requested changes to this revision.
Bigcheese added a reviewer: Bigcheese.
This revision now requires changes to proceed.
================
Comment at: ELF/Writer.cpp:612-642
@@ -611,12 +611,33 @@
uintX_t Last = PF_R;
+
+ bool HasTbss = false;
+ bool HasTdata = false;
+ bool InTls = false;
for (OutputSectionBase<ELFT> *Sec : OutputSections) {
if (!Sec->getSize() || !needsPhdr<ELFT>(Sec))
continue;
+
+ bool EndPhdr = false;
+ if (Sec->getFlags() & SHF_TLS) {
+ if (Sec->getType() == SHT_PROGBITS)
+ HasTdata = true;
+ else
+ HasTbss = true;
+ EndPhdr = true;
+ InTls = true;
+ } else if (InTls) {
+ EndPhdr = true;
+ InTls = false;
+ }
+
uintX_t Flags = toPhdrFlags(Sec->getFlags());
- if (Last != Flags) {
+ if (EndPhdr || Last != Flags) {
Last = Flags;
++NumPhdrs;
}
}
+ if (!HasTbss && HasTdata)
+ ++NumPhdrs;
+
// Reserve space needed for the program header so that the array
----------------
We don't need to handle the case of multiple disjoint TLS initialization blocks. The spec doesn't allow it. All this needs to do is add a phdr if it sees any allocated TLS section.
================
Comment at: ELF/Writer.cpp:736
@@ -664,3 +735,3 @@
}
}
----------------
grimar wrote:
> ruiu wrote:
> > Too much code has been added to this function. It needs cleanup before adding more.
> I agree. Its bulky now.
> I`ll try to do something with it tomorrow.
http://reviews.llvm.org/D13615 provides a much simpler implementation of the layout.
http://reviews.llvm.org/D13986
More information about the llvm-commits
mailing list