summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-readobj/COFFDumper.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-01-15 18:06:25 +0000
committerReid Kleckner <rnk@google.com>2016-01-15 18:06:25 +0000
commitc31f530cb709b5266480bc46dcc804b171eed3b5 (patch)
tree8f8697bab3288fd97283934fc2606a1a99d68e8f /llvm/tools/llvm-readobj/COFFDumper.cpp
parent7e38be912d0b6aa9f7925cf521a3f91f62179928 (diff)
downloadbcm5719-llvm-c31f530cb709b5266480bc46dcc804b171eed3b5.tar.gz
bcm5719-llvm-c31f530cb709b5266480bc46dcc804b171eed3b5.zip
[codeview] Dump the file checksum substream
llvm-svn: 257910
Diffstat (limited to 'llvm/tools/llvm-readobj/COFFDumper.cpp')
-rw-r--r--llvm/tools/llvm-readobj/COFFDumper.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index ba7ac9140b9..f0699cecfbd 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -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> FunctionOptionEnum[] = {
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::printCodeViewSymbolSection(StringRef SectionName,
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::printCodeViewSymbolsSubsection(StringRef Subsection,
}
}
+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;
OpenPOWER on IntegriCloud