From 7702bc237e9671b7203f2aa2eb6daf73efe4e85b Mon Sep 17 00:00:00 2001 From: George Rimar Date: Thu, 16 Mar 2017 11:20:02 +0000 Subject: [PATCH] [ELF] - Removed unused templates #4. NFC. llvm-svn: 297944 --- lld/ELF/Writer.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 02585ae68674..7f8391080f61 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -470,7 +470,6 @@ template void Writer::createSyntheticSections() { Add(In::StrTab); } -template static bool shouldKeepInSymtab(SectionBase *Sec, StringRef SymName, const SymbolBody &B) { if (B.isFile() || B.isSection()) @@ -497,7 +496,7 @@ static bool shouldKeepInSymtab(SectionBase *Sec, StringRef SymName, return !Sec || !(Sec->Flags & SHF_MERGE); } -template static bool includeInSymtab(const SymbolBody &B) { +static bool includeInSymtab(const SymbolBody &B) { if (!B.isLocal() && !B.symbol()->IsUsedInRegularObj) return false; @@ -535,11 +534,11 @@ template void Writer::copyLocalSymbols() { // No reason to keep local undefined symbol in symtab. if (!DR) continue; - if (!includeInSymtab(*B)) + if (!includeInSymtab(*B)) continue; SectionBase *Sec = DR->Section; - if (!shouldKeepInSymtab(Sec, B->getName(), *B)) + if (!shouldKeepInSymtab(Sec, B->getName(), *B)) continue; In::SymTab->addSymbol(B); } @@ -948,7 +947,6 @@ template void Writer::createSections() { Sec->assignOffsets(); } -template static bool canSharePtLoad(const OutputSection &S1, const OutputSection &S2) { if (!(S1.Flags & SHF_ALLOC) || !(S2.Flags & SHF_ALLOC)) return false; @@ -1011,8 +1009,8 @@ template void Writer::sortSections() { while (NonScriptI != E) { auto BestPos = std::max_element( I, NonScriptI, [&](OutputSection *&A, OutputSection *&B) { - bool ACanSharePtLoad = canSharePtLoad(**NonScriptI, *A); - bool BCanSharePtLoad = canSharePtLoad(**NonScriptI, *B); + bool ACanSharePtLoad = canSharePtLoad(**NonScriptI, *A); + bool BCanSharePtLoad = canSharePtLoad(**NonScriptI, *B); if (ACanSharePtLoad != BCanSharePtLoad) return BCanSharePtLoad; @@ -1052,7 +1050,6 @@ static void applySynthetic(const std::vector &Sections, // to make them visible from linkescript side. But not all sections are always // required to be in output. For example we don't need dynamic section content // sometimes. This function filters out such unused sections from output. -template static void removeUnusedSyntheticSections(std::vector &V) { // All input synthetic sections that can be empty are placed after // all regular ones. We iterate over them all and exit at first @@ -1119,7 +1116,7 @@ template void Writer::finalizeSections() { for (Symbol *S : Symtab::X->getSymbols()) { SymbolBody *Body = S->body(); - if (!includeInSymtab(*Body)) + if (!includeInSymtab(*Body)) continue; if (In::SymTab) In::SymTab->addSymbol(Body); @@ -1139,7 +1136,7 @@ template void Writer::finalizeSections() { // So far we have added sections from input object files. // This function adds linker-created Out::* sections. addPredefinedSections(); - removeUnusedSyntheticSections(OutputSections); + removeUnusedSyntheticSections(OutputSections); sortSections(); @@ -1265,7 +1262,7 @@ template OutputSection *Writer::findSection(StringRef Name) { return nullptr; } -template static bool needsPtLoad(OutputSection *Sec) { +static bool needsPtLoad(OutputSection *Sec) { if (!(Sec->Flags & SHF_ALLOC)) return false; @@ -1312,7 +1309,7 @@ template std::vector Writer::createPhdrs() { for (OutputSection *Sec : OutputSections) { if (!(Sec->Flags & SHF_ALLOC)) break; - if (!needsPtLoad(Sec)) + if (!needsPtLoad(Sec)) continue; // Segments are contiguous memory regions that has the same attributes @@ -1346,7 +1343,7 @@ template std::vector Writer::createPhdrs() { // read-only by dynamic linker after proccessing relocations. PhdrEntry RelRo(PT_GNU_RELRO, PF_R); for (OutputSection *Sec : OutputSections) - if (needsPtLoad(Sec) && isRelroSection(Sec)) + if (needsPtLoad(Sec) && isRelroSection(Sec)) RelRo.add(Sec); if (RelRo.First) Ret.push_back(std::move(RelRo)); @@ -1431,7 +1428,7 @@ template void Writer::fixSectionAlignments() { if (I == End || (I + 1) == End) continue; OutputSection *Sec = *(I + 1); - if (needsPtLoad(Sec)) + if (needsPtLoad(Sec)) Sec->PageAlign = true; } } @@ -1510,7 +1507,7 @@ template void Writer::assignAddresses() { VA = I->second; // We only assign VAs to allocated sections. - if (needsPtLoad(Sec)) { + if (needsPtLoad(Sec)) { VA = alignTo(VA, Alignment); Sec->Addr = VA; VA += Sec->Size;