[PATCH] D22789: Remove special handling of TLS/NOTE/RELRO sections.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 17:12:23 PDT 2016


ruiu created this revision.
ruiu added a reviewer: evgeny777.
ruiu added a subscriber: llvm-commits.

We were handling TLS/NOTE/RELRO sections in a special manner when
linker scripts are given. But I think we don't really need this --
we generally don't make a guess if linker scripts are given and do
exactly what is instructed to do. Our stance is, if you want to force
some layout, you need to give complete instructions to the linker.

https://reviews.llvm.org/D22789

Files:
  ELF/LinkerScript.cpp

Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -256,9 +256,6 @@
 std::vector<PhdrEntry<ELFT>>
 LinkerScript<ELFT>::createPhdrs(ArrayRef<OutputSectionBase<ELFT> *> Sections) {
   std::vector<PhdrEntry<ELFT>> Ret;
-  PhdrEntry<ELFT> *TlsPhdr = nullptr;
-  PhdrEntry<ELFT> *NotePhdr = nullptr;
-  PhdrEntry<ELFT> *RelroPhdr = nullptr;
 
   for (const PhdrsCommand &Cmd : Opt.PhdrsCommands) {
     Ret.emplace_back(Cmd.Type, Cmd.Flags == UINT_MAX ? PF_R : Cmd.Flags);
@@ -280,15 +277,6 @@
         Phdr.add(Out<ELFT>::Dynamic);
       }
       break;
-    case PT_TLS:
-      TlsPhdr = &Phdr;
-      break;
-    case PT_NOTE:
-      NotePhdr = &Phdr;
-      break;
-    case PT_GNU_RELRO:
-      RelroPhdr = &Phdr;
-      break;
     case PT_GNU_EH_FRAME:
       if (!Out<ELFT>::EhFrame->empty() && Out<ELFT>::EhFrameHdr) {
         Phdr.H.p_flags = toPhdrFlags(Out<ELFT>::EhFrameHdr->getFlags());
@@ -304,12 +292,6 @@
     if (!(Sec->getFlags() & SHF_ALLOC))
       break;
 
-    if (TlsPhdr && (Sec->getFlags() & SHF_TLS))
-      TlsPhdr->add(Sec);
-
-    if (!needsPtLoad<ELFT>(Sec))
-      continue;
-
     std::vector<size_t> PhdrIds = getPhdrIndices(Sec->getName());
     if (!PhdrIds.empty()) {
       // Assign headers specified by linker script
@@ -328,11 +310,6 @@
       }
       Load->add(Sec);
     }
-
-    if (RelroPhdr && isRelroSection(Sec))
-      RelroPhdr->add(Sec);
-    if (NotePhdr && Sec->getType() == SHT_NOTE)
-      NotePhdr->add(Sec);
   }
   return Ret;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22789.65442.patch
Type: text/x-patch
Size: 1584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160726/ac548472/attachment.bin>


More information about the llvm-commits mailing list