From 98afa2c1f1a040afc02be10d5a58bf7e87c38cc1 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 16 Dec 2019 10:58:48 -0800 Subject: [PATCH] [ELF] De-template PltSection::addEntry. NFC --- lld/ELF/Relocations.cpp | 12 ++++++------ lld/ELF/SyntheticSections.cpp | 7 +------ lld/ELF/SyntheticSections.h | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 82e0fdb..31b2a14 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -1011,10 +1011,10 @@ static void addRelativeReloc(InputSectionBase *isec, uint64_t offsetInSec, expr, type); } -template +template static void addPltEntry(PltSection *plt, GotPltSection *gotPlt, RelocationBaseSection *rel, RelType type, Symbol &sym) { - plt->addEntry(sym); + plt->addEntry(sym); gotPlt->addEntry(sym); rel->addReloc( {type, gotPlt, sym.getGotPltOffset(), !sym.isPreemptible, &sym, 0}); @@ -1190,7 +1190,7 @@ static void processRelocAux(InputSectionBase &sec, RelExpr expr, RelType type, "' cannot be preempted; recompile with -fPIE" + getLocation(sec, sym, offset)); if (!sym.isInPlt()) - addPltEntry(in.plt, in.gotPlt, in.relaPlt, target->pltRel, sym); + addPltEntry(in.plt, in.gotPlt, in.relaPlt, target->pltRel, sym); if (!sym.isDefined()) replaceWithDefined( sym, in.plt, @@ -1331,7 +1331,7 @@ static void scanReloc(InputSectionBase &sec, OffsetGetter &getOffset, RelTy *&i, if (!sym.isGnuIFunc() || sym.isPreemptible) { // If a relocation needs PLT, we create PLT and GOTPLT slots for the symbol. if (needsPlt(expr) && !sym.isInPlt()) - addPltEntry(in.plt, in.gotPlt, in.relaPlt, target->pltRel, sym); + addPltEntry(in.plt, in.gotPlt, in.relaPlt, target->pltRel, sym); // Create a GOT slot if a relocation needs GOT. if (needsGot(expr)) { @@ -1401,8 +1401,8 @@ static void scanReloc(InputSectionBase &sec, OffsetGetter &getOffset, RelTy *&i, // that's really needed to create the IRELATIVE is the section and value, // so ideally we should just need to copy those. auto *directSym = make(cast(sym)); - addPltEntry(in.iplt, in.igotPlt, in.relaIplt, target->iRelativeRel, - *directSym); + addPltEntry(in.iplt, in.igotPlt, in.relaIplt, target->iRelativeRel, + *directSym); sym.pltIndex = directSym->pltIndex; } if (needsGot(expr)) { diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index d014da2..d5b45c8 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -2486,7 +2486,7 @@ void PltSection::writeTo(uint8_t *buf) { } } -template void PltSection::addEntry(Symbol &sym) { +void PltSection::addEntry(Symbol &sym) { sym.pltIndex = entries.size(); entries.push_back(&sym); } @@ -3621,11 +3621,6 @@ template void splitSections(); template void splitSections(); template void splitSections(); -template void PltSection::addEntry(Symbol &Sym); -template void PltSection::addEntry(Symbol &Sym); -template void PltSection::addEntry(Symbol &Sym); -template void PltSection::addEntry(Symbol &Sym); - template class MipsAbiFlagsSection; template class MipsAbiFlagsSection; template class MipsAbiFlagsSection; diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index dee21f3..601f660 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -673,7 +673,7 @@ public: size_t getSize() const override; bool isNeeded() const override { return !entries.empty(); } void addSymbols(); - template void addEntry(Symbol &sym); + void addEntry(Symbol &sym); size_t headerSize; -- 2.7.4