llvm.org GIT mirror llvm / c2aa179
llvm-readobj: Dump more info for COFF import libraries. This patch teaches llvm-readobj to print out COFF import file header fields. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246291 91177308-0d34-0410-b5e6-96231b3b80d8 Rui Ueyama 5 years ago
6 changed file(s) with 68 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
5656 return BasicSymbolRef(Symb, this);
5757 }
5858
59 const coff_import_header *getCOFFImportHeader() const {
60 return reinterpret_cast(
61 Data.getBufferStart());
62 }
63
5964 private:
6065 bool isCode() const {
61 auto *Import = reinterpret_cast(
62 Data.getBufferStart());
63 return Import->getType() == COFF::IMPORT_CODE;
66 return getCOFFImportHeader()->getType() == COFF::IMPORT_CODE;
6467 }
6568 };
6669
329329 COFF-UNKNOWN-NEXT: ]
330330 COFF-UNKNOWN-NEXT: }
331331
332 COFF-IMPORTLIB: Format: COFF-import-file
332 COFF-IMPORTLIB: Format: COFF-import-file
333 COFF-IMPORTLIB-NEXT: Type: code
334 COFF-IMPORTLIB-NEXT: Name type: noprefix
335 COFF-IMPORTLIB-NEXT: Symbol: _func
336 COFF-IMPORTLIB-NEXT: Symbol: __imp__func
66 ARMAttributeParser.cpp
77 ARMWinEHPrinter.cpp
88 COFFDumper.cpp
9 COFFImportDumper.cpp
910 ELFDumper.cpp
1011 Error.cpp
1112 llvm-readobj.cpp
0 //===-- COFFImportDumper.cpp - COFF import library dumper -------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// \brief This file implements the COFF import library dumper for llvm-readobj.
11 ///
12 //===----------------------------------------------------------------------===//
13
14 #include "Error.h"
15 #include "ObjDumper.h"
16 #include "llvm-readobj.h"
17 #include "llvm/Object/COFF.h"
18 #include "llvm/Object/COFFImportFile.h"
19 #include "llvm/Support/COFF.h"
20
21 using namespace llvm::object;
22
23 namespace llvm {
24
25 void dumpCOFFImportFile(const COFFImportFile *File) {
26 outs() << '\n';
27 outs() << "File: " << File->getFileName() << "\n";
28 outs() << "Format: COFF-import-file\n";
29
30 const coff_import_header *H = File->getCOFFImportHeader();
31 switch (H->getType()) {
32 case COFF::IMPORT_CODE: outs() << "Type: code\n"; break;
33 case COFF::IMPORT_DATA: outs() << "Type: data\n"; break;
34 case COFF::IMPORT_CONST: outs() << "Type: const\n"; break;
35 }
36
37 switch (H->getNameType()) {
38 case COFF::IMPORT_ORDINAL: outs() << "Name type: ordinal\n"; break;
39 case COFF::IMPORT_NAME: outs() << "Name type: name\n"; break;
40 case COFF::IMPORT_NAME_NOPREFIX: outs() << "Name type: noprefix\n"; break;
41 case COFF::IMPORT_NAME_UNDECORATE: outs() << "Name type: undecorate\n"; break;
42 }
43
44 for (const object::BasicSymbolRef &Sym : File->symbols()) {
45 outs() << "Symbol: ";
46 Sym.printName(outs());
47 outs() << "\n";
48 }
49 }
50
51 } // namespace llvm
1414
1515 namespace llvm {
1616 namespace object {
17 class ObjectFile;
17 class COFFImportFile;
18 class ObjectFile;
1819 }
1920
2021 class StreamWriter;
7576 StreamWriter &Writer,
7677 std::unique_ptr &Result);
7778
79 void dumpCOFFImportFile(const object::COFFImportFile *File);
80
7881 } // namespace llvm
7982
8083 #endif
330330 Dumper->printStackMap();
331331 }
332332
333 static void dumpCOFFImportFile(const COFFImportFile *File) {
334 outs() << '\n';
335 outs() << "File: " << File->getFileName() << "\n";
336 outs() << "Format: COFF-import-file\n";
337 }
338
339333 /// @brief Dumps each object file in \a Arc;
340334 static void dumpArchive(const Archive *Arc) {
341335 for (const auto &Child : Arc->children()) {