}
template <class ELFT>
-void BuildIdFnv1<ELFT>::writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) {
+void BuildIdFnv1<ELFT>::writeBuildId(ArrayRef<uint8_t> Buf) {
const endianness E = ELFT::TargetEndianness;
// 64-bit FNV-1 hash
uint64_t Hash = 0xcbf29ce484222325;
- for (ArrayRef<uint8_t> Buf : Bufs) {
- for (uint8_t B : Buf) {
- Hash *= 0x100000001b3;
- Hash ^= B;
- }
+ for (uint8_t B : Buf) {
+ Hash *= 0x100000001b3;
+ Hash ^= B;
}
write64<E>(this->HashBuf, Hash);
}
template <class ELFT>
-void BuildIdMd5<ELFT>::writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) {
+void BuildIdMd5<ELFT>::writeBuildId(ArrayRef<uint8_t> Buf) {
MD5 Hash;
- for (ArrayRef<uint8_t> Buf : Bufs)
- Hash.update(Buf);
+ Hash.update(Buf);
MD5::MD5Result Res;
Hash.final(Res);
memcpy(this->HashBuf, Res, 16);
}
template <class ELFT>
-void BuildIdSha1<ELFT>::writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) {
+void BuildIdSha1<ELFT>::writeBuildId(ArrayRef<uint8_t> Buf) {
SHA1 Hash;
- for (ArrayRef<uint8_t> Buf : Bufs)
- Hash.update(Buf);
+ Hash.update(Buf);
memcpy(this->HashBuf, Hash.final().data(), 20);
}
template <class ELFT>
-void BuildIdUuid<ELFT>::writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) {
+void BuildIdUuid<ELFT>::writeBuildId(ArrayRef<uint8_t> Buf) {
if (getRandomBytes(this->HashBuf, 16))
error("entropy source failure");
}
: BuildIdSection<ELFT>(Config->BuildIdVector.size()) {}
template <class ELFT>
-void BuildIdHexstring<ELFT>::writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) {
+void BuildIdHexstring<ELFT>::writeBuildId(ArrayRef<uint8_t> Buf) {
memcpy(this->HashBuf, Config->BuildIdVector.data(),
Config->BuildIdVector.size());
}
public:
void writeTo(uint8_t *Buf) override;
- virtual void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) = 0;
+ virtual void writeBuildId(ArrayRef<uint8_t> Buf) = 0;
typename Base::Kind getKind() const override { return Base::BuildId; }
static bool classof(const Base *B) { return B->getKind() == Base::BuildId; }
template <class ELFT> class BuildIdFnv1 final : public BuildIdSection<ELFT> {
public:
BuildIdFnv1() : BuildIdSection<ELFT>(8) {}
- void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
+ void writeBuildId(ArrayRef<uint8_t> Buf) override;
};
template <class ELFT> class BuildIdMd5 final : public BuildIdSection<ELFT> {
public:
BuildIdMd5() : BuildIdSection<ELFT>(16) {}
- void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
+ void writeBuildId(ArrayRef<uint8_t> Buf) override;
};
template <class ELFT> class BuildIdSha1 final : public BuildIdSection<ELFT> {
public:
BuildIdSha1() : BuildIdSection<ELFT>(20) {}
- void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
+ void writeBuildId(ArrayRef<uint8_t> Buf) override;
};
template <class ELFT> class BuildIdUuid final : public BuildIdSection<ELFT> {
public:
BuildIdUuid() : BuildIdSection<ELFT>(16) {}
- void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
+ void writeBuildId(ArrayRef<uint8_t> Buf) override;
};
template <class ELFT>
class BuildIdHexstring final : public BuildIdSection<ELFT> {
public:
BuildIdHexstring();
- void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
+ void writeBuildId(ArrayRef<uint8_t>) override;
};
// All output sections that are hadnled by the linker specially are
if (!Out<ELFT>::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<ArrayRef<uint8_t>> Regions;
- for (OutputSectionBase<ELFT> *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<ELFT>::BuildId->writeBuildId(Regions);
+ uint8_t *End = Start + FileSize;
+ Out<ELFT>::BuildId->writeBuildId({Start, End});
}
template void elf::writeResult<ELF32LE>();