Path: blob/main/contrib/llvm-project/llvm/tools/llvm-readobj/COFFImportDumper.cpp
35231 views
//===-- COFFImportDumper.cpp - COFF import library dumper -------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7///8/// \file9/// This file implements the COFF import library dumper for llvm-readobj.10///11//===----------------------------------------------------------------------===//1213#include "llvm/BinaryFormat/COFF.h"14#include "llvm/Object/COFF.h"15#include "llvm/Object/COFFImportFile.h"16#include "llvm/Support/ScopedPrinter.h"1718using namespace llvm::object;1920namespace llvm {2122void dumpCOFFImportFile(const COFFImportFile *File, ScopedPrinter &Writer) {23Writer.startLine() << '\n';24Writer.printString("File", File->getFileName());25Writer.printString("Format", File->getFileFormatName());2627const coff_import_header *H = File->getCOFFImportHeader();28switch (H->getType()) {29case COFF::IMPORT_CODE: Writer.printString("Type", "code"); break;30case COFF::IMPORT_DATA: Writer.printString("Type", "data"); break;31case COFF::IMPORT_CONST: Writer.printString("Type", "const"); break;32}3334switch (H->getNameType()) {35case COFF::IMPORT_ORDINAL:36Writer.printString("Name type", "ordinal");37break;38case COFF::IMPORT_NAME:39Writer.printString("Name type", "name");40break;41case COFF::IMPORT_NAME_NOPREFIX:42Writer.printString("Name type", "noprefix");43break;44case COFF::IMPORT_NAME_UNDECORATE:45Writer.printString("Name type", "undecorate");46break;47case COFF::IMPORT_NAME_EXPORTAS:48Writer.printString("Name type", "export as");49break;50}5152if (H->getNameType() != COFF::IMPORT_ORDINAL)53Writer.printString("Export name", File->getExportName());5455for (const object::BasicSymbolRef &Sym : File->symbols()) {56raw_ostream &OS = Writer.startLine();57OS << "Symbol: ";58cantFail(Sym.printName(OS));59OS << "\n";60}61}6263} // namespace llvm646566