[llvm] r257910 - [codeview] Dump the file checksum substream

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 15 10:06:25 PST 2016


Author: rnk
Date: Fri Jan 15 12:06:25 2016
New Revision: 257910

URL: http://llvm.org/viewvc/llvm-project?rev=257910&view=rev
Log:
[codeview] Dump the file checksum substream

Modified:
    llvm/trunk/include/llvm/DebugInfo/CodeView/Line.h
    llvm/trunk/tools/llvm-readobj/COFFDumper.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/Line.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/Line.h?rev=257910&r1=257909&r2=257910&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/Line.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/Line.h Fri Jan 15 12:06:25 2016
@@ -137,6 +137,20 @@ struct InlineeSourceLine {
   //   ulittle32_t Files[];
 };
 
+enum class FileChecksumKind : uint8_t {
+  None,
+  MD5,
+  SHA1,
+  SHA256
+};
+
+struct FileChecksum {
+  ulittle32_t FileNameOffset; // Offset of filename in string table substream.
+  uint8_t ChecksumSize;
+  uint8_t ChecksumKind; // FileChecksumKind
+  // Checksum bytes follow.
+};
+
 } // namespace codeview
 } // namespace llvm
 

Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=257910&r1=257909&r2=257910&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Fri Jan 15 12:06:25 2016
@@ -94,6 +94,8 @@ private:
                                       const SectionRef &Section,
                                       StringRef SectionContents);
 
+  void printCodeViewFileChecksums(StringRef Subsection);
+
   void printCodeViewInlineeLines(StringRef Subsection);
 
   void printMemberAttributes(MemberAttributes Attrs);
@@ -767,6 +769,13 @@ static const EnumEntry<uint8_t> Function
     LLVM_READOBJ_ENUM_CLASS_ENT(FunctionOptions, ConstructorWithVirtualBases),
 };
 
+static const EnumEntry<uint8_t> FileChecksumKindNames[] = {
+  LLVM_READOBJ_ENUM_CLASS_ENT(FileChecksumKind, None),
+  LLVM_READOBJ_ENUM_CLASS_ENT(FileChecksumKind, MD5),
+  LLVM_READOBJ_ENUM_CLASS_ENT(FileChecksumKind, SHA1),
+  LLVM_READOBJ_ENUM_CLASS_ENT(FileChecksumKind, SHA256),
+};
+
 template <typename T>
 static std::error_code getSymbolAuxData(const COFFObjectFile *Obj,
                                         COFFSymbolRef Symbol,
@@ -1030,6 +1039,10 @@ void COFFDumper::printCodeViewSymbolSect
       printCodeViewInlineeLines(Contents);
       break;
 
+    case ModuleSubstreamKind::FileChecksums:
+      printCodeViewFileChecksums(Contents);
+      break;
+
     case ModuleSubstreamKind::Lines: {
       // Holds a PC to file:line table.  Some data to parse this subsection is
       // stored in the other subsections, so just check sanity and store the
@@ -1701,6 +1714,31 @@ void COFFDumper::printCodeViewSymbolsSub
   }
 }
 
+void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
+  StringRef Data = Subsection;
+  while (!Data.empty()) {
+    DictScope S(W, "FileChecksum");
+    const FileChecksum *FC;
+    error(consumeObject(Data, FC));
+    if (FC->FileNameOffset >= CVStringTable.size())
+      error(object_error::parse_failed);
+    StringRef Filename =
+        CVStringTable.drop_front(FC->FileNameOffset).split('\0').first;
+    W.printHex("Filename", Filename, FC->FileNameOffset);
+    W.printHex("ChecksumSize", FC->ChecksumSize);
+    W.printEnum("ChecksumKind", uint8_t(FC->ChecksumKind),
+                makeArrayRef(FileChecksumKindNames));
+    if (FC->ChecksumSize >= Data.size())
+      error(object_error::parse_failed);
+    StringRef ChecksumBytes = Data.substr(0, FC->ChecksumSize);
+    W.printBinary("ChecksumBytes", ChecksumBytes);
+    unsigned PaddedSize =
+        RoundUpToAlignment(FC->ChecksumSize + sizeof(FileChecksum), 4) -
+        sizeof(FileChecksum);
+    Data = Data.drop_front(PaddedSize);
+  }
+}
+
 void COFFDumper::printCodeViewInlineeLines(StringRef Subsection) {
   StringRef Data = Subsection;
   uint32_t Signature;




More information about the llvm-commits mailing list