1 //===- COFFImportFile.h - COFF short import file implementation -*- 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 //===----------------------------------------------------------------------===//
10 // COFF short import file is a special kind of file which contains
11 // only symbol names for DLL-exported symbols. This class implements
12 // SymbolicFile interface for the file.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_OBJECT_COFF_IMPORT_FILE_H
17 #define LLVM_OBJECT_COFF_IMPORT_FILE_H
19 #include "llvm/Object/COFF.h"
20 #include "llvm/Object/IRObjectFile.h"
21 #include "llvm/Object/ObjectFile.h"
22 #include "llvm/Object/SymbolicFile.h"
23 #include "llvm/Support/MemoryBuffer.h"
28 class COFFImportFile : public SymbolicFile {
30 COFFImportFile(MemoryBufferRef Source)
31 : SymbolicFile(ID_COFFImportFile, Source) {}
33 static inline bool classof(Binary const *V) { return V->isCOFFImportFile(); }
35 void moveSymbolNext(DataRefImpl &Symb) const override { ++Symb.p; }
37 std::error_code printSymbolName(raw_ostream &OS,
38 DataRefImpl Symb) const override {
41 OS << StringRef(Data.getBufferStart() + sizeof(coff_import_header));
42 return std::error_code();
45 uint32_t getSymbolFlags(DataRefImpl Symb) const override {
46 return SymbolRef::SF_Global;
49 basic_symbol_iterator symbol_begin_impl() const override {
50 return BasicSymbolRef(DataRefImpl(), this);
53 basic_symbol_iterator symbol_end_impl() const override {
55 Symb.p = isCode() ? 2 : 1;
56 return BasicSymbolRef(Symb, this);
61 auto *Import = reinterpret_cast<const object::coff_import_header *>(
62 Data.getBufferStart());
63 return Import->getType() == COFF::IMPORT_CODE;