LLVM  9.0.0svn
COFFImportFile.h
Go to the documentation of this file.
1 //===- COFFImportFile.h - COFF short import file implementation -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // COFF short import file is a special kind of file which contains
10 // only symbol names for DLL-exported symbols. This class implements
11 // exporting of Symbols to create libraries and a SymbolicFile
12 // interface for the file type.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_OBJECT_COFF_IMPORT_FILE_H
17 #define LLVM_OBJECT_COFF_IMPORT_FILE_H
18 
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/Object/COFF.h"
22 #include "llvm/Object/ObjectFile.h"
26 
27 namespace llvm {
28 namespace object {
29 
30 class COFFImportFile : public SymbolicFile {
31 public:
33  : SymbolicFile(ID_COFFImportFile, Source) {}
34 
35  static bool classof(Binary const *V) { return V->isCOFFImportFile(); }
36 
37  void moveSymbolNext(DataRefImpl &Symb) const override { ++Symb.p; }
38 
39  Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override {
40  if (Symb.p == 0)
41  OS << "__imp_";
43  return Error::success();
44  }
45 
46  uint32_t getSymbolFlags(DataRefImpl Symb) const override {
47  return SymbolRef::SF_Global;
48  }
49 
51  return BasicSymbolRef(DataRefImpl(), this);
52  }
53 
54  basic_symbol_iterator symbol_end() const override {
55  DataRefImpl Symb;
56  Symb.p = isData() ? 1 : 2;
57  return BasicSymbolRef(Symb, this);
58  }
59 
61  return reinterpret_cast<const object::coff_import_header *>(
63  }
64 
65 private:
66  bool isData() const {
68  }
69 };
70 
72  std::string Name;
73  std::string ExtName;
74  std::string SymbolName;
75  std::string AliasTarget;
76 
77  uint16_t Ordinal = 0;
78  bool Noname = false;
79  bool Data = false;
80  bool Private = false;
81  bool Constant = false;
82 
83  friend bool operator==(const COFFShortExport &L, const COFFShortExport &R) {
84  return L.Name == R.Name && L.ExtName == R.ExtName &&
85  L.Ordinal == R.Ordinal && L.Noname == R.Noname &&
86  L.Data == R.Data && L.Private == R.Private;
87  }
88 
89  friend bool operator!=(const COFFShortExport &L, const COFFShortExport &R) {
90  return !(L == R);
91  }
92 };
93 
96  COFF::MachineTypes Machine, bool MinGW);
97 
98 } // namespace object
99 } // namespace llvm
100 
101 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
void moveSymbolNext(DataRefImpl &Symb) const override
MachineTypes
Definition: COFF.h:93
bool isCOFFImportFile() const
Definition: Binary.h:128
Error writeImportLibrary(StringRef ImportName, StringRef Path, ArrayRef< COFFShortExport > Exports, COFF::MachineTypes Machine, bool MinGW)
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:32
COFF::MachineTypes Machine
Definition: COFFYAML.cpp:365
COFFImportFile(MemoryBufferRef Source)
This is an important base class in LLVM.
Definition: Constant.h:41
friend bool operator==(const COFFShortExport &L, const COFFShortExport &R)
static ErrorSuccess success()
Create a success value.
Definition: Error.h:326
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
friend bool operator!=(const COFFShortExport &L, const COFFShortExport &R)
MemoryBufferRef Data
Definition: Binary.h:37
This is a value type class that represents a single symbol in the list of symbols in the object file...
Definition: SymbolicFile.h:98
static bool classof(Binary const *V)
const char * getBufferStart() const
Definition: MemoryBuffer.h:276
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
const coff_import_header * getCOFFImportHeader() const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
basic_symbol_iterator symbol_begin() const override
basic_symbol_iterator symbol_end() const override