From 41217616a8ad0d7f1c35ba121a5fb2af9139c106 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 8 Dec 2016 03:17:05 +0000 Subject: [PATCH] Delete dead code. Thanks to George Rimar for pointing it out. llvm-svn: 289020 --- lld/ELF/LinkerScript.cpp | 13 ------------- lld/ELF/Writer.cpp | 2 ++ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index f126ef0..8a0c39d 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -764,19 +764,6 @@ void LinkerScript::assignAddresses(std::vector> &Phdrs) { MinVA = alignDown(MinVA - HeaderSize, Config->MaxPageSize); Out::ElfHeader->Addr = MinVA; Out::ProgramHeaders->Addr = Out::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::ProgramHeaders->Size = - sizeof(typename ELFT::Phdr) * Phdrs.size(); - } } // Creates program headers as instructed by PHDRS linker script command. diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index d7df3ac..ce1e533 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -139,6 +139,8 @@ template void Writer::removeEmptyPTLoad() { 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; }); -- 2.7.4