Index: lld/trunk/ELF/SyntheticSections.h =================================================================== --- lld/trunk/ELF/SyntheticSections.h +++ lld/trunk/ELF/SyntheticSections.h @@ -135,7 +135,7 @@ }; // .note.gnu.build-id section. -template class BuildIdSection : public SyntheticSection { +class BuildIdSection : public SyntheticSection { // First 16 bytes are a header. static const unsigned HeaderSize = 16; @@ -760,6 +760,7 @@ 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 @@ }; template struct In : public InX { - static BuildIdSection *BuildId; static DynamicSection *Dynamic; static SymbolTableSection *DynSymTab; static EhFrameHeader *EhFrameHdr; @@ -792,7 +792,6 @@ static VersionNeedSection *VerNeed; }; -template BuildIdSection *In::BuildId; template DynamicSection *In::Dynamic; template SymbolTableSection *In::DynSymTab; template EhFrameHeader *In::EhFrameHdr; Index: lld/trunk/ELF/SyntheticSections.cpp =================================================================== --- lld/trunk/ELF/SyntheticSections.cpp +++ lld/trunk/ELF/SyntheticSections.cpp @@ -319,16 +319,15 @@ } } -template -BuildIdSection::BuildIdSection() +BuildIdSection::BuildIdSection() : SyntheticSection(SHF_ALLOC, SHT_NOTE, 1, ".note.gnu.build-id"), HashSize(getHashSize()) {} -template void BuildIdSection::writeTo(uint8_t *Buf) { - const endianness E = ELFT::TargetEndianness; - write32(Buf, 4); // Name size - write32(Buf + 4, HashSize); // Content size - write32(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 @@ // 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 -void BuildIdSection::computeHash( +void BuildIdSection::computeHash( llvm::ArrayRef Data, std::function Arr)> HashFn) { std::vector> Chunks = split(Data, 1024 * 1024); @@ -376,8 +374,7 @@ return this->Size - Size; } -template -void BuildIdSection::writeBuildId(ArrayRef Buf) { +void BuildIdSection::writeBuildId(ArrayRef Buf) { switch (Config->BuildId) { case BuildIdKind::Fast: computeHash(Buf, [](uint8_t *Dest, ArrayRef Arr) { @@ -2251,6 +2248,7 @@ 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; template class elf::MipsReginfoSection; -template class elf::BuildIdSection; -template class elf::BuildIdSection; -template class elf::BuildIdSection; -template class elf::BuildIdSection; - template class elf::GotSection; template class elf::GotSection; template class elf::GotSection; Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/ELF/Writer.cpp @@ -353,7 +353,7 @@ } if (Config->BuildId != BuildIdKind::None) { - In::BuildId = make>(); + In::BuildId = make(); Add(In::BuildId); }