[lld] r303893 - Use MD5::hash(). NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu May 25 11:17:43 PDT 2017


Author: ruiu
Date: Thu May 25 13:17:43 2017
New Revision: 303893

URL: http://llvm.org/viewvc/llvm-project?rev=303893&view=rev
Log:
Use MD5::hash(). NFC.

Modified:
    lld/trunk/COFF/Writer.cpp

Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=303893&r1=303892&r2=303893&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Thu May 25 13:17:43 2017
@@ -805,19 +805,15 @@ void Writer::writeBuildId() {
   if (BuildId == nullptr)
     return;
 
-  MD5 Hash;
-  MD5::MD5Result Res;
-
-  Hash.update(ArrayRef<uint8_t>{Buffer->getBufferStart(),
-                                Buffer->getBufferEnd()});
-  Hash.final(Res);
-
   assert(BuildId->DI->Signature.CVSignature == OMF::Signature::PDB70 &&
          "only PDB 7.0 is supported");
-  assert(sizeof(Res) == sizeof(BuildId->DI->PDB70.Signature) &&
+  assert(sizeof(BuildId->DI->PDB70.Signature) == 16 &&
          "signature size mismatch");
-  memcpy(BuildId->DI->PDB70.Signature, Res.Bytes.data(),
-         sizeof(codeview::PDB70DebugInfo::Signature));
+
+  // Compute an MD5 hash.
+  ArrayRef<uint8_t> Buf(Buffer->getBufferStart(), Buffer->getBufferEnd());
+  memcpy(BuildId->DI->PDB70.Signature, MD5::hash(Buf).data(), 16);
+
   // TODO(compnerd) track the Age
   BuildId->DI->PDB70.Age = 1;
 }




More information about the llvm-commits mailing list