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"
24 #include "llvm/Support/raw_ostream.h"
29 class COFFImportFile : public SymbolicFile {
31 COFFImportFile(MemoryBufferRef Source)
32 : SymbolicFile(ID_COFFImportFile, Source) {}
34 static inline bool classof(Binary const *V) { return V->isCOFFImportFile(); }
36 void moveSymbolNext(DataRefImpl &Symb) const override { ++Symb.p; }
38 std::error_code printSymbolName(raw_ostream &OS,
39 DataRefImpl Symb) const override {
42 OS << StringRef(Data.getBufferStart() + sizeof(coff_import_header));
43 return std::error_code();
46 uint32_t getSymbolFlags(DataRefImpl Symb) const override {
47 return SymbolRef::SF_Global;
50 basic_symbol_iterator symbol_begin_impl() const override {
51 return BasicSymbolRef(DataRefImpl(), this);
54 basic_symbol_iterator symbol_end_impl() const override {
56 Symb.p = isCode() ? 2 : 1;
57 return BasicSymbolRef(Symb, this);
62 auto *Import = reinterpret_cast<const object::coff_import_header *>(
63 Data.getBufferStart());
64 return Import->getType() == COFF::IMPORT_CODE;