[lld] r298065 - [ELF] - Detemplate PltSection. NFC.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 17 04:01:57 PDT 2017
Author: grimar
Date: Fri Mar 17 06:01:57 2017
New Revision: 298065
URL: http://llvm.org/viewvc/llvm-project?rev=298065&view=rev
Log:
[ELF] - Detemplate PltSection. NFC.
Alternative approach can be remove templated method
either, like D31028 do.
Modified:
lld/trunk/ELF/Relocations.cpp
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/ELF/SyntheticSections.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=298065&r1=298064&r2=298065&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Fri Mar 17 06:01:57 2017
@@ -789,13 +789,13 @@ static void scanRelocs(InputSectionBase
continue;
if (Body.isGnuIFunc() && !Preemptible) {
- In<ELFT>::Iplt->addEntry(Body);
+ In<ELFT>::Iplt->addEntry<ELFT>(Body);
In<ELFT>::IgotPlt->addEntry(Body);
In<ELFT>::RelaIplt->addReloc({Target->IRelativeRel, In<ELFT>::IgotPlt,
Body.getGotPltOffset(), !Preemptible,
&Body, 0});
} else {
- In<ELFT>::Plt->addEntry(Body);
+ In<ELFT>::Plt->addEntry<ELFT>(Body);
In<ELFT>::GotPlt->addEntry(Body);
In<ELFT>::RelaPlt->addReloc({Target->PltRel, In<ELFT>::GotPlt,
Body.getGotPltOffset(), !Preemptible,
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=298065&r1=298064&r2=298065&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Fri Mar 17 06:01:57 2017
@@ -1645,12 +1645,11 @@ template <class ELFT> void HashTableSect
}
}
-template <class ELFT>
-PltSection<ELFT>::PltSection(size_t S)
+PltSection::PltSection(size_t S)
: SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 16, ".plt"),
HeaderSize(S) {}
-template <class ELFT> void PltSection<ELFT>::writeTo(uint8_t *Buf) {
+void PltSection::writeTo(uint8_t *Buf) {
// At beginning of PLT but not the IPLT, we have code to call the dynamic
// linker to resolve dynsyms at runtime. Write such code.
if (HeaderSize != 0)
@@ -1669,7 +1668,7 @@ template <class ELFT> void PltSection<EL
}
}
-template <class ELFT> void PltSection<ELFT>::addEntry(SymbolBody &Sym) {
+template <class ELFT> void PltSection::addEntry(SymbolBody &Sym) {
Sym.PltIndex = Entries.size();
RelocationSection<ELFT> *PltRelocSection = In<ELFT>::RelaPlt;
if (HeaderSize == 0) {
@@ -1680,13 +1679,13 @@ template <class ELFT> void PltSection<EL
Entries.push_back(std::make_pair(&Sym, RelOff));
}
-template <class ELFT> size_t PltSection<ELFT>::getSize() const {
+size_t PltSection::getSize() const {
return HeaderSize + Entries.size() * Target->PltEntrySize;
}
// Some architectures such as additional symbols in the PLT section. For
// example ARM uses mapping symbols to aid disassembly
-template <class ELFT> void PltSection<ELFT>::addSymbols() {
+void PltSection::addSymbols() {
// The PLT may have symbols defined for the Header, the IPLT has no header
if (HeaderSize != 0)
Target->addPltHeaderSymbols(this);
@@ -1697,8 +1696,8 @@ template <class ELFT> void PltSection<EL
}
}
-template <class ELFT> unsigned PltSection<ELFT>::getPltRelocOff() const {
- return (HeaderSize == 0) ? In<ELFT>::Plt->getSize() : 0;
+unsigned PltSection::getPltRelocOff() const {
+ return (HeaderSize == 0) ? InX::Plt->getSize() : 0;
}
template <class ELFT>
@@ -2262,6 +2261,15 @@ InputSection *ThunkSection::getTargetInp
return T->getTargetInputSection();
}
+namespace lld {
+namespace elf {
+template void PltSection::addEntry<ELF32LE>(SymbolBody &Sym);
+template void PltSection::addEntry<ELF32BE>(SymbolBody &Sym);
+template void PltSection::addEntry<ELF64LE>(SymbolBody &Sym);
+template void PltSection::addEntry<ELF64BE>(SymbolBody &Sym);
+}
+}
+
InputSection *InX::ARMAttributes;
BssSection *InX::Bss;
BssSection *InX::BssRelRo;
@@ -2271,6 +2279,8 @@ InputSection *InX::Interp;
GotPltSection *InX::GotPlt;
IgotPltSection *InX::IgotPlt;
MipsRldMapSection *InX::MipsRldMap;
+PltSection *InX::Plt;
+PltSection *InX::Iplt;
StringTableSection *InX::ShStrTab;
StringTableSection *InX::StrTab;
@@ -2352,11 +2362,6 @@ template class elf::HashTableSection<ELF
template class elf::HashTableSection<ELF64LE>;
template class elf::HashTableSection<ELF64BE>;
-template class elf::PltSection<ELF32LE>;
-template class elf::PltSection<ELF32BE>;
-template class elf::PltSection<ELF64LE>;
-template class elf::PltSection<ELF64BE>;
-
template class elf::GdbIndexSection<ELF32LE>;
template class elf::GdbIndexSection<ELF32BE>;
template class elf::GdbIndexSection<ELF64LE>;
Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=298065&r1=298064&r2=298065&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Fri Mar 17 06:01:57 2017
@@ -479,15 +479,16 @@ private:
// header as its first entry that is used at run-time to resolve lazy binding.
// The latter is used for GNU Ifunc symbols, that will be subject to a
// Target->IRelativeRel.
-template <class ELFT> class PltSection : public SyntheticSection {
+class PltSection : public SyntheticSection {
public:
PltSection(size_t HeaderSize);
void writeTo(uint8_t *Buf) override;
size_t getSize() const override;
- void addEntry(SymbolBody &Sym);
bool empty() const override { return Entries.empty(); }
void addSymbols();
+ template <class ELFT> void addEntry(SymbolBody &Sym);
+
private:
void writeHeader(uint8_t *Buf){};
void addHeaderSymbols(){};
@@ -766,6 +767,8 @@ struct InX {
static GotPltSection *GotPlt;
static IgotPltSection *IgotPlt;
static MipsRldMapSection *MipsRldMap;
+ static PltSection *Plt;
+ static PltSection *Iplt;
static StringTableSection *ShStrTab;
static StringTableSection *StrTab;
};
@@ -781,8 +784,6 @@ template <class ELFT> struct In : public
static EhFrameSection<ELFT> *EhFrame;
static MipsGotSection<ELFT> *MipsGot;
static HashTableSection<ELFT> *HashTab;
- static PltSection<ELFT> *Plt;
- static PltSection<ELFT> *Iplt;
static RelocationSection<ELFT> *RelaDyn;
static RelocationSection<ELFT> *RelaPlt;
static RelocationSection<ELFT> *RelaIplt;
@@ -802,8 +803,6 @@ template <class ELFT> GotSection<ELFT> *
template <class ELFT> EhFrameSection<ELFT> *In<ELFT>::EhFrame;
template <class ELFT> MipsGotSection<ELFT> *In<ELFT>::MipsGot;
template <class ELFT> HashTableSection<ELFT> *In<ELFT>::HashTab;
-template <class ELFT> PltSection<ELFT> *In<ELFT>::Plt;
-template <class ELFT> PltSection<ELFT> *In<ELFT>::Iplt;
template <class ELFT> RelocationSection<ELFT> *In<ELFT>::RelaDyn;
template <class ELFT> RelocationSection<ELFT> *In<ELFT>::RelaPlt;
template <class ELFT> RelocationSection<ELFT> *In<ELFT>::RelaIplt;
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=298065&r1=298064&r2=298065&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Mar 17 06:01:57 2017
@@ -449,9 +449,9 @@ template <class ELFT> void Writer<ELFT>:
false /*Sort*/);
Add(In<ELFT>::RelaIplt);
- In<ELFT>::Plt = make<PltSection<ELFT>>(Target->PltHeaderSize);
+ In<ELFT>::Plt = make<PltSection>(Target->PltHeaderSize);
Add(In<ELFT>::Plt);
- In<ELFT>::Iplt = make<PltSection<ELFT>>(0);
+ In<ELFT>::Iplt = make<PltSection>(0);
Add(In<ELFT>::Iplt);
if (!Config->Relocatable) {
More information about the llvm-commits
mailing list