diff options
Diffstat (limited to 'tools/llvm-readobj')
-rw-r--r-- | tools/llvm-readobj/ARMAttributeParser.cpp | 2 | ||||
-rw-r--r-- | tools/llvm-readobj/ARMWinEHPrinter.cpp | 2 | ||||
-rw-r--r-- | tools/llvm-readobj/COFFDumper.cpp | 55 | ||||
-rw-r--r-- | tools/llvm-readobj/ELFDumper.cpp | 7 | ||||
-rw-r--r-- | tools/llvm-readobj/ObjDumper.h | 1 | ||||
-rw-r--r-- | tools/llvm-readobj/llvm-readobj.cpp | 17 | ||||
-rw-r--r-- | tools/llvm-readobj/llvm-readobj.h | 3 |
7 files changed, 68 insertions, 19 deletions
diff --git a/tools/llvm-readobj/ARMAttributeParser.cpp b/tools/llvm-readobj/ARMAttributeParser.cpp index d35cd14..e2d7191 100644 --- a/tools/llvm-readobj/ARMAttributeParser.cpp +++ b/tools/llvm-readobj/ARMAttributeParser.cpp @@ -141,7 +141,7 @@ void ARMAttributeParser::CPU_arch_profile(AttrType Tag, const uint8_t *Data, case 'R': Profile = "Real-time"; break; case 'M': Profile = "Microcontroller"; break; case 'S': Profile = "Classic"; break; - case '0': Profile = "None"; break; + case 0: Profile = "None"; break; } PrintAttribute(Tag, Encoded, Profile); diff --git a/tools/llvm-readobj/ARMWinEHPrinter.cpp b/tools/llvm-readobj/ARMWinEHPrinter.cpp index ede36d1..62252fc 100644 --- a/tools/llvm-readobj/ARMWinEHPrinter.cpp +++ b/tools/llvm-readobj/ARMWinEHPrinter.cpp @@ -64,8 +64,8 @@ #include "ARMWinEHPrinter.h" #include "Error.h" -#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/Support/ARMWinEH.h" #include "llvm/Support/Format.h" diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index 5276428..1412111 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -57,6 +57,7 @@ public: void printDynamicSymbols() override; void printUnwindInfo() override; void printCOFFImports() override; + void printCOFFExports() override; void printCOFFDirectives() override; void printCOFFBaseReloc() override; @@ -70,7 +71,7 @@ private: void printBaseOfDataField(const pe32_header *Hdr); void printBaseOfDataField(const pe32plus_header *Hdr); - void printCodeViewLineTables(const SectionRef &Section); + void printCodeViewDebugInfo(const SectionRef &Section); void printCodeViewSymbolsSubsection(StringRef Subsection, const SectionRef &Section, @@ -468,7 +469,7 @@ void COFFDumper::printBaseOfDataField(const pe32_header *Hdr) { void COFFDumper::printBaseOfDataField(const pe32plus_header *) {} -void COFFDumper::printCodeViewLineTables(const SectionRef &Section) { +void COFFDumper::printCodeViewDebugInfo(const SectionRef &Section) { StringRef Data; if (error(Section.getContents(Data))) return; @@ -476,7 +477,7 @@ void COFFDumper::printCodeViewLineTables(const SectionRef &Section) { SmallVector<StringRef, 10> FunctionNames; StringMap<StringRef> FunctionLineTables; - ListScope D(W, "CodeViewLineTables"); + ListScope D(W, "CodeViewDebugInfo"); { // FIXME: Add more offset correctness checks. DataExtractor DE(Data, true, 4); @@ -502,14 +503,17 @@ void COFFDumper::printCodeViewLineTables(const SectionRef &Section) { return; } - // Print the raw contents to simplify debugging if anything goes wrong - // afterwards. StringRef Contents = Data.substr(Offset, PayloadSize); - W.printBinaryBlock("Contents", Contents); + if (opts::CodeViewSubsectionBytes) { + // Print the raw contents to simplify debugging if anything goes wrong + // afterwards. + W.printBinaryBlock("Contents", Contents); + } switch (SubSectionType) { case COFF::DEBUG_SYMBOL_SUBSECTION: - printCodeViewSymbolsSubsection(Contents, Section, Offset); + if (opts::SectionSymbols) + printCodeViewSymbolsSubsection(Contents, Section, Offset); break; case COFF::DEBUG_LINE_TABLE_SUBSECTION: { // Holds a PC to file:line table. Some data to parse this subsection is @@ -694,10 +698,20 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection, InFunctionScope = false; break; } - default: + default: { + if (opts::CodeViewSubsectionBytes) { + ListScope S(W, "Record"); + W.printHex("Size", Size); + W.printHex("Type", Type); + + StringRef Contents = DE.getData().substr(Offset, Size); + W.printBinaryBlock("Contents", Contents); + } + Offset += Size; break; } + } } if (InFunctionScope) @@ -746,8 +760,8 @@ void COFFDumper::printSections() { } } - if (Name == ".debug$S" && opts::CodeViewLineTables) - printCodeViewLineTables(Sec); + if (Name == ".debug$S" && opts::CodeView) + printCodeViewDebugInfo(Sec); if (opts::SectionData && !(Section->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)) { @@ -1062,6 +1076,26 @@ void COFFDumper::printCOFFImports() { } } +void COFFDumper::printCOFFExports() { + for (const ExportDirectoryEntryRef &E : Obj->export_directories()) { + DictScope Export(W, "Export"); + + StringRef Name; + uint32_t Ordinal, RVA; + + if (error(E.getSymbolName(Name))) + continue; + if (error(E.getOrdinal(Ordinal))) + continue; + if (error(E.getExportRVA(RVA))) + continue; + + W.printNumber("Ordinal", Ordinal); + W.printString("Name", Name); + W.printHex("RVA", RVA); + } +} + void COFFDumper::printCOFFDirectives() { for (const SectionRef &Section : Obj->sections()) { StringRef Contents; @@ -1086,6 +1120,7 @@ static StringRef getBaseRelocTypeName(uint8_t Type) { case COFF::IMAGE_REL_BASED_LOW: return "LOW"; case COFF::IMAGE_REL_BASED_HIGHLOW: return "HIGHLOW"; case COFF::IMAGE_REL_BASED_HIGHADJ: return "HIGHADJ"; + case COFF::IMAGE_REL_BASED_ARM_MOV32T: return "ARM_MOV32(T)"; case COFF::IMAGE_REL_BASED_DIR64: return "DIR64"; default: return "unknown (" + llvm::utostr(Type) + ")"; } diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index d68c786..e4b7601 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -372,9 +372,10 @@ static const EnumEntry<unsigned> ElfMachineType[] = { }; static const EnumEntry<unsigned> ElfSymbolBindings[] = { - { "Local", ELF::STB_LOCAL }, - { "Global", ELF::STB_GLOBAL }, - { "Weak", ELF::STB_WEAK } + { "Local", ELF::STB_LOCAL }, + { "Global", ELF::STB_GLOBAL }, + { "Weak", ELF::STB_WEAK }, + { "Unique", ELF::STB_GNU_UNIQUE } }; static const EnumEntry<unsigned> ElfSymbolTypes[] = { diff --git a/tools/llvm-readobj/ObjDumper.h b/tools/llvm-readobj/ObjDumper.h index a34e091..27e658f 100644 --- a/tools/llvm-readobj/ObjDumper.h +++ b/tools/llvm-readobj/ObjDumper.h @@ -45,6 +45,7 @@ public: // Only implemented for PE/COFF. virtual void printCOFFImports() { } + virtual void printCOFFExports() { } virtual void printCOFFDirectives() { } virtual void printCOFFBaseReloc() { } diff --git a/tools/llvm-readobj/llvm-readobj.cpp b/tools/llvm-readobj/llvm-readobj.cpp index d08f186..f8f3086 100644 --- a/tools/llvm-readobj/llvm-readobj.cpp +++ b/tools/llvm-readobj/llvm-readobj.cpp @@ -127,9 +127,14 @@ namespace opts { cl::opt<bool> ExpandRelocs("expand-relocs", cl::desc("Expand each shown relocation to multiple lines")); - // -codeview-linetables - cl::opt<bool> CodeViewLineTables("codeview-linetables", - cl::desc("Display CodeView line table information")); + // -codeview + cl::opt<bool> CodeView("codeview", + cl::desc("Display CodeView debug information")); + + // -codeview-subsection-bytes + cl::opt<bool> CodeViewSubsectionBytes( + "codeview-subsection-bytes", + cl::desc("Dump raw contents of codeview debug sections and records")); // -arm-attributes, -a cl::opt<bool> ARMAttributes("arm-attributes", @@ -146,6 +151,10 @@ namespace opts { cl::opt<bool> COFFImports("coff-imports", cl::desc("Display the PE/COFF import table")); + // -coff-exports + cl::opt<bool> + COFFExports("coff-exports", cl::desc("Display the PE/COFF export table")); + // -coff-directives cl::opt<bool> COFFDirectives("coff-directives", @@ -282,6 +291,8 @@ static void dumpObject(const ObjectFile *Obj) { Dumper->printMipsPLTGOT(); if (opts::COFFImports) Dumper->printCOFFImports(); + if (opts::COFFExports) + Dumper->printCOFFExports(); if (opts::COFFDirectives) Dumper->printCOFFDirectives(); if (opts::COFFBaseRelocs) diff --git a/tools/llvm-readobj/llvm-readobj.h b/tools/llvm-readobj/llvm-readobj.h index 1c33417..74b9a60 100644 --- a/tools/llvm-readobj/llvm-readobj.h +++ b/tools/llvm-readobj/llvm-readobj.h @@ -36,7 +36,8 @@ namespace opts { extern llvm::cl::opt<bool> DynamicSymbols; extern llvm::cl::opt<bool> UnwindInfo; extern llvm::cl::opt<bool> ExpandRelocs; - extern llvm::cl::opt<bool> CodeViewLineTables; + extern llvm::cl::opt<bool> CodeView; + extern llvm::cl::opt<bool> CodeViewSubsectionBytes; extern llvm::cl::opt<bool> ARMAttributes; extern llvm::cl::opt<bool> MipsPLTGOT; } // namespace opts |