LLVM  5.0.0
COFFImportFile.h
Go to the documentation of this file.
1 //===- COFFImportFile.h - COFF short import file implementation -*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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 // exporting of Symbols to create libraries and a SymbolicFile
13 // interface for the file type.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef LLVM_OBJECT_COFF_IMPORT_FILE_H
18 #define LLVM_OBJECT_COFF_IMPORT_FILE_H
19 
20 #include "llvm/ADT/ArrayRef.h"
21 #include "llvm/Object/COFF.h"
23 #include "llvm/Object/ObjectFile.h"
27 
28 namespace llvm {
29 namespace object {
30 
31 class COFFImportFile : public SymbolicFile {
32 public:
34  : SymbolicFile(ID_COFFImportFile, Source) {}
35 
36  static bool classof(Binary const *V) { return V->isCOFFImportFile(); }
37 
38  void moveSymbolNext(DataRefImpl &Symb) const override { ++Symb.p; }
39 
40  std::error_code printSymbolName(raw_ostream &OS,
41  DataRefImpl Symb) const override {
42  if (Symb.p == 0)
43  OS << "__imp_";
45  return std::error_code();
46  }
47 
48  uint32_t getSymbolFlags(DataRefImpl Symb) const override {
49  return SymbolRef::SF_Global;
50  }
51 
53  return BasicSymbolRef(DataRefImpl(), this);
54  }
55 
56  basic_symbol_iterator symbol_end() const override {
57  DataRefImpl Symb;
58  Symb.p = isData() ? 1 : 2;
59  return BasicSymbolRef(Symb, this);
60  }
61 
63  return reinterpret_cast<const object::coff_import_header *>(
65  }
66 
67 private:
68  bool isData() const {
70  }
71 };
72 
74  std::string Name;
75  std::string ExtName;
76  std::string SymbolName;
77 
78  uint16_t Ordinal = 0;
79  bool Noname = false;
80  bool Data = false;
81  bool Private = false;
82  bool Constant = false;
83 
84  bool isWeak() {
85  return ExtName.size() && ExtName != Name;
86  }
87 
88  friend bool operator==(const COFFShortExport &L, const COFFShortExport &R) {
89  return L.Name == R.Name && L.ExtName == R.ExtName &&
90  L.Ordinal == R.Ordinal && L.Noname == R.Noname &&
91  L.Data == R.Data && L.Private == R.Private;
92  }
93 
94  friend bool operator!=(const COFFShortExport &L, const COFFShortExport &R) {
95  return !(L == R);
96  }
97 };
98 
100  StringRef Path,
103  bool MakeWeakAliases);
104 
105 } // namespace object
106 } // namespace llvm
107 
108 #endif
MachineLoop * L
const char * getBufferStart() const
Definition: MemoryBuffer.h:173
void moveSymbolNext(DataRefImpl &Symb) const override
MachineTypes Machine
uint32_t getSymbolFlags(DataRefImpl Symb) const override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
std::error_code printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
bool isCOFFImportFile() const
Definition: Binary.h:122
COFFImportFile(MemoryBufferRef Source)
This is an important base class in LLVM.
Definition: Constant.h:42
const coff_import_header * getCOFFImportHeader() const
friend bool operator==(const COFFShortExport &L, const COFFShortExport &R)
std::error_code writeImportLibrary(StringRef ImportName, StringRef Path, ArrayRef< COFFShortExport > Exports, COFF::MachineTypes Machine, bool MakeWeakAliases)
friend bool operator!=(const COFFShortExport &L, const COFFShortExport &R)
MemoryBufferRef Data
Definition: Binary.h:36
This is a value type class that represents a single symbol in the list of symbols in the object file...
Definition: SymbolicFile.h:99
StringRef ImportName
static bool classof(Binary const *V)
MachineTypes
Definition: COFF.h:94
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
basic_symbol_iterator symbol_begin() const override
basic_symbol_iterator symbol_end() const override