[lld] r290764 - COFF: replace a magic number and assert more

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 30 11:02:04 PST 2016


Author: compnerd
Date: Fri Dec 30 13:02:04 2016
New Revision: 290764

URL: http://llvm.org/viewvc/llvm-project?rev=290764&view=rev
Log:
COFF: replace a magic number and assert more

Assert that the size of the MD5 result is the same size as the signature
field being populated.  Use the sizeof operator to determine the size of
the field being written rather than hardcoding it to the magic number
16.  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=290764&r1=290763&r2=290764&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Fri Dec 30 13:02:04 2016
@@ -828,7 +828,10 @@ void Writer::writeBuildId() {
 
   assert(BuildId->DI->Signature.CVSignature == OMF::Signature::PDB70 &&
          "only PDB 7.0 is supported");
-  memcpy(BuildId->DI->PDB70.Signature, Res, 16);
+  assert(sizeof(Res) == sizeof(BuildId->DI->PDB70.Signature) &&
+         "signature size mismatch");
+  memcpy(BuildId->DI->PDB70.Signature, Res,
+         sizeof(codeview::PDB70DebugInfo::Signature));
   // TODO(compnerd) track the Age
   BuildId->DI->PDB70.Age = 1;
 }




More information about the llvm-commits mailing list