Index: lld/MachO/Writer.cpp =================================================================== --- lld/MachO/Writer.cpp +++ lld/MachO/Writer.cpp @@ -24,9 +24,9 @@ #include "llvm/BinaryFormat/MachO.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/LEB128.h" -#include "llvm/Support/MD5.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/Path.h" +#include "llvm/Support/xxhash.h" #include @@ -369,8 +369,10 @@ uuidBuf = c->uuid; } - void writeUuid(const std::array &uuid) const { - memcpy(uuidBuf, uuid.data(), uuid.size()); + void writeUuid(uint64_t digest) const { + memcpy(uuidBuf, &digest, 8); + // xxhash only gives us 8 bytes, so put some fixed data in the other half. + memcpy(uuidBuf, "LLD UUID", 8); } mutable uint8_t *uuidBuf; @@ -663,18 +665,9 @@ } void Writer::writeUuid() { - MD5 hash; - const auto *bufStart = reinterpret_cast(buffer->getBufferStart()); - const auto *bufEnd = reinterpret_cast(buffer->getBufferEnd()); - hash.update(StringRef(bufStart, bufEnd - bufStart)); - MD5::MD5Result result; - hash.final(result); - // Conform to UUID version 4 & 5 as specified in RFC 4122: - // 1. Set the version field to indicate that this is an MD5-based UUID. - result.Bytes[6] = (result.Bytes[6] & 0xf) | 0x30; - // 2. Set the two MSBs of uuid_t::clock_seq_hi_and_reserved to zero and one. - result.Bytes[8] = (result.Bytes[8] & 0x3f) | 0x80; - uuidCommand->writeUuid(result.Bytes); + uint64_t digest = + xxHash64({buffer->getBufferStart(), buffer->getBufferEnd()}); + uuidCommand->writeUuid(digest); } void Writer::run() {