Coverage Report

Created: 2018-06-18 20:01

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/ELF/InputFiles.h
Line
Count
Source (jump to first uncovered line)
1
//===- InputFiles.h ---------------------------------------------*- C++ -*-===//
2
//
3
//                             The LLVM Linker
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLD_ELF_INPUT_FILES_H
11
#define LLD_ELF_INPUT_FILES_H
12
13
#include "Config.h"
14
#include "lld/Common/ErrorHandler.h"
15
#include "lld/Common/LLVM.h"
16
#include "lld/Common/Reproduce.h"
17
#include "llvm/ADT/CachedHashString.h"
18
#include "llvm/ADT/DenseSet.h"
19
#include "llvm/ADT/STLExtras.h"
20
#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
21
#include "llvm/IR/Comdat.h"
22
#include "llvm/Object/Archive.h"
23
#include "llvm/Object/ELF.h"
24
#include "llvm/Object/IRObjectFile.h"
25
#include "llvm/Support/Threading.h"
26
#include <map>
27
28
namespace llvm {
29
class TarWriter;
30
struct DILineInfo;
31
namespace lto {
32
class InputFile;
33
}
34
} // namespace llvm
35
36
namespace lld {
37
namespace elf {
38
class InputFile;
39
class InputSectionBase;
40
}
41
42
// Returns "<internal>", "foo.a(bar.o)" or "baz.o".
43
std::string toString(const elf::InputFile *F);
44
45
namespace elf {
46
47
using llvm::object::Archive;
48
49
class Symbol;
50
51
// If -reproduce option is given, all input files are written
52
// to this tar archive.
53
extern llvm::TarWriter *Tar;
54
55
// Opens a given file.
56
llvm::Optional<MemoryBufferRef> readFile(StringRef Path);
57
58
// The root class of input files.
59
class InputFile {
60
public:
61
  enum Kind {
62
    ObjKind,
63
    SharedKind,
64
    LazyObjKind,
65
    ArchiveKind,
66
    BitcodeKind,
67
    BinaryKind,
68
  };
69
70
37.4k
  Kind kind() const { return FileKind; }
71
72
3.79k
  bool isElf() const {
73
3.79k
    Kind K = kind();
74
3.79k
    return K == ObjKind || 
K == SharedKind872
;
75
3.79k
  }
76
77
133k
  StringRef getName() const { return MB.getBufferIdentifier(); }
78
  MemoryBufferRef MB;
79
80
  // Returns sections. It is a runtime error to call this function
81
  // on files that don't have the notion of sections.
82
3.25k
  ArrayRef<InputSectionBase *> getSections() const {
83
3.25k
    assert(FileKind == ObjKind || FileKind == BinaryKind);
84
3.25k
    return Sections;
85
3.25k
  }
86
87
  // Returns object file symbols. It is a runtime error to call this
88
  // function on files of other types.
89
2.33k
  ArrayRef<Symbol *> getSymbols() {
90
2.33k
    assert(FileKind == BinaryKind || FileKind == ObjKind ||
91
2.33k
           FileKind == BitcodeKind);
92
2.33k
    return Symbols;
93
2.33k
  }
94
95
  // Filename of .a which contained this file. If this file was
96
  // not in an archive file, it is the empty string. We use this
97
  // string for creating error messages.
98
  std::string ArchiveName;
99
100
  // If this is an architecture-specific file, the following members
101
  // have ELF type (i.e. ELF{32,64}{LE,BE}) and target machine type.
102
  ELFKind EKind = ELFNoneKind;
103
  uint16_t EMachine = llvm::ELF::EM_NONE;
104
  uint8_t OSABI = 0;
105
106
  // Cache for toString(). Only toString() should use this member.
107
  mutable std::string ToStringCache;
108
109
  std::string getSrcMsg(const Symbol &Sym, InputSectionBase &Sec,
110
                        uint64_t Offset);
111
112
  // True if this is an argument for --just-symbols. Usually false.
113
  bool JustSymbols = false;
114
115
  // GroupId is used for --warn-backrefs which is an optional error
116
  // checking feature. All files within the same --{start,end}-group or
117
  // --{start,end}-lib get the same group ID. Otherwise, each file gets a new
118
  // group ID. For more info, see checkDependency() in SymbolTable.cpp.
119
  uint32_t GroupId;
120
  static bool IsInGroup;
121
  static uint32_t NextGroupId;
122
123
  // Index of MIPS GOT built for this file.
124
  llvm::Optional<size_t> MipsGotIndex;
125
126
protected:
127
  InputFile(Kind K, MemoryBufferRef M);
128
  std::vector<InputSectionBase *> Sections;
129
  std::vector<Symbol *> Symbols;
130
131
private:
132
  const Kind FileKind;
133
};
134
135
template <typename ELFT> class ELFFileBase : public InputFile {
136
public:
137
  typedef typename ELFT::Shdr Elf_Shdr;
138
  typedef typename ELFT::Sym Elf_Sym;
139
  typedef typename ELFT::Word Elf_Word;
140
  typedef typename ELFT::SymRange Elf_Sym_Range;
141
142
  ELFFileBase(Kind K, MemoryBufferRef M);
143
509
  static bool classof(const InputFile *F) { return F->isElf(); }
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)1, false> >::classof(lld::elf::InputFile const*)
Line
Count
Source
143
44
  static bool classof(const InputFile *F) { return F->isElf(); }
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)0, false> >::classof(lld::elf::InputFile const*)
Line
Count
Source
143
364
  static bool classof(const InputFile *F) { return F->isElf(); }
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)1, true> >::classof(lld::elf::InputFile const*)
Line
Count
Source
143
6
  static bool classof(const InputFile *F) { return F->isElf(); }
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)0, true> >::classof(lld::elf::InputFile const*)
Line
Count
Source
143
95
  static bool classof(const InputFile *F) { return F->isElf(); }
144
145
444k
  llvm::object::ELFFile<ELFT> getObj() const {
146
444k
    return check(llvm::object::ELFFile<ELFT>::create(MB.getBuffer()));
147
444k
  }
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getObj() const
Line
Count
Source
145
422k
  llvm::object::ELFFile<ELFT> getObj() const {
146
422k
    return check(llvm::object::ELFFile<ELFT>::create(MB.getBuffer()));
147
422k
  }
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getObj() const
Line
Count
Source
145
6.56k
  llvm::object::ELFFile<ELFT> getObj() const {
146
6.56k
    return check(llvm::object::ELFFile<ELFT>::create(MB.getBuffer()));
147
6.56k
  }
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getObj() const
Line
Count
Source
145
3.91k
  llvm::object::ELFFile<ELFT> getObj() const {
146
3.91k
    return check(llvm::object::ELFFile<ELFT>::create(MB.getBuffer()));
147
3.91k
  }
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getObj() const
Line
Count
Source
145
11.9k
  llvm::object::ELFFile<ELFT> getObj() const {
146
11.9k
    return check(llvm::object::ELFFile<ELFT>::create(MB.getBuffer()));
147
11.9k
  }
148
149
84
  StringRef getStringTable() const { return StringTable; }
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getStringTable() const
Line
Count
Source
149
6
  StringRef getStringTable() const { return StringTable; }
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getStringTable() const
Line
Count
Source
149
6
  StringRef getStringTable() const { return StringTable; }
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getStringTable() const
Line
Count
Source
149
72
  StringRef getStringTable() const { return StringTable; }
Unexecuted instantiation: lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getStringTable() const
150
151
  uint32_t getSectionIndex(const Elf_Sym &Sym) const;
152
153
  Elf_Sym_Range getGlobalELFSyms();
154
86
  Elf_Sym_Range getELFSyms() const { return ELFSyms; }
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getELFSyms() const
Line
Count
Source
154
6
  Elf_Sym_Range getELFSyms() const { return ELFSyms; }
Unexecuted instantiation: lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getELFSyms() const
lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getELFSyms() const
Line
Count
Source
154
80
  Elf_Sym_Range getELFSyms() const { return ELFSyms; }
Unexecuted instantiation: lld::elf::ELFFileBase<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getELFSyms() const
155
156
protected:
157
  ArrayRef<Elf_Sym> ELFSyms;
158
  uint32_t FirstGlobal = 0;
159
  ArrayRef<Elf_Word> SymtabSHNDX;
160
  StringRef StringTable;
161
  void initSymtab(ArrayRef<Elf_Shdr> Sections, const Elf_Shdr *Symtab);
162
};
163
164
// .o file.
165
template <class ELFT> class ObjFile : public ELFFileBase<ELFT> {
166
  typedef ELFFileBase<ELFT> Base;
167
  typedef typename ELFT::Rel Elf_Rel;
168
  typedef typename ELFT::Rela Elf_Rela;
169
  typedef typename ELFT::Sym Elf_Sym;
170
  typedef typename ELFT::Shdr Elf_Shdr;
171
  typedef typename ELFT::Word Elf_Word;
172
173
  StringRef getShtGroupSignature(ArrayRef<Elf_Shdr> Sections,
174
                                 const Elf_Shdr &Sec);
175
  ArrayRef<Elf_Word> getShtGroupEntries(const Elf_Shdr &Sec);
176
177
public:
178
0
  static bool classof(const InputFile *F) { return F->kind() == Base::ObjKind; }
Unexecuted instantiation: lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::classof(lld::elf::InputFile const*)
Unexecuted instantiation: lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::classof(lld::elf::InputFile const*)
Unexecuted instantiation: lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::classof(lld::elf::InputFile const*)
Unexecuted instantiation: lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::classof(lld::elf::InputFile const*)
179
180
  ArrayRef<Symbol *> getLocalSymbols();
181
  ArrayRef<Symbol *> getGlobalSymbols();
182
183
  ObjFile(MemoryBufferRef M, StringRef ArchiveName);
184
  void parse(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups);
185
186
13.5k
  Symbol &getSymbol(uint32_t SymbolIndex) const {
187
13.5k
    if (SymbolIndex >= this->Symbols.size())
188
0
      fatal(toString(this) + ": invalid symbol index");
189
13.5k
    return *this->Symbols[SymbolIndex];
190
13.5k
  }
lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSymbol(unsigned int) const
Line
Count
Source
186
784
  Symbol &getSymbol(uint32_t SymbolIndex) const {
187
784
    if (SymbolIndex >= this->Symbols.size())
188
0
      fatal(toString(this) + ": invalid symbol index");
189
784
    return *this->Symbols[SymbolIndex];
190
784
  }
lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSymbol(unsigned int) const
Line
Count
Source
186
285
  Symbol &getSymbol(uint32_t SymbolIndex) const {
187
285
    if (SymbolIndex >= this->Symbols.size())
188
0
      fatal(toString(this) + ": invalid symbol index");
189
285
    return *this->Symbols[SymbolIndex];
190
285
  }
lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSymbol(unsigned int) const
Line
Count
Source
186
2.29k
  Symbol &getSymbol(uint32_t SymbolIndex) const {
187
2.29k
    if (SymbolIndex >= this->Symbols.size())
188
0
      fatal(toString(this) + ": invalid symbol index");
189
2.29k
    return *this->Symbols[SymbolIndex];
190
2.29k
  }
lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSymbol(unsigned int) const
Line
Count
Source
186
10.2k
  Symbol &getSymbol(uint32_t SymbolIndex) const {
187
10.2k
    if (SymbolIndex >= this->Symbols.size())
188
0
      fatal(toString(this) + ": invalid symbol index");
189
10.2k
    return *this->Symbols[SymbolIndex];
190
10.2k
  }
191
192
13.5k
  template <typename RelT> Symbol &getRelocTargetSym(const RelT &Rel) const {
193
13.5k
    uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL);
194
13.5k
    return getSymbol(SymIndex);
195
13.5k
  }
lld::elf::Symbol& lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocTargetSym<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> >(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, true> const&) const
Line
Count
Source
192
3
  template <typename RelT> Symbol &getRelocTargetSym(const RelT &Rel) const {
193
3
    uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL);
194
3
    return getSymbol(SymIndex);
195
3
  }
lld::elf::Symbol& lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getRelocTargetSym<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> >(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, false>, false> const&) const
Line
Count
Source
192
781
  template <typename RelT> Symbol &getRelocTargetSym(const RelT &Rel) const {
193
781
    uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL);
194
781
    return getSymbol(SymIndex);
195
781
  }
lld::elf::Symbol& lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocTargetSym<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> >(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, true> const&) const
Line
Count
Source
192
13
  template <typename RelT> Symbol &getRelocTargetSym(const RelT &Rel) const {
193
13
    uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL);
194
13
    return getSymbol(SymIndex);
195
13
  }
lld::elf::Symbol& lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getRelocTargetSym<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> >(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, false>, false> const&) const
Line
Count
Source
192
272
  template <typename RelT> Symbol &getRelocTargetSym(const RelT &Rel) const {
193
272
    uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL);
194
272
    return getSymbol(SymIndex);
195
272
  }
lld::elf::Symbol& lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocTargetSym<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> >(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, true> const&) const
Line
Count
Source
192
2.29k
  template <typename RelT> Symbol &getRelocTargetSym(const RelT &Rel) const {
193
2.29k
    uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL);
194
2.29k
    return getSymbol(SymIndex);
195
2.29k
  }
lld::elf::Symbol& lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getRelocTargetSym<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> >(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true>, false> const&) const
Line
Count
Source
192
2
  template <typename RelT> Symbol &getRelocTargetSym(const RelT &Rel) const {
193
2
    uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL);
194
2
    return getSymbol(SymIndex);
195
2
  }
lld::elf::Symbol& lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocTargetSym<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> >(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, true> const&) const
Line
Count
Source
192
10.2k
  template <typename RelT> Symbol &getRelocTargetSym(const RelT &Rel) const {
193
10.2k
    uint32_t SymIndex = Rel.getSymbol(Config->IsMips64EL);
194
10.2k
    return getSymbol(SymIndex);
195
10.2k
  }
Unexecuted instantiation: lld::elf::Symbol& lld::elf::ObjFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getRelocTargetSym<llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> >(llvm::object::Elf_Rel_Impl<llvm::object::ELFType<(llvm::support::endianness)0, true>, false> const&) const
196
197
  // Returns source line information for a given offset.
198
  // If no information is available, returns "".
199
  std::string getLineInfo(InputSectionBase *S, uint64_t Offset);
200
  llvm::Optional<llvm::DILineInfo> getDILineInfo(InputSectionBase *, uint64_t);
201
  llvm::Optional<std::pair<std::string, unsigned>> getVariableLoc(StringRef Name);
202
203
  // MIPS GP0 value defined by this file. This value represents the gp value
204
  // used to create the relocatable object and required to support
205
  // R_MIPS_GPREL16 / R_MIPS_GPREL32 relocations.
206
  uint32_t MipsGp0 = 0;
207
208
  // Name of source file obtained from STT_FILE symbol value,
209
  // or empty string if there is no such symbol in object file
210
  // symbol table.
211
  StringRef SourceFile;
212
213
private:
214
  void
215
  initializeSections(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups);
216
  void initializeSymbols();
217
  void initializeJustSymbols();
218
  void initializeDwarf();
219
  InputSectionBase *getRelocTarget(const Elf_Shdr &Sec);
220
  InputSectionBase *createInputSection(const Elf_Shdr &Sec);
221
  StringRef getSectionName(const Elf_Shdr &Sec);
222
223
  bool shouldMerge(const Elf_Shdr &Sec);
224
  Symbol *createSymbol(const Elf_Sym *Sym);
225
226
  // .shstrtab contents.
227
  StringRef SectionStringTable;
228
229
  // Debugging information to retrieve source file and line for error
230
  // reporting. Linker may find reasonable number of errors in a
231
  // single object file, so we cache debugging information in order to
232
  // parse it only once for each object file we link.
233
  std::unique_ptr<llvm::DWARFContext> Dwarf;
234
  std::vector<const llvm::DWARFDebugLine::LineTable *> LineTables;
235
  struct VarLoc {
236
    const llvm::DWARFDebugLine::LineTable *LT;
237
    unsigned File;
238
    unsigned Line;
239
  };
240
  llvm::DenseMap<StringRef, VarLoc> VariableLoc;
241
  llvm::once_flag InitDwarfLine;
242
};
243
244
// LazyObjFile is analogous to ArchiveFile in the sense that
245
// the file contains lazy symbols. The difference is that
246
// LazyObjFile wraps a single file instead of multiple files.
247
//
248
// This class is used for --start-lib and --end-lib options which
249
// instruct the linker to link object files between them with the
250
// archive file semantics.
251
class LazyObjFile : public InputFile {
252
public:
253
  LazyObjFile(MemoryBufferRef M, StringRef ArchiveName,
254
              uint64_t OffsetInArchive)
255
25
      : InputFile(LazyObjKind, M), OffsetInArchive(OffsetInArchive) {
256
25
    this->ArchiveName = ArchiveName;
257
25
  }
258
259
3.00k
  static bool classof(const InputFile *F) { return F->kind() == LazyObjKind; }
260
261
  template <class ELFT> void parse();
262
  MemoryBufferRef getBuffer();
263
  InputFile *fetch();
264
  bool AddedToLink = false;
265
266
private:
267
  template <class ELFT> void addElfSymbols();
268
269
  uint64_t OffsetInArchive;
270
};
271
272
// An ArchiveFile object represents a .a file.
273
class ArchiveFile : public InputFile {
274
public:
275
  explicit ArchiveFile(std::unique_ptr<Archive> &&File);
276
3.10k
  static bool classof(const InputFile *F) { return F->kind() == ArchiveKind; }
277
  template <class ELFT> void parse();
278
279
  // Pulls out an object file that contains a definition for Sym and
280
  // returns it. If the same file was instantiated before, this
281
  // function returns a nullptr (so we don't instantiate the same file
282
  // more than once.)
283
  InputFile *fetch(const Archive::Symbol &Sym);
284
285
private:
286
  std::unique_ptr<Archive> File;
287
  llvm::DenseSet<uint64_t> Seen;
288
};
289
290
class BitcodeFile : public InputFile {
291
public:
292
  BitcodeFile(MemoryBufferRef M, StringRef ArchiveName,
293
              uint64_t OffsetInArchive);
294
3.00k
  static bool classof(const InputFile *F) { return F->kind() == BitcodeKind; }
295
  template <class ELFT>
296
  void parse(llvm::DenseSet<llvm::CachedHashStringRef> &ComdatGroups);
297
  std::unique_ptr<llvm::lto::InputFile> Obj;
298
};
299
300
// .so file.
301
template <class ELFT> class SharedFile : public ELFFileBase<ELFT> {
302
  typedef ELFFileBase<ELFT> Base;
303
  typedef typename ELFT::Dyn Elf_Dyn;
304
  typedef typename ELFT::Shdr Elf_Shdr;
305
  typedef typename ELFT::Sym Elf_Sym;
306
  typedef typename ELFT::SymRange Elf_Sym_Range;
307
  typedef typename ELFT::Verdef Elf_Verdef;
308
  typedef typename ELFT::Versym Elf_Versym;
309
310
  const Elf_Shdr *VersymSec = nullptr;
311
  const Elf_Shdr *VerdefSec = nullptr;
312
313
public:
314
  std::vector<const Elf_Verdef *> Verdefs;
315
  std::string SoName;
316
317
4.73k
  static bool classof(const InputFile *F) {
318
4.73k
    return F->kind() == Base::SharedKind;
319
4.73k
  }
lld::elf::SharedFile<llvm::object::ELFType<(llvm::support::endianness)1, false> >::classof(lld::elf::InputFile const*)
Line
Count
Source
317
641
  static bool classof(const InputFile *F) {
318
641
    return F->kind() == Base::SharedKind;
319
641
  }
lld::elf::SharedFile<llvm::object::ELFType<(llvm::support::endianness)0, false> >::classof(lld::elf::InputFile const*)
Line
Count
Source
317
343
  static bool classof(const InputFile *F) {
318
343
    return F->kind() == Base::SharedKind;
319
343
  }
lld::elf::SharedFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::classof(lld::elf::InputFile const*)
Line
Count
Source
317
3.55k
  static bool classof(const InputFile *F) {
318
3.55k
    return F->kind() == Base::SharedKind;
319
3.55k
  }
lld::elf::SharedFile<llvm::object::ELFType<(llvm::support::endianness)0, true> >::classof(lld::elf::InputFile const*)
Line
Count
Source
317
199
  static bool classof(const InputFile *F) {
318
199
    return F->kind() == Base::SharedKind;
319
199
  }
320
321
  SharedFile(MemoryBufferRef M, StringRef DefaultSoName);
322
323
  void parseSoName();
324
  void parseRest();
325
  uint32_t getAlignment(ArrayRef<Elf_Shdr> Sections, const Elf_Sym &Sym);
326
  std::vector<const Elf_Verdef *> parseVerdefs();
327
  std::vector<uint32_t> parseVersyms();
328
329
  struct NeededVer {
330
    // The string table offset of the version name in the output file.
331
    size_t StrTab;
332
333
    // The version identifier for this version name.
334
    uint16_t Index;
335
  };
336
337
  // Mapping from Elf_Verdef data structures to information about Elf_Vernaux
338
  // data structures in the output file.
339
  std::map<const Elf_Verdef *, NeededVer> VerdefMap;
340
341
  // Used for --as-needed
342
  bool IsNeeded;
343
};
344
345
class BinaryFile : public InputFile {
346
public:
347
5
  explicit BinaryFile(MemoryBufferRef M) : InputFile(BinaryKind, M) {}
348
3.11k
  static bool classof(const InputFile *F) { return F->kind() == BinaryKind; }
349
  void parse();
350
};
351
352
InputFile *createObjectFile(MemoryBufferRef MB, StringRef ArchiveName = "",
353
                            uint64_t OffsetInArchive = 0);
354
InputFile *createSharedFile(MemoryBufferRef MB, StringRef DefaultSoName);
355
356
2.98k
inline bool isBitcode(MemoryBufferRef MB) {
357
2.98k
  return identify_magic(MB.getBuffer()) == llvm::file_magic::bitcode;
358
2.98k
}
359
360
std::string replaceThinLTOSuffix(StringRef Path);
361
362
extern std::vector<BinaryFile *> BinaryFiles;
363
extern std::vector<BitcodeFile *> BitcodeFiles;
364
extern std::vector<LazyObjFile *> LazyObjFiles;
365
extern std::vector<InputFile *> ObjectFiles;
366
extern std::vector<InputFile *> SharedFiles;
367
368
} // namespace elf
369
} // namespace lld
370
371
#endif