summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/SyntheticSections.cpp25
-rw-r--r--lld/ELF/SyntheticSections.h5
-rw-r--r--lld/ELF/Writer.cpp2
3 files changed, 12 insertions, 20 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index fdac4c8bb6a..702271e7bce 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -319,16 +319,15 @@ static size_t getHashSize() {
}
}
-template <class ELFT>
-BuildIdSection<ELFT>::BuildIdSection()
+BuildIdSection::BuildIdSection()
: SyntheticSection(SHF_ALLOC, SHT_NOTE, 1, ".note.gnu.build-id"),
HashSize(getHashSize()) {}
-template <class ELFT> void BuildIdSection<ELFT>::writeTo(uint8_t *Buf) {
- const endianness E = ELFT::TargetEndianness;
- write32<E>(Buf, 4); // Name size
- write32<E>(Buf + 4, HashSize); // Content size
- write32<E>(Buf + 8, NT_GNU_BUILD_ID); // Type
+void BuildIdSection::writeTo(uint8_t *Buf) {
+ const endianness E = Config->IsLE ? endianness::little : endianness::big;
+ write32(Buf, 4, E); // Name size
+ write32(Buf + 4, HashSize, E); // Content size
+ write32(Buf + 8, NT_GNU_BUILD_ID, E); // Type
memcpy(Buf + 12, "GNU", 4); // Name string
HashBuf = Buf + 16;
}
@@ -350,8 +349,7 @@ static std::vector<ArrayRef<uint8_t>> split(ArrayRef<uint8_t> Arr,
// In order to utilize multiple cores, we first split data into 1MB
// chunks, compute a hash for each chunk, and then compute a hash value
// of the hash values.
-template <class ELFT>
-void BuildIdSection<ELFT>::computeHash(
+void BuildIdSection::computeHash(
llvm::ArrayRef<uint8_t> Data,
std::function<void(uint8_t *Dest, ArrayRef<uint8_t> Arr)> HashFn) {
std::vector<ArrayRef<uint8_t>> Chunks = split(Data, 1024 * 1024);
@@ -376,8 +374,7 @@ size_t BssSection::reserveSpace(uint32_t Alignment, size_t Size) {
return this->Size - Size;
}
-template <class ELFT>
-void BuildIdSection<ELFT>::writeBuildId(ArrayRef<uint8_t> Buf) {
+void BuildIdSection::writeBuildId(ArrayRef<uint8_t> Buf) {
switch (Config->BuildId) {
case BuildIdKind::Fast:
computeHash(Buf, [](uint8_t *Dest, ArrayRef<uint8_t> Arr) {
@@ -2251,6 +2248,7 @@ InputSection *ThunkSection::getTargetInputSection() const {
InputSection *InX::ARMAttributes;
BssSection *InX::Bss;
BssSection *InX::BssRelRo;
+BuildIdSection *InX::BuildId;
InputSection *InX::Common;
StringTableSection *InX::DynStrTab;
InputSection *InX::Interp;
@@ -2305,11 +2303,6 @@ template class elf::MipsReginfoSection<ELF32BE>;
template class elf::MipsReginfoSection<ELF64LE>;
template class elf::MipsReginfoSection<ELF64BE>;
-template class elf::BuildIdSection<ELF32LE>;
-template class elf::BuildIdSection<ELF32BE>;
-template class elf::BuildIdSection<ELF64LE>;
-template class elf::BuildIdSection<ELF64BE>;
-
template class elf::GotSection<ELF32LE>;
template class elf::GotSection<ELF32BE>;
template class elf::GotSection<ELF64LE>;
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 5d648653dc6..d81541aec10 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -135,7 +135,7 @@ private:
};
// .note.gnu.build-id section.
-template <class ELFT> class BuildIdSection : public SyntheticSection {
+class BuildIdSection : public SyntheticSection {
// First 16 bytes are a header.
static const unsigned HeaderSize = 16;
@@ -760,6 +760,7 @@ struct InX {
static InputSection *ARMAttributes;
static BssSection *Bss;
static BssSection *BssRelRo;
+ static BuildIdSection *BuildId;
static InputSection *Common;
static StringTableSection *DynStrTab;
static InputSection *Interp;
@@ -773,7 +774,6 @@ struct InX {
};
template <class ELFT> struct In : public InX {
- static BuildIdSection<ELFT> *BuildId;
static DynamicSection<ELFT> *Dynamic;
static SymbolTableSection<ELFT> *DynSymTab;
static EhFrameHeader<ELFT> *EhFrameHdr;
@@ -792,7 +792,6 @@ template <class ELFT> struct In : public InX {
static VersionNeedSection<ELFT> *VerNeed;
};
-template <class ELFT> BuildIdSection<ELFT> *In<ELFT>::BuildId;
template <class ELFT> DynamicSection<ELFT> *In<ELFT>::Dynamic;
template <class ELFT> SymbolTableSection<ELFT> *In<ELFT>::DynSymTab;
template <class ELFT> EhFrameHeader<ELFT> *In<ELFT>::EhFrameHdr;
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 3586499376d..fab3c323bee 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -353,7 +353,7 @@ template <class ELFT> void Writer<ELFT>::createSyntheticSections() {
}
if (Config->BuildId != BuildIdKind::None) {
- In<ELFT>::BuildId = make<BuildIdSection<ELFT>>();
+ In<ELFT>::BuildId = make<BuildIdSection>();
Add(In<ELFT>::BuildId);
}
OpenPOWER on IntegriCloud