return BasicSymbolRef(Symb, this);
}
+ const coff_import_header *getCOFFImportHeader() const {
+ return reinterpret_cast<const object::coff_import_header *>(
+ Data.getBufferStart());
+ }
+
private:
bool isCode() const {
- auto *Import = reinterpret_cast<const object::coff_import_header *>(
- Data.getBufferStart());
- return Import->getType() == COFF::IMPORT_CODE;
+ return getCOFFImportHeader()->getType() == COFF::IMPORT_CODE;
}
};
COFF-UNKNOWN-NEXT: ]
COFF-UNKNOWN-NEXT: }
-COFF-IMPORTLIB: Format: COFF-import-file
+COFF-IMPORTLIB: Format: COFF-import-file
+COFF-IMPORTLIB-NEXT: Type: code
+COFF-IMPORTLIB-NEXT: Name type: noprefix
+COFF-IMPORTLIB-NEXT: Symbol: _func
+COFF-IMPORTLIB-NEXT: Symbol: __imp__func
--- /dev/null
+//===-- COFFImportDumper.cpp - COFF import library dumper -------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// \brief This file implements the COFF import library dumper for llvm-readobj.
+///
+//===----------------------------------------------------------------------===//
+
+#include "Error.h"
+#include "ObjDumper.h"
+#include "llvm-readobj.h"
+#include "llvm/Object/COFF.h"
+#include "llvm/Object/COFFImportFile.h"
+#include "llvm/Support/COFF.h"
+
+using namespace llvm::object;
+
+namespace llvm {
+
+void dumpCOFFImportFile(const COFFImportFile *File) {
+ outs() << '\n';
+ outs() << "File: " << File->getFileName() << "\n";
+ outs() << "Format: COFF-import-file\n";
+
+ const coff_import_header *H = File->getCOFFImportHeader();
+ switch (H->getType()) {
+ case COFF::IMPORT_CODE: outs() << "Type: code\n"; break;
+ case COFF::IMPORT_DATA: outs() << "Type: data\n"; break;
+ case COFF::IMPORT_CONST: outs() << "Type: const\n"; break;
+ }
+
+ switch (H->getNameType()) {
+ case COFF::IMPORT_ORDINAL: outs() << "Name type: ordinal\n"; break;
+ case COFF::IMPORT_NAME: outs() << "Name type: name\n"; break;
+ case COFF::IMPORT_NAME_NOPREFIX: outs() << "Name type: noprefix\n"; break;
+ case COFF::IMPORT_NAME_UNDECORATE: outs() << "Name type: undecorate\n"; break;
+ }
+
+ for (const object::BasicSymbolRef &Sym : File->symbols()) {
+ outs() << "Symbol: ";
+ Sym.printName(outs());
+ outs() << "\n";
+ }
+}
+
+} // namespace llvm
Dumper->printStackMap();
}
-static void dumpCOFFImportFile(const COFFImportFile *File) {
- outs() << '\n';
- outs() << "File: " << File->getFileName() << "\n";
- outs() << "Format: COFF-import-file\n";
-}
-
/// @brief Dumps each object file in \a Arc;
static void dumpArchive(const Archive *Arc) {
for (const auto &Child : Arc->children()) {