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 /// \brief 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"
19 using namespace llvm::object;
23 void dumpCOFFImportFile(const COFFImportFile *File) {
25 outs() << "File: " << File->getFileName() << "\n";
26 outs() << "Format: COFF-import-file\n";
28 const coff_import_header *H = File->getCOFFImportHeader();
29 switch (H->getType()) {
30 case COFF::IMPORT_CODE: outs() << "Type: code\n"; break;
31 case COFF::IMPORT_DATA: outs() << "Type: data\n"; break;
32 case COFF::IMPORT_CONST: outs() << "Type: const\n"; break;
35 switch (H->getNameType()) {
36 case COFF::IMPORT_ORDINAL: outs() << "Name type: ordinal\n"; break;
37 case COFF::IMPORT_NAME: outs() << "Name type: name\n"; break;
38 case COFF::IMPORT_NAME_NOPREFIX: outs() << "Name type: noprefix\n"; break;
39 case COFF::IMPORT_NAME_UNDECORATE: outs() << "Name type: undecorate\n"; break;
42 for (const object::BasicSymbolRef &Sym : File->symbols()) {
44 Sym.printName(outs());