summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-09-27 09:14:59 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-09-27 09:14:59 +0000
commitaaf54714296a93334bd95d4b609a5176a8308f3b (patch)
tree8b69a00f3a19f643512e0ad7e521d6111faf8489
parent5d6efd100b03b31f5b6a2d5e31a58f9541267927 (diff)
downloadbcm5719-llvm-aaf54714296a93334bd95d4b609a5176a8308f3b.tar.gz
bcm5719-llvm-aaf54714296a93334bd95d4b609a5176a8308f3b.zip
[ELF] - Detemplate of HashTableSection<ELFT>
Detemplation of one more synthetic section. Differential revision: https://reviews.llvm.org/D38241 llvm-svn: 314283
-rw-r--r--lld/ELF/SyntheticSections.cpp32
-rw-r--r--lld/ELF/SyntheticSections.h5
-rw-r--r--lld/ELF/Writer.cpp6
3 files changed, 17 insertions, 26 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index f633e87d30e..ec3b9b7a404 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -1119,8 +1119,8 @@ template <class ELFT> void DynamicSection<ELFT>::finalizeContents() {
add({DT_TEXTREL, (uint64_t)0});
if (InX::GnuHashTab)
add({DT_GNU_HASH, InX::GnuHashTab});
- if (In<ELFT>::HashTab)
- add({DT_HASH, In<ELFT>::HashTab});
+ if (InX::HashTab)
+ add({DT_HASH, InX::HashTab});
if (Out::PreinitArray) {
add({DT_PREINIT_ARRAY, Out::PreinitArray});
@@ -1612,13 +1612,12 @@ void GnuHashTableSection::addSymbols(std::vector<SymbolTableEntry> &V) {
V.push_back({Ent.Body, Ent.StrTabOffset});
}
-template <class ELFT>
-HashTableSection<ELFT>::HashTableSection()
+HashTableSection::HashTableSection()
: SyntheticSection(SHF_ALLOC, SHT_HASH, 4, ".hash") {
this->Entsize = 4;
}
-template <class ELFT> void HashTableSection<ELFT>::finalizeContents() {
+void HashTableSection::finalizeContents() {
getParent()->Link = InX::DynSymTab->getParent()->SectionIndex;
unsigned NumEntries = 2; // nbucket and nchain.
@@ -1631,18 +1630,15 @@ template <class ELFT> void HashTableSection<ELFT>::finalizeContents() {
this->Size = NumEntries * 4;
}
-template <class ELFT> void HashTableSection<ELFT>::writeTo(uint8_t *Buf) {
- // A 32-bit integer type in the target endianness.
- typedef typename ELFT::Word Elf_Word;
-
+void HashTableSection::writeTo(uint8_t *Buf) {
unsigned NumSymbols = InX::DynSymTab->getNumSymbols();
- auto *P = reinterpret_cast<Elf_Word *>(Buf);
- *P++ = NumSymbols; // nbucket
- *P++ = NumSymbols; // nchain
+ uint32_t *P = reinterpret_cast<uint32_t *>(Buf);
+ write32(P++, NumSymbols, Config->Endianness); // nbucket
+ write32(P++, NumSymbols, Config->Endianness); // nchain
- Elf_Word *Buckets = P;
- Elf_Word *Chains = P + NumSymbols;
+ uint32_t *Buckets = P;
+ uint32_t *Chains = P + NumSymbols;
for (const SymbolTableEntry &S : InX::DynSymTab->getSymbols()) {
SymbolBody *Body = S.Symbol;
@@ -1650,7 +1646,7 @@ template <class ELFT> void HashTableSection<ELFT>::writeTo(uint8_t *Buf) {
unsigned I = Body->DynsymIndex;
uint32_t Hash = hashSysV(Name) % NumSymbols;
Chains[I] = Buckets[Hash];
- Buckets[Hash] = I;
+ write32(Buckets + Hash, I, Config->Endianness);
}
}
@@ -2362,6 +2358,7 @@ GdbIndexSection *InX::GdbIndex;
GotSection *InX::Got;
GotPltSection *InX::GotPlt;
GnuHashTableSection *InX::GnuHashTab;
+HashTableSection *InX::HashTab;
IgotPltSection *InX::IgotPlt;
MipsGotSection *InX::MipsGot;
MipsRldMapSection *InX::MipsRldMap;
@@ -2416,11 +2413,6 @@ template class elf::SymbolTableSection<ELF32BE>;
template class elf::SymbolTableSection<ELF64LE>;
template class elf::SymbolTableSection<ELF64BE>;
-template class elf::HashTableSection<ELF32LE>;
-template class elf::HashTableSection<ELF32BE>;
-template class elf::HashTableSection<ELF64LE>;
-template class elf::HashTableSection<ELF64BE>;
-
template class elf::EhFrameHeader<ELF32LE>;
template class elf::EhFrameHeader<ELF32BE>;
template class elf::EhFrameHeader<ELF64LE>;
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index c494dc32974..b807408e5c7 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -464,7 +464,7 @@ private:
size_t Size = 0;
};
-template <class ELFT> class HashTableSection final : public SyntheticSection {
+class HashTableSection final : public SyntheticSection {
public:
HashTableSection();
void finalizeContents() override;
@@ -804,6 +804,7 @@ struct InX {
static StringTableSection *DynStrTab;
static SymbolTableBaseSection *DynSymTab;
static GnuHashTableSection *GnuHashTab;
+ static HashTableSection *HashTab;
static InputSection *Interp;
static GdbIndexSection *GdbIndex;
static GotSection *Got;
@@ -821,7 +822,6 @@ struct InX {
template <class ELFT> struct In : public InX {
static EhFrameHeader<ELFT> *EhFrameHdr;
static EhFrameSection<ELFT> *EhFrame;
- static HashTableSection<ELFT> *HashTab;
static RelocationSection<ELFT> *RelaDyn;
static RelocationSection<ELFT> *RelaPlt;
static RelocationSection<ELFT> *RelaIplt;
@@ -832,7 +832,6 @@ template <class ELFT> struct In : public InX {
template <class ELFT> EhFrameHeader<ELFT> *In<ELFT>::EhFrameHdr;
template <class ELFT> EhFrameSection<ELFT> *In<ELFT>::EhFrame;
-template <class ELFT> HashTableSection<ELFT> *In<ELFT>::HashTab;
template <class ELFT> RelocationSection<ELFT> *In<ELFT>::RelaDyn;
template <class ELFT> RelocationSection<ELFT> *In<ELFT>::RelaPlt;
template <class ELFT> RelocationSection<ELFT> *In<ELFT>::RelaIplt;
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 0e27bc98662..4442f44b0e2 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -333,8 +333,8 @@ template <class ELFT> void Writer<ELFT>::createSyntheticSections() {
}
if (Config->SysvHash) {
- In<ELFT>::HashTab = make<HashTableSection<ELFT>>();
- Add(In<ELFT>::HashTab);
+ InX::HashTab = make<HashTableSection>();
+ Add(InX::HashTab);
}
Add(InX::Dynamic);
@@ -1353,7 +1353,7 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
// symbol table section (DynSymTab) must be the first one.
applySynthetic({InX::DynSymTab, InX::Bss,
InX::BssRelRo, InX::GnuHashTab,
- In<ELFT>::HashTab, InX::SymTab,
+ InX::HashTab, InX::SymTab,
InX::ShStrTab, InX::StrTab,
In<ELFT>::VerDef, InX::DynStrTab,
InX::Got, InX::MipsGot,
OpenPOWER on IntegriCloud