[lld] r310297 - [lld] Write the DataCRC to the output PDB.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 7 13:23:45 PDT 2017


Author: zturner
Date: Mon Aug  7 13:23:45 2017
New Revision: 310297

URL: http://llvm.org/viewvc/llvm-project?rev=310297&view=rev
Log:
[lld] Write the DataCRC to the output PDB.

Modified:
    lld/trunk/COFF/PDB.cpp
    lld/trunk/test/COFF/pdb.test

Modified: lld/trunk/COFF/PDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/PDB.cpp?rev=310297&r1=310296&r2=310297&view=diff
==============================================================================
--- lld/trunk/COFF/PDB.cpp (original)
+++ lld/trunk/COFF/PDB.cpp Mon Aug  7 13:23:45 2017
@@ -44,6 +44,7 @@
 #include "llvm/Support/BinaryByteStream.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/JamCRC.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include <memory>
@@ -690,12 +691,17 @@ void PDBLinker::addSectionContrib(pdb::D
   if (auto *SecChunk = dyn_cast<SectionChunk>(C)) {
     SC.Characteristics = SecChunk->Header->Characteristics;
     SC.Imod = SecChunk->File->ModuleDBI->getModuleIndex();
+    ArrayRef<uint8_t> Contents = SecChunk->getContents();
+    JamCRC CRC(0);
+    ArrayRef<char> CharContents = makeArrayRef(
+        reinterpret_cast<const char *>(Contents.data()), Contents.size());
+    CRC.update(CharContents);
+    SC.DataCrc = CRC.getCRC();
   } else {
     SC.Characteristics = OS->getCharacteristics();
     // FIXME: When we start creating DBI for import libraries, use those here.
     SC.Imod = LinkerModule.getModuleIndex();
   }
-  SC.DataCrc = 0;  // FIXME
   SC.RelocCrc = 0; // FIXME
   Builder.getDbiBuilder().addSectionContrib(SC);
 }

Modified: lld/trunk/test/COFF/pdb.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/pdb.test?rev=310297&r1=310296&r2=310297&view=diff
==============================================================================
--- lld/trunk/test/COFF/pdb.test (original)
+++ lld/trunk/test/COFF/pdb.test Mon Aug  7 13:23:45 2017
@@ -248,15 +248,15 @@ RAW-NEXT: ==============================
 RAW-NEXT:   PDB does not contain the requested image section header type
 RAW:                        Section Contributions
 RAW-NEXT: ============================================================
-RAW-NEXT:   SC[.pdata]  | mod = 0, 0001:0000, size = 12, data crc = 0, reloc crc = 0
+RAW-NEXT:   SC[.pdata]  | mod = 0, 0001:0000, size = 12, data crc = 361370162, reloc crc = 0
 RAW-NEXT:                 IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_READ
-RAW-NEXT:   SC[.text]   | mod = 0, 0002:0000, size = 14, data crc = 0, reloc crc = 0
+RAW-NEXT:   SC[.text]   | mod = 0, 0002:0000, size = 14, data crc = 1682752513, reloc crc = 0
 RAW-NEXT:                 IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_16BYTES | IMAGE_SCN_MEM_EXECUTE |
 RAW-NEXT:                 IMAGE_SCN_MEM_READ
-RAW-NEXT:   SC[.text]   | mod = 1, 0002:0016, size = 6, data crc = 0, reloc crc = 0
+RAW-NEXT:   SC[.text]   | mod = 1, 0002:0016, size = 6, data crc = 2139436471, reloc crc = 0
 RAW-NEXT:                 IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_16BYTES | IMAGE_SCN_MEM_EXECUTE |
 RAW-NEXT:                 IMAGE_SCN_MEM_READ
-RAW-NEXT:   SC[.xdata]  | mod = 0, 0003:0000, size = 8, data crc = 0, reloc crc = 0
+RAW-NEXT:   SC[.xdata]  | mod = 0, 0003:0000, size = 8, data crc = 264583633, reloc crc = 0
 RAW-NEXT:                 IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_READ
 RAW:                             Section Map
 RAW-NEXT: ============================================================




More information about the llvm-commits mailing list