diff options
Diffstat (limited to 'llvm/tools/llvm-readobj/COFFDumper.cpp')
-rw-r--r-- | llvm/tools/llvm-readobj/COFFDumper.cpp | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp index fccfd465c57..306ebf90b87 100644 --- a/llvm/tools/llvm-readobj/COFFDumper.cpp +++ b/llvm/tools/llvm-readobj/COFFDumper.cpp @@ -75,6 +75,7 @@ public: void printCOFFExports() override; void printCOFFDirectives() override; void printCOFFBaseReloc() override; + void printCOFFDebugDirectory() override; void printCodeViewDebugInfo() override; void mergeCodeViewTypes(llvm::codeview::MemoryTypeTableBuilder &CVTypes) override; @@ -475,6 +476,25 @@ static const EnumEntry<COFF::COMDATType> ImageCOMDATSelect[] = { { "Newest" , COFF::IMAGE_COMDAT_SELECT_NEWEST } }; +static const EnumEntry<COFF::DebugType> ImageDebugType[] = { + { "Unknown" , COFF::IMAGE_DEBUG_TYPE_UNKNOWN }, + { "COFF" , COFF::IMAGE_DEBUG_TYPE_COFF }, + { "CodeView" , COFF::IMAGE_DEBUG_TYPE_CODEVIEW }, + { "FPO" , COFF::IMAGE_DEBUG_TYPE_FPO }, + { "Misc" , COFF::IMAGE_DEBUG_TYPE_MISC }, + { "Exception" , COFF::IMAGE_DEBUG_TYPE_EXCEPTION }, + { "Fixup" , COFF::IMAGE_DEBUG_TYPE_FIXUP }, + { "OmapToSrc" , COFF::IMAGE_DEBUG_TYPE_OMAP_TO_SRC }, + { "OmapFromSrc", COFF::IMAGE_DEBUG_TYPE_OMAP_FROM_SRC }, + { "Borland" , COFF::IMAGE_DEBUG_TYPE_BORLAND }, + { "CLSID" , COFF::IMAGE_DEBUG_TYPE_CLSID }, + { "VCFeature" , COFF::IMAGE_DEBUG_TYPE_VC_FEATURE }, + { "POGO" , COFF::IMAGE_DEBUG_TYPE_POGO }, + { "ILTCG" , COFF::IMAGE_DEBUG_TYPE_ILTCG }, + { "MPX" , COFF::IMAGE_DEBUG_TYPE_MPX }, + { "NoTimestamp", COFF::IMAGE_DEBUG_TYPE_NO_TIMESTAMP }, +}; + static const EnumEntry<COFF::WeakExternalCharacteristics> WeakExternalCharacteristics[] = { { "NoLibrary", COFF::IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY }, @@ -643,8 +663,42 @@ void COFFDumper::printPEHeader(const PEHeader *Hdr) { "DelayImportDescriptor", "CLRRuntimeHeader", "Reserved" }; - for (uint32_t i = 0; i < Hdr->NumberOfRvaAndSize; ++i) { + for (uint32_t i = 0; i < Hdr->NumberOfRvaAndSize; ++i) printDataDirectory(i, directory[i]); + } +} + +void COFFDumper::printCOFFDebugDirectory() { + ListScope LS(W, "DebugDirectory"); + for (const debug_directory &D : Obj->debug_directories()) { + char FormattedTime[20] = {}; + time_t TDS = D.TimeDateStamp; + strftime(FormattedTime, 20, "%Y-%m-%d %H:%M:%S", gmtime(&TDS)); + DictScope S(W, "DebugEntry"); + W.printHex("Characteristics", D.Characteristics); + W.printHex("TimeDateStamp", FormattedTime, D.TimeDateStamp); + W.printHex("MajorVersion", D.MajorVersion); + W.printHex("MinorVersion", D.MinorVersion); + W.printEnum("Type", D.Type, makeArrayRef(ImageDebugType)); + W.printHex("SizeOfData", D.SizeOfData); + W.printHex("AddressOfRawData", D.AddressOfRawData); + W.printHex("PointerToRawData", D.PointerToRawData); + if (D.Type == COFF::IMAGE_DEBUG_TYPE_CODEVIEW) { + const debug_pdb_info *PDBInfo; + StringRef PDBFileName; + error(Obj->getDebugPDBInfo(&D, PDBInfo, PDBFileName)); + DictScope PDBScope(W, "PDBInfo"); + W.printHex("PDBSignature", PDBInfo->Signature); + W.printBinary("PDBGUID", makeArrayRef(PDBInfo->Guid)); + W.printNumber("PDBAge", PDBInfo->Age); + W.printString("PDBFileName", PDBFileName); + } else { + // FIXME: Type values of 12 and 13 are commonly observed but are not in + // the documented type enum. Figure out what they mean. + ArrayRef<uint8_t> RawData; + error( + Obj->getRvaAndSizeAsBytes(D.AddressOfRawData, D.SizeOfData, RawData)); + W.printBinaryBlock("RawData", RawData); } } } |