[lld] r289020 - Delete dead code.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 19:17:05 PST 2016


Author: rafael
Date: Wed Dec  7 21:17:05 2016
New Revision: 289020

URL: http://llvm.org/viewvc/llvm-project?rev=289020&view=rev
Log:
Delete dead code.

Thanks to George Rimar for pointing it out.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=289020&r1=289019&r2=289020&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed Dec  7 21:17:05 2016
@@ -764,19 +764,6 @@ void LinkerScript<ELFT>::assignAddresses
   MinVA = alignDown(MinVA - HeaderSize, Config->MaxPageSize);
   Out<ELFT>::ElfHeader->Addr = MinVA;
   Out<ELFT>::ProgramHeaders->Addr = Out<ELFT>::ElfHeader->Size + MinVA;
-
-  if (!FirstPTLoad->First) {
-    // Sometimes the very first PT_LOAD segment can be empty.
-    // This happens if (all conditions met):
-    //  - Linker script is used
-    //  - First section in ELF image is not RO
-    //  - Not enough space for program headers.
-    // The code below removes empty PT_LOAD segment and updates
-    // program headers size.
-    Phdrs.erase(FirstPTLoad);
-    Out<ELFT>::ProgramHeaders->Size =
-        sizeof(typename ELFT::Phdr) * Phdrs.size();
-  }
 }
 
 // Creates program headers as instructed by PHDRS linker script command.

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=289020&r1=289019&r2=289020&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Dec  7 21:17:05 2016
@@ -139,6 +139,8 @@ template <class ELFT> void Writer<ELFT>:
   auto I = std::remove_if(Phdrs.begin(), Phdrs.end(), [&](const Phdr &P) {
     if (P.H.p_type != PT_LOAD)
       return false;
+    if (!P.First)
+      return true;
     uintX_t Size = P.Last->Addr + P.Last->Size - P.First->Addr;
     return Size == 0;
   });




More information about the llvm-commits mailing list