1 //===-- COFFImportDumper.cpp - COFF import library dumper -------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// This file implements the COFF import library dumper for llvm-readobj.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/BinaryFormat/COFF.h"
15 #include "llvm/Object/COFF.h"
16 #include "llvm/Object/COFFImportFile.h"
17 #include "llvm/Support/ScopedPrinter.h"
19 using namespace llvm::object
;
23 void dumpCOFFImportFile(const COFFImportFile
*File
, ScopedPrinter
&Writer
) {
24 Writer
.startLine() << '\n';
25 Writer
.printString("File", File
->getFileName());
26 Writer
.printString("Format", "COFF-import-file");
28 const coff_import_header
*H
= File
->getCOFFImportHeader();
29 switch (H
->getType()) {
30 case COFF::IMPORT_CODE
: Writer
.printString("Type", "code"); break;
31 case COFF::IMPORT_DATA
: Writer
.printString("Type", "data"); break;
32 case COFF::IMPORT_CONST
: Writer
.printString("Type", "const"); break;
35 switch (H
->getNameType()) {
36 case COFF::IMPORT_ORDINAL
:
37 Writer
.printString("Name type", "ordinal");
39 case COFF::IMPORT_NAME
:
40 Writer
.printString("Name type", "name");
42 case COFF::IMPORT_NAME_NOPREFIX
:
43 Writer
.printString("Name type", "noprefix");
45 case COFF::IMPORT_NAME_UNDECORATE
:
46 Writer
.printString("Name type", "undecorate");
50 for (const object::BasicSymbolRef
&Sym
: File
->symbols()) {
51 raw_ostream
&OS
= Writer
.startLine();
53 cantFail(Sym
.printName(OS
));