Coverage Report

Created: 2017-09-19 22:28

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/lld/COFF/Symbols.h
Line
Count
Source (jump to first uncovered line)
1
//===- Symbols.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_COFF_SYMBOLS_H
11
#define LLD_COFF_SYMBOLS_H
12
13
#include "Chunks.h"
14
#include "Config.h"
15
#include "Memory.h"
16
#include "lld/Core/LLVM.h"
17
#include "llvm/ADT/ArrayRef.h"
18
#include "llvm/Object/Archive.h"
19
#include "llvm/Object/COFF.h"
20
#include <atomic>
21
#include <memory>
22
#include <vector>
23
24
namespace lld {
25
namespace coff {
26
27
using llvm::object::Archive;
28
using llvm::object::COFFSymbolRef;
29
using llvm::object::coff_import_header;
30
using llvm::object::coff_symbol_generic;
31
32
class ArchiveFile;
33
class InputFile;
34
class ObjFile;
35
struct Symbol;
36
class SymbolTable;
37
38
// The base class for real symbol classes.
39
class SymbolBody {
40
public:
41
  enum Kind {
42
    // The order of these is significant. We start with the regular defined
43
    // symbols as those are the most prevelant and the zero tag is the cheapest
44
    // to set. Among the defined kinds, the lower the kind is preferred over
45
    // the higher kind when testing wether one symbol should take precedence
46
    // over another.
47
    DefinedRegularKind = 0,
48
    DefinedCommonKind,
49
    DefinedLocalImportKind,
50
    DefinedImportThunkKind,
51
    DefinedImportDataKind,
52
    DefinedAbsoluteKind,
53
    DefinedSyntheticKind,
54
55
    UndefinedKind,
56
    LazyKind,
57
58
    LastDefinedCOFFKind = DefinedCommonKind,
59
    LastDefinedKind = DefinedSyntheticKind,
60
  };
61
62
12.3k
  Kind kind() const { return static_cast<Kind>(SymbolKind); }
63
64
  // Returns true if this is an external symbol.
65
57
  bool isExternal() { return IsExternal; }
66
67
  // Returns the symbol name.
68
  StringRef getName();
69
70
  // Returns the file from which this symbol was created.
71
  InputFile *getFile();
72
73
  // Indicates that this symbol will be included in the final image. Only valid
74
  // after calling markLive.
75
  bool isLive() const;
76
77
  Symbol *symbol();
78
0
  const Symbol *symbol() const {
79
0
    return const_cast<SymbolBody *>(this)->symbol();
80
0
  }
81
82
protected:
83
  friend SymbolTable;
84
  explicit SymbolBody(Kind K, StringRef N = "")
85
      : SymbolKind(K), IsExternal(true), IsCOMDAT(false),
86
4.26k
        WrittenToSymtab(false), Name(N) {}
87
88
  const unsigned SymbolKind : 8;
89
  unsigned IsExternal : 1;
90
91
  // This bit is used by the \c DefinedRegular subclass.
92
  unsigned IsCOMDAT : 1;
93
94
public:
95
  // This bit is used by Writer::createSymbolAndStringTable() to prevent
96
  // symbols from being written to the symbol table more than once.
97
  unsigned WrittenToSymtab : 1;
98
99
protected:
100
  StringRef Name;
101
};
102
103
// The base class for any defined symbols, including absolute symbols,
104
// etc.
105
class Defined : public SymbolBody {
106
public:
107
3.81k
  Defined(Kind K, StringRef N) : SymbolBody(K, N) {}
108
109
1.02k
  static bool classof(const SymbolBody *S) {
110
1.02k
    return S->kind() <= LastDefinedKind;
111
1.02k
  }
112
113
  // Returns the RVA (relative virtual address) of this symbol. The
114
  // writer sets and uses RVAs.
115
  uint64_t getRVA();
116
117
  // Returns the chunk containing this symbol. Absolute symbols and __ImageBase
118
  // do not have chunks, so this may return null.
119
  Chunk *getChunk();
120
};
121
122
// Symbols defined via a COFF object file or bitcode file.  For COFF files, this
123
// stores a coff_symbol_generic*, and names of internal symbols are lazily
124
// loaded through that. For bitcode files, Sym is nullptr and the name is stored
125
// as a StringRef.
126
class DefinedCOFF : public Defined {
127
  friend SymbolBody;
128
public:
129
  DefinedCOFF(Kind K, InputFile *F, StringRef N, const coff_symbol_generic *S)
130
1.49k
      : Defined(K, N), File(F), Sym(S) {}
131
132
462
  static bool classof(const SymbolBody *S) {
133
462
    return S->kind() <= LastDefinedCOFFKind;
134
462
  }
135
136
0
  InputFile *getFile() { return File; }
137
138
  COFFSymbolRef getCOFFSymbol();
139
140
  InputFile *File;
141
142
protected:
143
  const coff_symbol_generic *Sym;
144
};
145
146
// Regular defined symbols read from object file symbol tables.
147
class DefinedRegular : public DefinedCOFF {
148
public:
149
  DefinedRegular(InputFile *F, StringRef N, bool IsCOMDAT,
150
                 bool IsExternal = false,
151
                 const coff_symbol_generic *S = nullptr,
152
                 SectionChunk *C = nullptr)
153
1.48k
      : DefinedCOFF(DefinedRegularKind, F, N, S), Data(C ? &C->Repl : nullptr) {
154
1.48k
    this->IsExternal = IsExternal;
155
1.48k
    this->IsCOMDAT = IsCOMDAT;
156
1.48k
  }
157
158
2.02k
  static bool classof(const SymbolBody *S) {
159
2.02k
    return S->kind() == DefinedRegularKind;
160
2.02k
  }
161
162
1.20k
  uint64_t getRVA() const { return (*Data)->getRVA() + Sym->Value; }
163
17
  bool isCOMDAT() const { return IsCOMDAT; }
164
2.10k
  SectionChunk *getChunk() const { return *Data; }
165
2
  uint32_t getValue() const { return Sym->Value; }
166
167
private:
168
  SectionChunk **Data;
169
};
170
171
class DefinedCommon : public DefinedCOFF {
172
public:
173
  DefinedCommon(InputFile *F, StringRef N, uint64_t Size,
174
                const coff_symbol_generic *S = nullptr,
175
                CommonChunk *C = nullptr)
176
10
      : DefinedCOFF(DefinedCommonKind, F, N, S), Data(C), Size(Size) {
177
10
    this->IsExternal = true;
178
10
  }
179
180
1
  static bool classof(const SymbolBody *S) {
181
1
    return S->kind() == DefinedCommonKind;
182
1
  }
183
184
13
  uint64_t getRVA() { return Data->getRVA(); }
185
10
  CommonChunk *getChunk() { return Data; }
186
187
private:
188
  friend SymbolTable;
189
0
  uint64_t getSize() const { return Size; }
190
  CommonChunk *Data;
191
  uint64_t Size;
192
};
193
194
// Absolute symbols.
195
class DefinedAbsolute : public Defined {
196
public:
197
  DefinedAbsolute(StringRef N, COFFSymbolRef S)
198
8
      : Defined(DefinedAbsoluteKind, N), VA(S.getValue()) {
199
8
    IsExternal = S.isExternal();
200
8
  }
201
202
  DefinedAbsolute(StringRef N, uint64_t V)
203
1.91k
      : Defined(DefinedAbsoluteKind, N), VA(V) {}
204
205
124
  static bool classof(const SymbolBody *S) {
206
124
    return S->kind() == DefinedAbsoluteKind;
207
124
  }
208
209
26
  uint64_t getRVA() { return VA - Config->ImageBase; }
210
2
  void setVA(uint64_t V) { VA = V; }
211
212
  // The sentinel absolute symbol section index. Section index relocations
213
  // against absolute symbols resolve to this 16 bit number, and it is the
214
  // largest valid section index plus one. This is written by the Writer.
215
  static uint16_t OutputSectionIndex;
216
0
  uint16_t getSecIdx() { return OutputSectionIndex; }
217
218
private:
219
  uint64_t VA;
220
};
221
222
// This symbol is used for linker-synthesized symbols like __ImageBase and
223
// __safe_se_handler_table.
224
class DefinedSynthetic : public Defined {
225
public:
226
  explicit DefinedSynthetic(StringRef Name, Chunk *C)
227
264
      : Defined(DefinedSyntheticKind, Name), C(C) {}
228
229
396
  static bool classof(const SymbolBody *S) {
230
396
    return S->kind() == DefinedSyntheticKind;
231
396
  }
232
233
  // A null chunk indicates that this is __ImageBase. Otherwise, this is some
234
  // other synthesized chunk, like SEHTableChunk.
235
16
  uint32_t getRVA() 
{ return C ? 16
C->getRVA()1
:
015
; }
236
56
  Chunk *getChunk() { return C; }
237
238
private:
239
  Chunk *C;
240
};
241
242
// This class represents a symbol defined in an archive file. It is
243
// created from an archive file header, and it knows how to load an
244
// object file from an archive to replace itself with a defined
245
// symbol. If the resolver finds both Undefined and Lazy for
246
// the same name, it will ask the Lazy to load a file.
247
class Lazy : public SymbolBody {
248
public:
249
  Lazy(ArchiveFile *F, const Archive::Symbol S)
250
210
      : SymbolBody(LazyKind, S.getName()), File(F), Sym(S) {}
251
252
852
  static bool classof(const SymbolBody *S) { return S->kind() == LazyKind; }
253
254
  ArchiveFile *File;
255
256
private:
257
  friend SymbolTable;
258
259
private:
260
  const Archive::Symbol Sym;
261
};
262
263
// Undefined symbols.
264
class Undefined : public SymbolBody {
265
public:
266
242
  explicit Undefined(StringRef N) : SymbolBody(UndefinedKind, N) {}
267
268
3.61k
  static bool classof(const SymbolBody *S) {
269
3.61k
    return S->kind() == UndefinedKind;
270
3.61k
  }
271
272
  // An undefined symbol can have a fallback symbol which gives an
273
  // undefined symbol a second chance if it would remain undefined.
274
  // If it remains undefined, it'll be replaced with whatever the
275
  // Alias pointer points to.
276
  SymbolBody *WeakAlias = nullptr;
277
278
  // If this symbol is external weak, try to resolve it to a defined
279
  // symbol by searching the chain of fallback symbols. Returns the symbol if
280
  // successful, otherwise returns null.
281
  Defined *getWeakAlias();
282
};
283
284
// Windows-specific classes.
285
286
// This class represents a symbol imported from a DLL. This has two
287
// names for internal use and external use. The former is used for
288
// name resolution, and the latter is used for the import descriptor
289
// table in an output. The former has "__imp_" prefix.
290
class DefinedImportData : public Defined {
291
public:
292
  DefinedImportData(StringRef N, ImportFile *F)
293
66
      : Defined(DefinedImportDataKind, N), File(F) {
294
66
  }
295
296
487
  static bool classof(const SymbolBody *S) {
297
487
    return S->kind() == DefinedImportDataKind;
298
487
  }
299
300
83
  uint64_t getRVA() { return File->Location->getRVA(); }
301
25
  Chunk *getChunk() { return File->Location; }
302
62
  void setLocation(Chunk *AddressTable) { File->Location = AddressTable; }
303
304
92
  StringRef getDLLName() { return File->DLLName; }
305
111
  StringRef getExternalName() { return File->ExternalName; }
306
57
  uint16_t getOrdinal() { return File->Hdr->OrdinalHint; }
307
308
  ImportFile *File;
309
};
310
311
// This class represents a symbol for a jump table entry which jumps
312
// to a function in a DLL. Linker are supposed to create such symbols
313
// without "__imp_" prefix for all function symbols exported from
314
// DLLs, so that you can call DLL functions as regular functions with
315
// a regular name. A function pointer is given as a DefinedImportData.
316
class DefinedImportThunk : public Defined {
317
public:
318
  DefinedImportThunk(StringRef Name, DefinedImportData *S, uint16_t Machine);
319
320
492
  static bool classof(const SymbolBody *S) {
321
492
    return S->kind() == DefinedImportThunkKind;
322
492
  }
323
324
84
  uint64_t getRVA() { return Data->getRVA(); }
325
147
  Chunk *getChunk() { return Data; }
326
327
  DefinedImportData *WrappedSym;
328
329
private:
330
  Chunk *Data;
331
};
332
333
// If you have a symbol "__imp_foo" in your object file, a symbol name
334
// "foo" becomes automatically available as a pointer to "__imp_foo".
335
// This class is for such automatically-created symbols.
336
// Yes, this is an odd feature. We didn't intend to implement that.
337
// This is here just for compatibility with MSVC.
338
class DefinedLocalImport : public Defined {
339
public:
340
  DefinedLocalImport(StringRef N, Defined *S)
341
2
      : Defined(DefinedLocalImportKind, N), Data(make<LocalImportChunk>(S)) {}
342
343
0
  static bool classof(const SymbolBody *S) {
344
0
    return S->kind() == DefinedLocalImportKind;
345
0
  }
346
347
2
  uint64_t getRVA() { return Data->getRVA(); }
348
4
  Chunk *getChunk() { return Data; }
349
350
private:
351
  LocalImportChunk *Data;
352
};
353
354
1.40k
inline uint64_t Defined::getRVA() {
355
1.40k
  switch (kind()) {
356
26
  case DefinedAbsoluteKind:
357
26
    return cast<DefinedAbsolute>(this)->getRVA();
358
16
  case DefinedSyntheticKind:
359
16
    return cast<DefinedSynthetic>(this)->getRVA();
360
83
  case DefinedImportDataKind:
361
83
    return cast<DefinedImportData>(this)->getRVA();
362
84
  case DefinedImportThunkKind:
363
84
    return cast<DefinedImportThunk>(this)->getRVA();
364
2
  case DefinedLocalImportKind:
365
2
    return cast<DefinedLocalImport>(this)->getRVA();
366
13
  case DefinedCommonKind:
367
13
    return cast<DefinedCommon>(this)->getRVA();
368
1.18k
  case DefinedRegularKind:
369
1.18k
    return cast<DefinedRegular>(this)->getRVA();
370
0
  case LazyKind:
371
0
  case UndefinedKind:
372
0
    llvm_unreachable("Cannot get the address for an undefined symbol.");
373
1.40k
  }
374
0
  
llvm_unreachable0
("unknown symbol kind");
375
1.40k
}
376
377
1.13k
inline Chunk *Defined::getChunk() {
378
1.13k
  switch (kind()) {
379
633
  case DefinedRegularKind:
380
633
    return cast<DefinedRegular>(this)->getChunk();
381
327
  case DefinedAbsoluteKind:
382
327
    return nullptr;
383
56
  case DefinedSyntheticKind:
384
56
    return cast<DefinedSynthetic>(this)->getChunk();
385
25
  case DefinedImportDataKind:
386
25
    return cast<DefinedImportData>(this)->getChunk();
387
86
  case DefinedImportThunkKind:
388
86
    return cast<DefinedImportThunk>(this)->getChunk();
389
2
  case DefinedLocalImportKind:
390
2
    return cast<DefinedLocalImport>(this)->getChunk();
391
9
  case DefinedCommonKind:
392
9
    return cast<DefinedCommon>(this)->getChunk();
393
0
  case LazyKind:
394
0
  case UndefinedKind:
395
0
    llvm_unreachable("Cannot get the chunk of an undefined symbol.");
396
1.13k
  }
397
0
  
llvm_unreachable0
("unknown symbol kind");
398
1.13k
}
399
400
// A real symbol object, SymbolBody, is usually stored within a Symbol. There's
401
// always one Symbol for each symbol name. The resolver updates the SymbolBody
402
// stored in the Body field of this object as it resolves symbols. Symbol also
403
// holds computed properties of symbol names.
404
struct Symbol {
405
  // True if this symbol was referenced by a regular (non-bitcode) object.
406
  unsigned IsUsedInRegularObj : 1;
407
408
  // True if we've seen both a lazy and an undefined symbol with this symbol
409
  // name, which means that we have enqueued an archive member load and should
410
  // not load any more archive members to resolve the same symbol.
411
  unsigned PendingArchiveLoad : 1;
412
413
  // This field is used to store the Symbol's SymbolBody. This instantiation of
414
  // AlignedCharArrayUnion gives us a struct with a char array field that is
415
  // large and aligned enough to store any derived class of SymbolBody.
416
  llvm::AlignedCharArrayUnion<
417
      DefinedRegular, DefinedCommon, DefinedAbsolute, DefinedSynthetic, Lazy,
418
      Undefined, DefinedImportData, DefinedImportThunk, DefinedLocalImport>
419
      Body;
420
421
6.04k
  SymbolBody *body() {
422
6.04k
    return reinterpret_cast<SymbolBody *>(Body.buffer);
423
6.04k
  }
424
0
  const SymbolBody *body() const { return const_cast<Symbol *>(this)->body(); }
425
};
426
427
template <typename T, typename... ArgT>
428
3.33k
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
3.33k
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
3.33k
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
3.33k
                "Body not aligned enough");
432
3.33k
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
3.33k
         "Not a SymbolBody");
434
3.33k
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
3.33k
}
void lld::coff::replaceBody<lld::coff::Undefined, llvm::StringRef>(lld::coff::Symbol*, llvm::StringRef&&)
Line
Count
Source
428
70
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
70
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
70
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
70
                "Body not aligned enough");
432
70
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
70
         "Not a SymbolBody");
434
70
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
70
}
void lld::coff::replaceBody<lld::coff::DefinedLocalImport, llvm::StringRef&, lld::coff::Defined*&>(lld::coff::Symbol*, llvm::StringRef&&&, lld::coff::Defined*&&&)
Line
Count
Source
428
2
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
2
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
2
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
2
                "Body not aligned enough");
432
2
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
2
         "Not a SymbolBody");
434
2
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
2
}
void lld::coff::replaceBody<lld::coff::DefinedAbsolute, llvm::StringRef&, int>(lld::coff::Symbol*, llvm::StringRef&&&, int&&)
Line
Count
Source
428
1
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
1
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
1
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
1
                "Body not aligned enough");
432
1
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
1
         "Not a SymbolBody");
434
1
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
1
}
void lld::coff::replaceBody<lld::coff::Undefined, llvm::StringRef&>(lld::coff::Symbol*, llvm::StringRef&&&)
Line
Count
Source
428
172
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
172
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
172
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
172
                "Body not aligned enough");
432
172
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
172
         "Not a SymbolBody");
434
172
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
172
}
void lld::coff::replaceBody<lld::coff::Lazy, lld::coff::ArchiveFile*&, llvm::object::Archive::Symbol const&>(lld::coff::Symbol*, lld::coff::ArchiveFile*&&&, llvm::object::Archive::Symbol const&&&)
Line
Count
Source
428
210
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
210
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
210
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
210
                "Body not aligned enough");
432
210
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
210
         "Not a SymbolBody");
434
210
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
210
}
void lld::coff::replaceBody<lld::coff::DefinedAbsolute, llvm::StringRef&, llvm::object::COFFSymbolRef&>(lld::coff::Symbol*, llvm::StringRef&&&, llvm::object::COFFSymbolRef&&&)
Line
Count
Source
428
6
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
6
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
6
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
6
                "Body not aligned enough");
432
6
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
6
         "Not a SymbolBody");
434
6
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
6
}
void lld::coff::replaceBody<lld::coff::DefinedAbsolute, llvm::StringRef&, unsigned long long&>(lld::coff::Symbol*, llvm::StringRef&&&, unsigned long long&&&)
Line
Count
Source
428
1.91k
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
1.91k
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
1.91k
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
1.91k
                "Body not aligned enough");
432
1.91k
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
1.91k
         "Not a SymbolBody");
434
1.91k
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
1.91k
}
void lld::coff::replaceBody<lld::coff::DefinedSynthetic, llvm::StringRef&, lld::coff::Chunk*&>(lld::coff::Symbol*, llvm::StringRef&&&, lld::coff::Chunk*&&&)
Line
Count
Source
428
262
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
262
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
262
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
262
                "Body not aligned enough");
432
262
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
262
         "Not a SymbolBody");
434
262
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
262
}
void lld::coff::replaceBody<lld::coff::DefinedRegular, lld::coff::InputFile*&, llvm::StringRef&, bool&, bool, llvm::object::coff_symbol_generic const*&, lld::coff::SectionChunk*&>(lld::coff::Symbol*, lld::coff::InputFile*&&&, llvm::StringRef&&&, bool&&&, bool&&, llvm::object::coff_symbol_generic const*&&&, lld::coff::SectionChunk*&&&)
Line
Count
Source
428
560
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
560
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
560
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
560
                "Body not aligned enough");
432
560
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
560
         "Not a SymbolBody");
434
560
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
560
}
void lld::coff::replaceBody<lld::coff::DefinedCommon, lld::coff::InputFile*&, llvm::StringRef&, unsigned long long&, llvm::object::coff_symbol_generic const*&, lld::coff::CommonChunk*&>(lld::coff::Symbol*, lld::coff::InputFile*&&&, llvm::StringRef&&&, unsigned long long&&&, llvm::object::coff_symbol_generic const*&&&, lld::coff::CommonChunk*&&&)
Line
Count
Source
428
10
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
10
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
10
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
10
                "Body not aligned enough");
432
10
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
10
         "Not a SymbolBody");
434
10
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
10
}
void lld::coff::replaceBody<lld::coff::DefinedImportData, llvm::StringRef&, lld::coff::ImportFile*&>(lld::coff::Symbol*, llvm::StringRef&&&, lld::coff::ImportFile*&&&)
Line
Count
Source
428
66
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
66
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
66
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
66
                "Body not aligned enough");
432
66
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
66
         "Not a SymbolBody");
434
66
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
66
}
void lld::coff::replaceBody<lld::coff::DefinedImportThunk, llvm::StringRef&, lld::coff::DefinedImportData*&, unsigned short&>(lld::coff::Symbol*, llvm::StringRef&&&, lld::coff::DefinedImportData*&&&, unsigned short&&&)
Line
Count
Source
428
63
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
63
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
63
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
63
                "Body not aligned enough");
432
63
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
63
         "Not a SymbolBody");
434
63
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
63
}
void lld::coff::replaceBody<lld::coff::DefinedSynthetic, llvm::StringRef, lld::coff::SEHTableChunk*&>(lld::coff::Symbol*, llvm::StringRef&&, lld::coff::SEHTableChunk*&&&)
Line
Count
Source
428
2
void replaceBody(Symbol *S, ArgT &&... Arg) {
429
2
  static_assert(sizeof(T) <= sizeof(S->Body), "Body too small");
430
2
  static_assert(alignof(T) <= alignof(decltype(S->Body)),
431
2
                "Body not aligned enough");
432
2
  assert(static_cast<SymbolBody *>(static_cast<T *>(nullptr)) == nullptr &&
433
2
         "Not a SymbolBody");
434
2
  new (S->Body.buffer) T(std::forward<ArgT>(Arg)...);
435
2
}
436
437
103
inline Symbol *SymbolBody::symbol() {
438
103
  assert(isExternal());
439
103
  return reinterpret_cast<Symbol *>(reinterpret_cast<char *>(this) -
440
103
                                    offsetof(Symbol, Body));
441
103
}
442
} // namespace coff
443
444
std::string toString(coff::SymbolBody &B);
445
} // namespace lld
446
447
#endif