Index: lld/trunk/ELF/OutputSections.h =================================================================== --- lld/trunk/ELF/OutputSections.h +++ lld/trunk/ELF/OutputSections.h @@ -700,7 +700,7 @@ public: void writeTo(uint8_t *Buf) override; - virtual void writeBuildId(ArrayRef> Bufs) = 0; + virtual void writeBuildId(ArrayRef Buf) = 0; typename Base::Kind getKind() const override { return Base::BuildId; } static bool classof(const Base *B) { return B->getKind() == Base::BuildId; } @@ -713,32 +713,32 @@ template class BuildIdFnv1 final : public BuildIdSection { public: BuildIdFnv1() : BuildIdSection(8) {} - void writeBuildId(ArrayRef> Bufs) override; + void writeBuildId(ArrayRef Buf) override; }; template class BuildIdMd5 final : public BuildIdSection { public: BuildIdMd5() : BuildIdSection(16) {} - void writeBuildId(ArrayRef> Bufs) override; + void writeBuildId(ArrayRef Buf) override; }; template class BuildIdSha1 final : public BuildIdSection { public: BuildIdSha1() : BuildIdSection(20) {} - void writeBuildId(ArrayRef> Bufs) override; + void writeBuildId(ArrayRef Buf) override; }; template class BuildIdUuid final : public BuildIdSection { public: BuildIdUuid() : BuildIdSection(16) {} - void writeBuildId(ArrayRef> Bufs) override; + void writeBuildId(ArrayRef Buf) override; }; template class BuildIdHexstring final : public BuildIdSection { public: BuildIdHexstring(); - void writeBuildId(ArrayRef> Bufs) override; + void writeBuildId(ArrayRef) override; }; // All output sections that are hadnled by the linker specially are Index: lld/trunk/ELF/OutputSections.cpp =================================================================== --- lld/trunk/ELF/OutputSections.cpp +++ lld/trunk/ELF/OutputSections.cpp @@ -1657,40 +1657,36 @@ } template -void BuildIdFnv1::writeBuildId(ArrayRef> Bufs) { +void BuildIdFnv1::writeBuildId(ArrayRef Buf) { const endianness E = ELFT::TargetEndianness; // 64-bit FNV-1 hash uint64_t Hash = 0xcbf29ce484222325; - for (ArrayRef Buf : Bufs) { - for (uint8_t B : Buf) { - Hash *= 0x100000001b3; - Hash ^= B; - } + for (uint8_t B : Buf) { + Hash *= 0x100000001b3; + Hash ^= B; } write64(this->HashBuf, Hash); } template -void BuildIdMd5::writeBuildId(ArrayRef> Bufs) { +void BuildIdMd5::writeBuildId(ArrayRef Buf) { MD5 Hash; - for (ArrayRef Buf : Bufs) - Hash.update(Buf); + Hash.update(Buf); MD5::MD5Result Res; Hash.final(Res); memcpy(this->HashBuf, Res, 16); } template -void BuildIdSha1::writeBuildId(ArrayRef> Bufs) { +void BuildIdSha1::writeBuildId(ArrayRef Buf) { SHA1 Hash; - for (ArrayRef Buf : Bufs) - Hash.update(Buf); + Hash.update(Buf); memcpy(this->HashBuf, Hash.final().data(), 20); } template -void BuildIdUuid::writeBuildId(ArrayRef> Bufs) { +void BuildIdUuid::writeBuildId(ArrayRef Buf) { if (getRandomBytes(this->HashBuf, 16)) error("entropy source failure"); } @@ -1700,7 +1696,7 @@ : BuildIdSection(Config->BuildIdVector.size()) {} template -void BuildIdHexstring::writeBuildId(ArrayRef> Bufs) { +void BuildIdHexstring::writeBuildId(ArrayRef Buf) { memcpy(this->HashBuf, Config->BuildIdVector.data(), Config->BuildIdVector.size()); } Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/ELF/Writer.cpp @@ -1320,21 +1320,10 @@ if (!Out::BuildId) return; - // Compute a hash of all sections except .debug_* sections. - // We skip debug sections because they tend to be very large - // and their contents are very likely to be the same as long as - // other sections are the same. + // Compute a hash of all sections of the output file. uint8_t *Start = Buffer->getBufferStart(); - uint8_t *Last = Start; - std::vector> Regions; - for (OutputSectionBase *Sec : OutputSections) { - uint8_t *End = Start + Sec->getFileOff(); - if (!Sec->getName().startswith(".debug_")) - Regions.push_back({Last, End}); - Last = End; - } - Regions.push_back({Last, Start + FileSize}); - Out::BuildId->writeBuildId(Regions); + uint8_t *End = Start + FileSize; + Out::BuildId->writeBuildId({Start, End}); } template void elf::writeResult();