1 //===-- COFFImportDumper.cpp - COFF import library dumper -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file implements the COFF import library dumper for llvm-readobj.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/BinaryFormat/COFF.h"
16 #include "llvm/Object/COFF.h"
17 #include "llvm/Object/COFFImportFile.h"
18 #include "llvm/Support/ScopedPrinter.h"
20 using namespace llvm::object
;
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");
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;
36 switch (H
->getNameType()) {
37 case COFF::IMPORT_ORDINAL
:
38 Writer
.printString("Name type", "ordinal");
40 case COFF::IMPORT_NAME
:
41 Writer
.printString("Name type", "name");
43 case COFF::IMPORT_NAME_NOPREFIX
:
44 Writer
.printString("Name type", "noprefix");
46 case COFF::IMPORT_NAME_UNDECORATE
:
47 Writer
.printString("Name type", "undecorate");
51 for (const object::BasicSymbolRef
&Sym
: File
->symbols()) {
52 raw_ostream
&OS
= Writer
.startLine();