1 //===-- COFFImportDumper.cpp - COFF import library dumper -------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// This file implements the COFF import library dumper for llvm-readobj.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #include "llvm/BinaryFormat/COFF.h"
16 #include "llvm/Object/COFF.h"
17 #include "llvm/Object/COFFImportFile.h"
18 #include "llvm/Support/ScopedPrinter.h"
19
20 using namespace llvm::object;
21
22 namespace llvm {
23
dumpCOFFImportFile(const COFFImportFile * File,ScopedPrinter & Writer)24 void dumpCOFFImportFile(const COFFImportFile *File, ScopedPrinter &Writer) {
25 Writer.startLine() << '\n';
26 Writer.printString("File", File->getFileName());
27 Writer.printString("Format", "COFF-import-file");
28
29 const coff_import_header *H = File->getCOFFImportHeader();
30 switch (H->getType()) {
31 case COFF::IMPORT_CODE: Writer.printString("Type", "code"); break;
32 case COFF::IMPORT_DATA: Writer.printString("Type", "data"); break;
33 case COFF::IMPORT_CONST: Writer.printString("Type", "const"); break;
34 }
35
36 switch (H->getNameType()) {
37 case COFF::IMPORT_ORDINAL:
38 Writer.printString("Name type", "ordinal");
39 break;
40 case COFF::IMPORT_NAME:
41 Writer.printString("Name type", "name");
42 break;
43 case COFF::IMPORT_NAME_NOPREFIX:
44 Writer.printString("Name type", "noprefix");
45 break;
46 case COFF::IMPORT_NAME_UNDECORATE:
47 Writer.printString("Name type", "undecorate");
48 break;
49 }
50
51 for (const object::BasicSymbolRef &Sym : File->symbols()) {
52 raw_ostream &OS = Writer.startLine();
53 OS << "Symbol: ";
54 Sym.printName(OS);
55 OS << "\n";
56 }
57 }
58
59 } // namespace llvm
60