[ELF] De-template PltSection::addEntry. NFC

This commit is contained in:
Fangrui Song 2019-12-16 10:58:48 -08:00
parent 6a71355e52
commit 98afa2c1f1
3 changed files with 8 additions and 13 deletions

View File

@ -1011,10 +1011,10 @@ static void addRelativeReloc(InputSectionBase *isec, uint64_t offsetInSec,
expr, type);
}
template <class ELFT, class GotPltSection>
template <class GotPltSection>
static void addPltEntry(PltSection *plt, GotPltSection *gotPlt,
RelocationBaseSection *rel, RelType type, Symbol &sym) {
plt->addEntry<ELFT>(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<ELFT>(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<ELFT>(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<Defined>(cast<Defined>(sym));
addPltEntry<ELFT>(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)) {

View File

@ -2486,7 +2486,7 @@ void PltSection::writeTo(uint8_t *buf) {
}
}
template <class ELFT> 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<ELF32BE>();
template void splitSections<ELF64LE>();
template void splitSections<ELF64BE>();
template void PltSection::addEntry<ELF32LE>(Symbol &Sym);
template void PltSection::addEntry<ELF32BE>(Symbol &Sym);
template void PltSection::addEntry<ELF64LE>(Symbol &Sym);
template void PltSection::addEntry<ELF64BE>(Symbol &Sym);
template class MipsAbiFlagsSection<ELF32LE>;
template class MipsAbiFlagsSection<ELF32BE>;
template class MipsAbiFlagsSection<ELF64LE>;

View File

@ -673,7 +673,7 @@ public:
size_t getSize() const override;
bool isNeeded() const override { return !entries.empty(); }
void addSymbols();
template <class ELFT> void addEntry(Symbol &sym);
void addEntry(Symbol &sym);
size_t headerSize;