[PATCH] D36342: [lld] Write the DataCRC to the output PDB
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 4 16:10:36 PDT 2017
zturner created this revision.
This matches what MSVC does, and I have confirmed that the CRC we write is the same value as the one they write.
https://reviews.llvm.org/D36342
Files:
lld/COFF/PDB.cpp
lld/test/COFF/pdb.test
Index: lld/test/COFF/pdb.test
===================================================================
--- lld/test/COFF/pdb.test
+++ lld/test/COFF/pdb.test
@@ -248,15 +248,15 @@
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: ============================================================
Index: lld/COFF/PDB.cpp
===================================================================
--- lld/COFF/PDB.cpp
+++ lld/COFF/PDB.cpp
@@ -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 @@
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36342.109835.patch
Type: text/x-patch
Size: 2872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170804/8c9677dc/attachment.bin>
More information about the llvm-commits
mailing list