Coverage Report

Created: 2019-05-19 14:56

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/ELF/SyntheticSections.h
Line
Count
Source (jump to first uncovered line)
1
//===- SyntheticSection.h ---------------------------------------*- 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
// Synthetic sections represent chunks of linker-created data. If you
10
// need to create a chunk of data that to be included in some section
11
// in the result, you probably want to create that as a synthetic section.
12
//
13
// Synthetic sections are designed as input sections as opposed to
14
// output sections because we want to allow them to be manipulated
15
// using linker scripts just like other input sections from regular
16
// files.
17
//
18
//===----------------------------------------------------------------------===//
19
20
#ifndef LLD_ELF_SYNTHETIC_SECTIONS_H
21
#define LLD_ELF_SYNTHETIC_SECTIONS_H
22
23
#include "DWARF.h"
24
#include "EhFrame.h"
25
#include "InputSection.h"
26
#include "llvm/ADT/MapVector.h"
27
#include "llvm/MC/StringTableBuilder.h"
28
#include "llvm/Support/Endian.h"
29
#include <functional>
30
31
namespace lld {
32
namespace elf {
33
class Defined;
34
35
class SyntheticSection : public InputSection {
36
public:
37
  SyntheticSection(uint64_t Flags, uint32_t Type, uint32_t Alignment,
38
                   StringRef Name)
39
      : InputSection(nullptr, Flags, Type, Alignment, {}, Name,
40
53.0k
                     InputSectionBase::Synthetic) {
41
53.0k
    this->Live = true;
42
53.0k
  }
43
44
53.0k
  virtual ~SyntheticSection() = default;
45
  virtual void writeTo(uint8_t *Buf) = 0;
46
  virtual size_t getSize() const = 0;
47
5.43k
  virtual void finalizeContents() {}
48
  // If the section has the SHF_ALLOC flag and the size may be changed if
49
  // thunks are added, update the section size.
50
2.51k
  virtual bool updateAllocSize() { return false; }
51
28.6k
  virtual bool isNeeded() const { return true; }
52
53
6.47M
  static bool classof(const SectionBase *D) {
54
6.47M
    return D->kind() == InputSectionBase::Synthetic;
55
6.47M
  }
56
};
57
58
struct CieRecord {
59
  EhSectionPiece *Cie = nullptr;
60
  std::vector<EhSectionPiece *> Fdes;
61
};
62
63
// Section for .eh_frame.
64
class EhFrameSection final : public SyntheticSection {
65
public:
66
  EhFrameSection();
67
  void writeTo(uint8_t *Buf) override;
68
  void finalizeContents() override;
69
7.11k
  bool isNeeded() const override { return !Sections.empty(); }
70
379
  size_t getSize() const override { return Size; }
71
72
  template <class ELFT> void addSection(InputSectionBase *S);
73
74
  std::vector<EhInputSection *> Sections;
75
  size_t NumFdes = 0;
76
77
  struct FdeData {
78
    uint32_t PcRel;
79
    uint32_t FdeVARel;
80
  };
81
82
  std::vector<FdeData> getFdeData() const;
83
4
  ArrayRef<CieRecord *> getCieRecords() const { return CieRecords; }
84
85
private:
86
  // This is used only when parsing EhInputSection. We keep it here to avoid
87
  // allocating one for each EhInputSection.
88
  llvm::DenseMap<size_t, CieRecord *> OffsetToCie;
89
90
  uint64_t Size = 0;
91
92
  template <class ELFT, class RelTy>
93
  void addSectionAux(EhInputSection *S, llvm::ArrayRef<RelTy> Rels);
94
95
  template <class ELFT, class RelTy>
96
  CieRecord *addCie(EhSectionPiece &Piece, ArrayRef<RelTy> Rels);
97
98
  template <class ELFT, class RelTy>
99
  bool isFdeLive(EhSectionPiece &Piece, ArrayRef<RelTy> Rels);
100
101
  uint64_t getFdePc(uint8_t *Buf, size_t Off, uint8_t Enc) const;
102
103
  std::vector<CieRecord *> CieRecords;
104
105
  // CIE records are uniquified by their contents and personality functions.
106
  llvm::DenseMap<std::pair<ArrayRef<uint8_t>, Symbol *>, CieRecord *> CieMap;
107
};
108
109
class GotSection : public SyntheticSection {
110
public:
111
  GotSection();
112
936
  size_t getSize() const override { return Size; }
113
  void finalizeContents() override;
114
  bool isNeeded() const override;
115
  void writeTo(uint8_t *Buf) override;
116
117
  void addEntry(Symbol &Sym);
118
  bool addDynTlsEntry(Symbol &Sym);
119
  bool addTlsIndex();
120
  uint64_t getGlobalDynAddr(const Symbol &B) const;
121
  uint64_t getGlobalDynOffset(const Symbol &B) const;
122
123
6
  uint64_t getTlsIndexVA() { return this->getVA() + TlsIndexOff; }
124
34
  uint32_t getTlsIndexOff() const { return TlsIndexOff; }
125
126
  // Flag to force GOT to be in output if we have relocations
127
  // that relies on its address.
128
  bool HasGotOffRel = false;
129
130
protected:
131
  size_t NumEntries = 0;
132
  uint32_t TlsIndexOff = -1;
133
  uint64_t Size = 0;
134
};
135
136
// .note.GNU-stack section.
137
class GnuStackSection : public SyntheticSection {
138
public:
139
  GnuStackSection()
140
82
      : SyntheticSection(0, llvm::ELF::SHT_PROGBITS, 1, ".note.GNU-stack") {}
141
82
  void writeTo(uint8_t *Buf) override {}
142
328
  size_t getSize() const override { return 0; }
143
};
144
145
// .note.gnu.build-id section.
146
class BuildIdSection : public SyntheticSection {
147
  // First 16 bytes are a header.
148
  static const unsigned HeaderSize = 16;
149
150
public:
151
  const size_t HashSize;
152
  BuildIdSection();
153
  void writeTo(uint8_t *Buf) override;
154
68
  size_t getSize() const override { return HeaderSize + HashSize; }
155
  void writeBuildId(llvm::ArrayRef<uint8_t> Buf);
156
157
private:
158
  uint8_t *HashBuf;
159
};
160
161
// BssSection is used to reserve space for copy relocations and common symbols.
162
// We create three instances of this class for .bss, .bss.rel.ro and "COMMON",
163
// that are used for writable symbols, read-only symbols and common symbols,
164
// respectively.
165
class BssSection final : public SyntheticSection {
166
public:
167
  BssSection(StringRef Name, uint64_t Size, uint32_t Alignment);
168
0
  void writeTo(uint8_t *) override {
169
0
    llvm_unreachable("unexpected writeTo() call for SHT_NOBITS section");
170
0
  }
171
9.73k
  bool isNeeded() const override { return Size != 0; }
172
592
  size_t getSize() const override { return Size; }
173
174
197k
  static bool classof(const SectionBase *S) { return S->Bss; }
175
  uint64_t Size;
176
};
177
178
class MipsGotSection final : public SyntheticSection {
179
public:
180
  MipsGotSection();
181
  void writeTo(uint8_t *Buf) override;
182
722
  size_t getSize() const override { return Size; }
183
  bool updateAllocSize() override;
184
  void finalizeContents() override;
185
  bool isNeeded() const override;
186
187
  // Join separate GOTs built for each input file to generate
188
  // primary and optional multiple secondary GOTs.
189
  void build();
190
191
  void addEntry(InputFile &File, Symbol &Sym, int64_t Addend, RelExpr Expr);
192
  void addDynTlsEntry(InputFile &File, Symbol &Sym);
193
  void addTlsIndex(InputFile &File);
194
195
  uint64_t getPageEntryOffset(const InputFile *F, const Symbol &S,
196
                              int64_t Addend) const;
197
  uint64_t getSymEntryOffset(const InputFile *F, const Symbol &S,
198
                             int64_t Addend) const;
199
  uint64_t getGlobalDynOffset(const InputFile *F, const Symbol &S) const;
200
  uint64_t getTlsIndexOffset(const InputFile *F) const;
201
202
  // Returns the symbol which corresponds to the first entry of the global part
203
  // of GOT on MIPS platform. It is required to fill up MIPS-specific dynamic
204
  // table properties.
205
  // Returns nullptr if the global part is empty.
206
  const Symbol *getFirstGlobalEntry() const;
207
208
  // Returns the number of entries in the local part of GOT including
209
  // the number of reserved entries.
210
  unsigned getLocalEntriesNum() const;
211
212
  // Return _gp value for primary GOT (nullptr) or particular input file.
213
  uint64_t getGp(const InputFile *F = nullptr) const;
214
215
private:
216
  // MIPS GOT consists of three parts: local, global and tls. Each part
217
  // contains different types of entries. Here is a layout of GOT:
218
  // - Header entries                |
219
  // - Page entries                  |   Local part
220
  // - Local entries (16-bit access) |
221
  // - Local entries (32-bit access) |
222
  // - Normal global entries         ||  Global part
223
  // - Reloc-only global entries     ||
224
  // - TLS entries                   ||| TLS part
225
  //
226
  // Header:
227
  //   Two entries hold predefined value 0x0 and 0x80000000.
228
  // Page entries:
229
  //   These entries created by R_MIPS_GOT_PAGE relocation and R_MIPS_GOT16
230
  //   relocation against local symbols. They are initialized by higher 16-bit
231
  //   of the corresponding symbol's value. So each 64kb of address space
232
  //   requires a single GOT entry.
233
  // Local entries (16-bit access):
234
  //   These entries created by GOT relocations against global non-preemptible
235
  //   symbols so dynamic linker is not necessary to resolve the symbol's
236
  //   values. "16-bit access" means that corresponding relocations address
237
  //   GOT using 16-bit index. Each unique Symbol-Addend pair has its own
238
  //   GOT entry.
239
  // Local entries (32-bit access):
240
  //   These entries are the same as above but created by relocations which
241
  //   address GOT using 32-bit index (R_MIPS_GOT_HI16/LO16 etc).
242
  // Normal global entries:
243
  //   These entries created by GOT relocations against preemptible global
244
  //   symbols. They need to be initialized by dynamic linker and they ordered
245
  //   exactly as the corresponding entries in the dynamic symbols table.
246
  // Reloc-only global entries:
247
  //   These entries created for symbols that are referenced by dynamic
248
  //   relocations R_MIPS_REL32. These entries are not accessed with gp-relative
249
  //   addressing, but MIPS ABI requires that these entries be present in GOT.
250
  // TLS entries:
251
  //   Entries created by TLS relocations.
252
  //
253
  // If the sum of local, global and tls entries is less than 64K only single
254
  // got is enough. Otherwise, multi-got is created. Series of primary and
255
  // multiple secondary GOTs have the following layout:
256
  // - Primary GOT
257
  //     Header
258
  //     Local entries
259
  //     Global entries
260
  //     Relocation only entries
261
  //     TLS entries
262
  //
263
  // - Secondary GOT
264
  //     Local entries
265
  //     Global entries
266
  //     TLS entries
267
  // ...
268
  //
269
  // All GOT entries required by relocations from a single input file entirely
270
  // belong to either primary or one of secondary GOTs. To reference GOT entries
271
  // each GOT has its own _gp value points to the "middle" of the GOT.
272
  // In the code this value loaded to the register which is used for GOT access.
273
  //
274
  // MIPS 32 function's prologue:
275
  //   lui     v0,0x0
276
  //   0: R_MIPS_HI16  _gp_disp
277
  //   addiu   v0,v0,0
278
  //   4: R_MIPS_LO16  _gp_disp
279
  //
280
  // MIPS 64:
281
  //   lui     at,0x0
282
  //   14: R_MIPS_GPREL16  main
283
  //
284
  // Dynamic linker does not know anything about secondary GOTs and cannot
285
  // use a regular MIPS mechanism for GOT entries initialization. So we have
286
  // to use an approach accepted by other architectures and create dynamic
287
  // relocations R_MIPS_REL32 to initialize global entries (and local in case
288
  // of PIC code) in secondary GOTs. But ironically MIPS dynamic linker
289
  // requires GOT entries and correspondingly ordered dynamic symbol table
290
  // entries to deal with dynamic relocations. To handle this problem
291
  // relocation-only section in the primary GOT contains entries for all
292
  // symbols referenced in global parts of secondary GOTs. Although the sum
293
  // of local and normal global entries of the primary got should be less
294
  // than 64K, the size of the primary got (including relocation-only entries
295
  // can be greater than 64K, because parts of the primary got that overflow
296
  // the 64K limit are used only by the dynamic linker at dynamic link-time
297
  // and not by 16-bit gp-relative addressing at run-time.
298
  //
299
  // For complete multi-GOT description see the following link
300
  // https://dmz-portal.mips.com/wiki/MIPS_Multi_GOT
301
302
  // Number of "Header" entries.
303
  static const unsigned HeaderEntriesNum = 2;
304
305
  uint64_t Size = 0;
306
307
  // Symbol and addend.
308
  using GotEntry = std::pair<Symbol *, int64_t>;
309
310
  struct FileGot {
311
    InputFile *File = nullptr;
312
    size_t StartIndex = 0;
313
314
    struct PageBlock {
315
      size_t FirstIndex;
316
      size_t Count;
317
25
      PageBlock() : FirstIndex(0), Count(0) {}
318
    };
319
320
    // Map output sections referenced by MIPS GOT relocations
321
    // to the description (index/count) "page" entries allocated
322
    // for this section.
323
    llvm::SmallMapVector<const OutputSection *, PageBlock, 16> PagesMap;
324
    // Maps from Symbol+Addend pair or just Symbol to the GOT entry index.
325
    llvm::MapVector<GotEntry, size_t> Local16;
326
    llvm::MapVector<GotEntry, size_t> Local32;
327
    llvm::MapVector<Symbol *, size_t> Global;
328
    llvm::MapVector<Symbol *, size_t> Relocs;
329
    llvm::MapVector<Symbol *, size_t> Tls;
330
    // Set of symbols referenced by dynamic TLS relocations.
331
    llvm::MapVector<Symbol *, size_t> DynTlsSymbols;
332
333
    // Total number of all entries.
334
    size_t getEntriesNum() const;
335
    // Number of "page" entries.
336
    size_t getPageEntriesNum() const;
337
    // Number of entries require 16-bit index to access.
338
    size_t getIndexedEntriesNum() const;
339
  };
340
341
  // Container of GOT created for each input file.
342
  // After building a final series of GOTs this container
343
  // holds primary and secondary GOT's.
344
  std::vector<FileGot> Gots;
345
346
  // Return (and create if necessary) `FileGot`.
347
  FileGot &getGot(InputFile &F);
348
349
  // Try to merge two GOTs. In case of success the `Dst` contains
350
  // result of merging and the function returns true. In case of
351
  // ovwerflow the `Dst` is unchanged and the function returns false.
352
  bool tryMergeGots(FileGot & Dst, FileGot & Src, bool IsPrimary);
353
};
354
355
class GotPltSection final : public SyntheticSection {
356
public:
357
  GotPltSection();
358
  void addEntry(Symbol &Sym);
359
  size_t getSize() const override;
360
  void writeTo(uint8_t *Buf) override;
361
  bool isNeeded() const override;
362
363
  // Flag to force GotPlt to be in output if we have relocations
364
  // that relies on its address.
365
  bool HasGotPltOffRel = false;
366
367
private:
368
  std::vector<const Symbol *> Entries;
369
};
370
371
// The IgotPltSection is a Got associated with the PltSection for GNU Ifunc
372
// Symbols that will be relocated by Target->IRelativeRel.
373
// On most Targets the IgotPltSection will immediately follow the GotPltSection
374
// on ARM the IgotPltSection will immediately follow the GotSection.
375
class IgotPltSection final : public SyntheticSection {
376
public:
377
  IgotPltSection();
378
  void addEntry(Symbol &Sym);
379
  size_t getSize() const override;
380
  void writeTo(uint8_t *Buf) override;
381
4.82k
  bool isNeeded() const override { return !Entries.empty(); }
382
383
private:
384
  std::vector<const Symbol *> Entries;
385
};
386
387
class StringTableSection final : public SyntheticSection {
388
public:
389
  StringTableSection(StringRef Name, bool Dynamic);
390
  unsigned addString(StringRef S, bool HashIt = true);
391
  void writeTo(uint8_t *Buf) override;
392
25.6k
  size_t getSize() const override { return Size; }
393
11.3k
  bool isDynamic() const { return Dynamic; }
394
395
private:
396
  const bool Dynamic;
397
398
  uint64_t Size = 0;
399
400
  llvm::DenseMap<StringRef, unsigned> StringMap;
401
  std::vector<StringRef> Strings;
402
};
403
404
class DynamicReloc {
405
public:
406
  DynamicReloc(RelType Type, const InputSectionBase *InputSec,
407
               uint64_t OffsetInSec, bool UseSymVA, Symbol *Sym, int64_t Addend)
408
      : Type(Type), Sym(Sym), InputSec(InputSec), OffsetInSec(OffsetInSec),
409
983
        UseSymVA(UseSymVA), Addend(Addend), OutputSec(nullptr) {}
410
  // This constructor records dynamic relocation settings used by MIPS
411
  // multi-GOT implementation. It's to relocate addresses of 64kb pages
412
  // lie inside the output section.
413
  DynamicReloc(RelType Type, const InputSectionBase *InputSec,
414
               uint64_t OffsetInSec, const OutputSection *OutputSec,
415
               int64_t Addend)
416
      : Type(Type), Sym(nullptr), InputSec(InputSec), OffsetInSec(OffsetInSec),
417
6
        UseSymVA(false), Addend(Addend), OutputSec(OutputSec) {}
418
419
  uint64_t getOffset() const;
420
  uint32_t getSymIndex() const;
421
422
  // Computes the addend of the dynamic relocation. Note that this is not the
423
  // same as the Addend member variable as it also includes the symbol address
424
  // if UseSymVA is true.
425
  int64_t computeAddend() const;
426
427
  RelType Type;
428
429
private:
430
  Symbol *Sym;
431
  const InputSectionBase *InputSec = nullptr;
432
  uint64_t OffsetInSec;
433
  // If this member is true, the dynamic relocation will not be against the
434
  // symbol but will instead be a relative relocation that simply adds the
435
  // load address. This means we need to write the symbol virtual address
436
  // plus the original addend as the final relocation addend.
437
  bool UseSymVA;
438
  int64_t Addend;
439
  const OutputSection *OutputSec;
440
};
441
442
template <class ELFT> class DynamicSection final : public SyntheticSection {
443
  using Elf_Dyn = typename ELFT::Dyn;
444
  using Elf_Rel = typename ELFT::Rel;
445
  using Elf_Rela = typename ELFT::Rela;
446
  using Elf_Relr = typename ELFT::Relr;
447
  using Elf_Shdr = typename ELFT::Shdr;
448
  using Elf_Sym = typename ELFT::Sym;
449
450
  // finalizeContents() fills this vector with the section contents.
451
  std::vector<std::pair<int32_t, std::function<uint64_t()>>> Entries;
452
453
public:
454
  DynamicSection();
455
  void finalizeContents() override;
456
  void writeTo(uint8_t *Buf) override;
457
4.75k
  size_t getSize() const override { return Size; }
lld::elf::DynamicSection<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSize() const
Line
Count
Source
457
666
  size_t getSize() const override { return Size; }
lld::elf::DynamicSection<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSize() const
Line
Count
Source
457
284
  size_t getSize() const override { return Size; }
lld::elf::DynamicSection<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSize() const
Line
Count
Source
457
3.56k
  size_t getSize() const override { return Size; }
lld::elf::DynamicSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSize() const
Line
Count
Source
457
242
  size_t getSize() const override { return Size; }
458
459
private:
460
  void add(int32_t Tag, std::function<uint64_t()> Fn);
461
  void addInt(int32_t Tag, uint64_t Val);
462
  void addInSec(int32_t Tag, InputSection *Sec);
463
  void addInSecRelative(int32_t Tag, InputSection *Sec);
464
  void addOutSec(int32_t Tag, OutputSection *Sec);
465
  void addSize(int32_t Tag, OutputSection *Sec);
466
  void addSym(int32_t Tag, Symbol *Sym);
467
468
  uint64_t Size = 0;
469
};
470
471
class RelocationBaseSection : public SyntheticSection {
472
public:
473
  RelocationBaseSection(StringRef Name, uint32_t Type, int32_t DynamicTag,
474
                        int32_t SizeDynamicTag);
475
  void addReloc(RelType DynType, InputSectionBase *IS, uint64_t OffsetInSec,
476
                Symbol *Sym);
477
  // Add a dynamic relocation that might need an addend. This takes care of
478
  // writing the addend to the output section if needed.
479
  void addReloc(RelType DynType, InputSectionBase *InputSec,
480
                uint64_t OffsetInSec, Symbol *Sym, int64_t Addend, RelExpr Expr,
481
                RelType Type);
482
  void addReloc(const DynamicReloc &Reloc);
483
14.3k
  bool isNeeded() const override { return !Relocs.empty(); }
484
2.63k
  size_t getSize() const override { return Relocs.size() * this->Entsize; }
485
229
  size_t getRelativeRelocCount() const { return NumRelativeRelocs; }
486
  void finalizeContents() override;
487
  int32_t DynamicTag, SizeDynamicTag;
488
489
protected:
490
  std::vector<DynamicReloc> Relocs;
491
  size_t NumRelativeRelocs = 0;
492
};
493
494
template <class ELFT>
495
class RelocationSection final : public RelocationBaseSection {
496
  using Elf_Rel = typename ELFT::Rel;
497
  using Elf_Rela = typename ELFT::Rela;
498
499
public:
500
  RelocationSection(StringRef Name, bool Sort);
501
  void writeTo(uint8_t *Buf) override;
502
503
private:
504
  bool Sort;
505
};
506
507
template <class ELFT>
508
class AndroidPackedRelocationSection final : public RelocationBaseSection {
509
  using Elf_Rel = typename ELFT::Rel;
510
  using Elf_Rela = typename ELFT::Rela;
511
512
public:
513
  AndroidPackedRelocationSection(StringRef Name);
514
515
  bool updateAllocSize() override;
516
30
  size_t getSize() const override { return RelocData.size(); }
lld::elf::AndroidPackedRelocationSection<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSize() const
Line
Count
Source
516
6
  size_t getSize() const override { return RelocData.size(); }
Unexecuted instantiation: lld::elf::AndroidPackedRelocationSection<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSize() const
lld::elf::AndroidPackedRelocationSection<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSize() const
Line
Count
Source
516
24
  size_t getSize() const override { return RelocData.size(); }
Unexecuted instantiation: lld::elf::AndroidPackedRelocationSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSize() const
517
5
  void writeTo(uint8_t *Buf) override {
518
5
    memcpy(Buf, RelocData.data(), RelocData.size());
519
5
  }
lld::elf::AndroidPackedRelocationSection<llvm::object::ELFType<(llvm::support::endianness)1, false> >::writeTo(unsigned char*)
Line
Count
Source
517
1
  void writeTo(uint8_t *Buf) override {
518
1
    memcpy(Buf, RelocData.data(), RelocData.size());
519
1
  }
Unexecuted instantiation: lld::elf::AndroidPackedRelocationSection<llvm::object::ELFType<(llvm::support::endianness)0, false> >::writeTo(unsigned char*)
lld::elf::AndroidPackedRelocationSection<llvm::object::ELFType<(llvm::support::endianness)1, true> >::writeTo(unsigned char*)
Line
Count
Source
517
4
  void writeTo(uint8_t *Buf) override {
518
4
    memcpy(Buf, RelocData.data(), RelocData.size());
519
4
  }
Unexecuted instantiation: lld::elf::AndroidPackedRelocationSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >::writeTo(unsigned char*)
520
521
private:
522
  SmallVector<char, 0> RelocData;
523
};
524
525
struct RelativeReloc {
526
164
  uint64_t getOffset() const { return InputSec->getVA(OffsetInSec); }
527
528
  const InputSectionBase *InputSec;
529
  uint64_t OffsetInSec;
530
};
531
532
class RelrBaseSection : public SyntheticSection {
533
public:
534
  RelrBaseSection();
535
8
  bool isNeeded() const override { return !Relocs.empty(); }
536
  std::vector<RelativeReloc> Relocs;
537
};
538
539
// RelrSection is used to encode offsets for relative relocations.
540
// Proposal for adding SHT_RELR sections to generic-abi is here:
541
//   https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg
542
// For more details, see the comment in RelrSection::updateAllocSize().
543
template <class ELFT> class RelrSection final : public RelrBaseSection {
544
  using Elf_Relr = typename ELFT::Relr;
545
546
public:
547
  RelrSection();
548
549
  bool updateAllocSize() override;
550
21
  size_t getSize() const override { return RelrRelocs.size() * this->Entsize; }
lld::elf::RelrSection<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSize() const
Line
Count
Source
550
14
  size_t getSize() const override { return RelrRelocs.size() * this->Entsize; }
Unexecuted instantiation: lld::elf::RelrSection<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSize() const
lld::elf::RelrSection<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSize() const
Line
Count
Source
550
7
  size_t getSize() const override { return RelrRelocs.size() * this->Entsize; }
Unexecuted instantiation: lld::elf::RelrSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSize() const
551
3
  void writeTo(uint8_t *Buf) override {
552
3
    memcpy(Buf, RelrRelocs.data(), getSize());
553
3
  }
lld::elf::RelrSection<llvm::object::ELFType<(llvm::support::endianness)1, false> >::writeTo(unsigned char*)
Line
Count
Source
551
2
  void writeTo(uint8_t *Buf) override {
552
2
    memcpy(Buf, RelrRelocs.data(), getSize());
553
2
  }
Unexecuted instantiation: lld::elf::RelrSection<llvm::object::ELFType<(llvm::support::endianness)0, false> >::writeTo(unsigned char*)
lld::elf::RelrSection<llvm::object::ELFType<(llvm::support::endianness)1, true> >::writeTo(unsigned char*)
Line
Count
Source
551
1
  void writeTo(uint8_t *Buf) override {
552
1
    memcpy(Buf, RelrRelocs.data(), getSize());
553
1
  }
Unexecuted instantiation: lld::elf::RelrSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >::writeTo(unsigned char*)
554
555
private:
556
  std::vector<Elf_Relr> RelrRelocs;
557
};
558
559
struct SymbolTableEntry {
560
  Symbol *Sym;
561
  size_t StrTabOffset;
562
};
563
564
class SymbolTableBaseSection : public SyntheticSection {
565
public:
566
  SymbolTableBaseSection(StringTableSection &StrTabSec);
567
  void finalizeContents() override;
568
14.6k
  size_t getSize() const override { return getNumSymbols() * Entsize; }
569
  void addSymbol(Symbol *Sym);
570
19.1k
  unsigned getNumSymbols() const { return Symbols.size() + 1; }
571
  size_t getSymbolIndex(Symbol *Sym);
572
1.44k
  ArrayRef<SymbolTableEntry> getSymbols() const { return Symbols; }
573
574
protected:
575
  void sortSymTabSymbols();
576
577
  // A vector of symbols and their string table offsets.
578
  std::vector<SymbolTableEntry> Symbols;
579
580
  StringTableSection &StrTabSec;
581
582
  llvm::once_flag OnceFlag;
583
  llvm::DenseMap<Symbol *, size_t> SymbolIndexMap;
584
  llvm::DenseMap<OutputSection *, size_t> SectionIndexMap;
585
};
586
587
template <class ELFT>
588
class SymbolTableSection final : public SymbolTableBaseSection {
589
  using Elf_Sym = typename ELFT::Sym;
590
591
public:
592
  SymbolTableSection(StringTableSection &StrTabSec);
593
  void writeTo(uint8_t *Buf) override;
594
};
595
596
class SymtabShndxSection final : public SyntheticSection {
597
public:
598
  SymtabShndxSection();
599
600
  void writeTo(uint8_t *Buf) override;
601
  size_t getSize() const override;
602
  bool isNeeded() const override;
603
  void finalizeContents() override;
604
};
605
606
// Outputs GNU Hash section. For detailed explanation see:
607
// https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections
608
class GnuHashTableSection final : public SyntheticSection {
609
public:
610
  GnuHashTableSection();
611
  void finalizeContents() override;
612
  void writeTo(uint8_t *Buf) override;
613
3.81k
  size_t getSize() const override { return Size; }
614
615
  // Adds symbols to the hash table.
616
  // Sorts the input to satisfy GNU hash section requirements.
617
  void addSymbols(std::vector<SymbolTableEntry> &Symbols);
618
619
private:
620
  // See the comment in writeBloomFilter.
621
  enum { Shift2 = 26 };
622
623
  void writeBloomFilter(uint8_t *Buf);
624
  void writeHashTable(uint8_t *Buf);
625
626
  struct Entry {
627
    Symbol *Sym;
628
    size_t StrTabOffset;
629
    uint32_t Hash;
630
    uint32_t BucketIdx;
631
  };
632
633
  std::vector<Entry> Symbols;
634
  size_t MaskWords;
635
  size_t NBuckets = 0;
636
  size_t Size = 0;
637
};
638
639
class HashTableSection final : public SyntheticSection {
640
public:
641
  HashTableSection();
642
  void finalizeContents() override;
643
  void writeTo(uint8_t *Buf) override;
644
4.72k
  size_t getSize() const override { return Size; }
645
646
private:
647
  size_t Size = 0;
648
};
649
650
// The PltSection is used for both the Plt and Iplt. The former usually has a
651
// header as its first entry that is used at run-time to resolve lazy binding.
652
// The latter is used for GNU Ifunc symbols, that will be subject to a
653
// Target->IRelativeRel.
654
class PltSection : public SyntheticSection {
655
public:
656
  PltSection(bool IsIplt);
657
  void writeTo(uint8_t *Buf) override;
658
  size_t getSize() const override;
659
14.7k
  bool isNeeded() const override { return !Entries.empty(); }
660
  void addSymbols();
661
  template <class ELFT> void addEntry(Symbol &Sym);
662
663
  size_t HeaderSize;
664
665
private:
666
  std::vector<const Symbol *> Entries;
667
  bool IsIplt;
668
};
669
670
class GdbIndexSection final : public SyntheticSection {
671
public:
672
  struct AddressEntry {
673
    InputSection *Section;
674
    uint64_t LowAddress;
675
    uint64_t HighAddress;
676
    uint32_t CuIndex;
677
  };
678
679
  struct CuEntry {
680
    uint64_t CuOffset;
681
    uint64_t CuLength;
682
  };
683
684
  struct NameAttrEntry {
685
    llvm::CachedHashStringRef Name;
686
    uint32_t CuIndexAndAttrs;
687
  };
688
689
  struct GdbChunk {
690
    InputSection *Sec;
691
    std::vector<AddressEntry> AddressAreas;
692
    std::vector<CuEntry> CompilationUnits;
693
  };
694
695
  struct GdbSymbol {
696
    llvm::CachedHashStringRef Name;
697
    std::vector<uint32_t> CuVector;
698
    uint32_t NameOff;
699
    uint32_t CuVectorOff;
700
  };
701
702
  GdbIndexSection();
703
  template <typename ELFT> static GdbIndexSection *create();
704
  void writeTo(uint8_t *Buf) override;
705
52
  size_t getSize() const override { return Size; }
706
  bool isNeeded() const override;
707
708
private:
709
  struct GdbIndexHeader {
710
    llvm::support::ulittle32_t Version;
711
    llvm::support::ulittle32_t CuListOff;
712
    llvm::support::ulittle32_t CuTypesOff;
713
    llvm::support::ulittle32_t AddressAreaOff;
714
    llvm::support::ulittle32_t SymtabOff;
715
    llvm::support::ulittle32_t ConstantPoolOff;
716
  };
717
718
  void initOutputSize();
719
  size_t computeSymtabSize() const;
720
721
  // Each chunk contains information gathered from debug sections of a
722
  // single object file.
723
  std::vector<GdbChunk> Chunks;
724
725
  // A symbol table for this .gdb_index section.
726
  std::vector<GdbSymbol> Symbols;
727
728
  size_t Size;
729
};
730
731
// --eh-frame-hdr option tells linker to construct a header for all the
732
// .eh_frame sections. This header is placed to a section named .eh_frame_hdr
733
// and also to a PT_GNU_EH_FRAME segment.
734
// At runtime the unwinder then can find all the PT_GNU_EH_FRAME segments by
735
// calling dl_iterate_phdr.
736
// This section contains a lookup table for quick binary search of FDEs.
737
// Detailed info about internals can be found in Ian Lance Taylor's blog:
738
// http://www.airs.com/blog/archives/460 (".eh_frame")
739
// http://www.airs.com/blog/archives/462 (".eh_frame_hdr")
740
class EhFrameHeader final : public SyntheticSection {
741
public:
742
  EhFrameHeader();
743
  void write();
744
  void writeTo(uint8_t *Buf) override;
745
  size_t getSize() const override;
746
  bool isNeeded() const override;
747
};
748
749
// For more information about .gnu.version and .gnu.version_r see:
750
// https://www.akkadia.org/drepper/symbol-versioning
751
752
// The .gnu.version_d section which has a section type of SHT_GNU_verdef shall
753
// contain symbol version definitions. The number of entries in this section
754
// shall be contained in the DT_VERDEFNUM entry of the .dynamic section.
755
// The section shall contain an array of Elf_Verdef structures, optionally
756
// followed by an array of Elf_Verdaux structures.
757
class VersionDefinitionSection final : public SyntheticSection {
758
public:
759
  VersionDefinitionSection();
760
  void finalizeContents() override;
761
  size_t getSize() const override;
762
  void writeTo(uint8_t *Buf) override;
763
764
private:
765
  enum { EntrySize = 28 };
766
  void writeOne(uint8_t *Buf, uint32_t Index, StringRef Name, size_t NameOff);
767
768
  unsigned FileDefNameOff;
769
};
770
771
// The .gnu.version section specifies the required version of each symbol in the
772
// dynamic symbol table. It contains one Elf_Versym for each dynamic symbol
773
// table entry. An Elf_Versym is just a 16-bit integer that refers to a version
774
// identifier defined in the either .gnu.version_r or .gnu.version_d section.
775
// The values 0 and 1 are reserved. All other values are used for versions in
776
// the own object or in any of the dependencies.
777
class VersionTableSection final : public SyntheticSection {
778
public:
779
  VersionTableSection();
780
  void finalizeContents() override;
781
  size_t getSize() const override;
782
  void writeTo(uint8_t *Buf) override;
783
  bool isNeeded() const override;
784
};
785
786
// The .gnu.version_r section defines the version identifiers used by
787
// .gnu.version. It contains a linked list of Elf_Verneed data structures. Each
788
// Elf_Verneed specifies the version requirements for a single DSO, and contains
789
// a reference to a linked list of Elf_Vernaux data structures which define the
790
// mapping from version identifiers to version names.
791
template <class ELFT>
792
class VersionNeedSection final : public SyntheticSection {
793
  using Elf_Verneed = typename ELFT::Verneed;
794
  using Elf_Vernaux = typename ELFT::Vernaux;
795
796
  struct Vernaux {
797
    uint64_t Hash;
798
    uint32_t VerneedIndex;
799
    uint64_t NameStrTab;
800
  };
801
802
  struct Verneed {
803
    uint64_t NameStrTab;
804
    std::vector<Vernaux> Vernauxs;
805
  };
806
807
  std::vector<Verneed> Verneeds;
808
809
public:
810
  VersionNeedSection();
811
  void finalizeContents() override;
812
  void writeTo(uint8_t *Buf) override;
813
  size_t getSize() const override;
814
  bool isNeeded() const override;
815
};
816
817
// MergeSyntheticSection is a class that allows us to put mergeable sections
818
// with different attributes in a single output sections. To do that
819
// we put them into MergeSyntheticSection synthetic input sections which are
820
// attached to regular output sections.
821
class MergeSyntheticSection : public SyntheticSection {
822
public:
823
  void addSection(MergeInputSection *MS);
824
  std::vector<MergeInputSection *> Sections;
825
826
protected:
827
  MergeSyntheticSection(StringRef Name, uint32_t Type, uint64_t Flags,
828
                        uint32_t Alignment)
829
2.52k
      : SyntheticSection(Flags, Type, Alignment, Name) {}
830
};
831
832
class MergeTailSection final : public MergeSyntheticSection {
833
public:
834
  MergeTailSection(StringRef Name, uint32_t Type, uint64_t Flags,
835
                   uint32_t Alignment);
836
837
  size_t getSize() const override;
838
  void writeTo(uint8_t *Buf) override;
839
  void finalizeContents() override;
840
841
private:
842
  llvm::StringTableBuilder Builder;
843
};
844
845
class MergeNoTailSection final : public MergeSyntheticSection {
846
public:
847
  MergeNoTailSection(StringRef Name, uint32_t Type, uint64_t Flags,
848
                     uint32_t Alignment)
849
2.51k
      : MergeSyntheticSection(Name, Type, Flags, Alignment) {}
850
851
9.80k
  size_t getSize() const override { return Size; }
852
  void writeTo(uint8_t *Buf) override;
853
  void finalizeContents() override;
854
855
private:
856
  // We use the most significant bits of a hash as a shard ID.
857
  // The reason why we don't want to use the least significant bits is
858
  // because DenseMap also uses lower bits to determine a bucket ID.
859
  // If we use lower bits, it significantly increases the probability of
860
  // hash collisons.
861
13.0k
  size_t getShardId(uint32_t Hash) {
862
13.0k
    assert((Hash >> 31) == 0);
863
13.0k
    return Hash >> (31 - llvm::countTrailingZeros(NumShards));
864
13.0k
  }
865
866
  // Section size
867
  size_t Size;
868
869
  // String table contents
870
  constexpr static size_t NumShards = 32;
871
  std::vector<llvm::StringTableBuilder> Shards;
872
  size_t ShardOffsets[NumShards];
873
};
874
875
// .MIPS.abiflags section.
876
template <class ELFT>
877
class MipsAbiFlagsSection final : public SyntheticSection {
878
  using Elf_Mips_ABIFlags = llvm::object::Elf_Mips_ABIFlags<ELFT>;
879
880
public:
881
  static MipsAbiFlagsSection *create();
882
883
  MipsAbiFlagsSection(Elf_Mips_ABIFlags Flags);
884
770
  size_t getSize() const override { return sizeof(Elf_Mips_ABIFlags); }
lld::elf::MipsAbiFlagsSection<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSize() const
Line
Count
Source
884
92
  size_t getSize() const override { return sizeof(Elf_Mips_ABIFlags); }
lld::elf::MipsAbiFlagsSection<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSize() const
Line
Count
Source
884
514
  size_t getSize() const override { return sizeof(Elf_Mips_ABIFlags); }
lld::elf::MipsAbiFlagsSection<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSize() const
Line
Count
Source
884
12
  size_t getSize() const override { return sizeof(Elf_Mips_ABIFlags); }
lld::elf::MipsAbiFlagsSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSize() const
Line
Count
Source
884
152
  size_t getSize() const override { return sizeof(Elf_Mips_ABIFlags); }
885
  void writeTo(uint8_t *Buf) override;
886
887
private:
888
  Elf_Mips_ABIFlags Flags;
889
};
890
891
// .MIPS.options section.
892
template <class ELFT> class MipsOptionsSection final : public SyntheticSection {
893
  using Elf_Mips_Options = llvm::object::Elf_Mips_Options<ELFT>;
894
  using Elf_Mips_RegInfo = llvm::object::Elf_Mips_RegInfo<ELFT>;
895
896
public:
897
  static MipsOptionsSection *create();
898
899
  MipsOptionsSection(Elf_Mips_RegInfo Reginfo);
900
  void writeTo(uint8_t *Buf) override;
901
902
205
  size_t getSize() const override {
903
205
    return sizeof(Elf_Mips_Options) + sizeof(Elf_Mips_RegInfo);
904
205
  }
Unexecuted instantiation: lld::elf::MipsOptionsSection<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSize() const
Unexecuted instantiation: lld::elf::MipsOptionsSection<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSize() const
lld::elf::MipsOptionsSection<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSize() const
Line
Count
Source
902
15
  size_t getSize() const override {
903
15
    return sizeof(Elf_Mips_Options) + sizeof(Elf_Mips_RegInfo);
904
15
  }
lld::elf::MipsOptionsSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSize() const
Line
Count
Source
902
190
  size_t getSize() const override {
903
190
    return sizeof(Elf_Mips_Options) + sizeof(Elf_Mips_RegInfo);
904
190
  }
905
906
private:
907
  Elf_Mips_RegInfo Reginfo;
908
};
909
910
// MIPS .reginfo section.
911
template <class ELFT> class MipsReginfoSection final : public SyntheticSection {
912
  using Elf_Mips_RegInfo = llvm::object::Elf_Mips_RegInfo<ELFT>;
913
914
public:
915
  static MipsReginfoSection *create();
916
917
  MipsReginfoSection(Elf_Mips_RegInfo Reginfo);
918
606
  size_t getSize() const override { return sizeof(Elf_Mips_RegInfo); }
lld::elf::MipsReginfoSection<llvm::object::ELFType<(llvm::support::endianness)1, false> >::getSize() const
Line
Count
Source
918
92
  size_t getSize() const override { return sizeof(Elf_Mips_RegInfo); }
lld::elf::MipsReginfoSection<llvm::object::ELFType<(llvm::support::endianness)0, false> >::getSize() const
Line
Count
Source
918
514
  size_t getSize() const override { return sizeof(Elf_Mips_RegInfo); }
Unexecuted instantiation: lld::elf::MipsReginfoSection<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSize() const
Unexecuted instantiation: lld::elf::MipsReginfoSection<llvm::object::ELFType<(llvm::support::endianness)0, true> >::getSize() const
919
  void writeTo(uint8_t *Buf) override;
920
921
private:
922
  Elf_Mips_RegInfo Reginfo;
923
};
924
925
// This is a MIPS specific section to hold a space within the data segment
926
// of executable file which is pointed to by the DT_MIPS_RLD_MAP entry.
927
// See "Dynamic section" in Chapter 5 in the following document:
928
// ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
929
class MipsRldMapSection : public SyntheticSection {
930
public:
931
  MipsRldMapSection();
932
116
  size_t getSize() const override { return Config->Wordsize; }
933
29
  void writeTo(uint8_t *Buf) override {}
934
};
935
936
// Representation of the combined .ARM.Exidx input sections. We process these
937
// as a SyntheticSection like .eh_frame as we need to merge duplicate entries
938
// and add terminating sentinel entries.
939
//
940
// The .ARM.exidx input sections after SHF_LINK_ORDER processing is done form
941
// a table that the unwinder can derive (Addresses are encoded as offsets from
942
// table):
943
// | Address of function | Unwind instructions for function |
944
// where the unwind instructions are either a small number of unwind or the
945
// special EXIDX_CANTUNWIND entry representing no unwinding information.
946
// When an exception is thrown from an address A, the unwinder searches the
947
// table for the closest table entry with Address of function <= A. This means
948
// that for two consecutive table entries:
949
// | A1 | U1 |
950
// | A2 | U2 |
951
// The range of addresses described by U1 is [A1, A2)
952
//
953
// There are two cases where we need a linker generated table entry to fixup
954
// the address ranges in the table
955
// Case 1:
956
// - A sentinel entry added with an address higher than all
957
// executable sections. This was needed to work around libunwind bug pr31091.
958
// - After address assignment we need to find the highest addressed executable
959
// section and use the limit of that section so that the unwinder never
960
// matches it.
961
// Case 2:
962
// - InputSections without a .ARM.exidx section (usually from Assembly)
963
// need a table entry so that they terminate the range of the previously
964
// function. This is pr40277.
965
//
966
// Instead of storing pointers to the .ARM.exidx InputSections from
967
// InputObjects, we store pointers to the executable sections that need
968
// .ARM.exidx sections. We can then use the dependentSections of these to
969
// either find the .ARM.exidx section or know that we need to generate one.
970
class ARMExidxSyntheticSection : public SyntheticSection {
971
public:
972
  ARMExidxSyntheticSection();
973
974
  // Add an input section to the ARMExidxSyntheticSection. Returns whether the
975
  // section needs to be removed from the main input section list.
976
  bool addSection(InputSection *IS);
977
978
96
  size_t getSize() const override { return Size; }
979
  void writeTo(uint8_t *Buf) override;
980
293
  bool isNeeded() const override { return !Empty; }
981
  // Sort and remove duplicate entries.
982
  void finalizeContents() override;
983
  InputSection *getLinkOrderDep() const;
984
985
  static bool classof(const SectionBase *D);
986
987
  // Links to the ARMExidxSections so we can transfer the relocations once the
988
  // layout is known.
989
  std::vector<InputSection *> ExidxSections;
990
991
private:
992
  size_t Size;
993
994
  // Empty if ExecutableSections contains no dependent .ARM.exidx sections.
995
  bool Empty = true;
996
997
  // Instead of storing pointers to the .ARM.exidx InputSections from
998
  // InputObjects, we store pointers to the executable sections that need
999
  // .ARM.exidx sections. We can then use the dependentSections of these to
1000
  // either find the .ARM.exidx section or know that we need to generate one.
1001
  std::vector<InputSection *> ExecutableSections;
1002
1003
  // The executable InputSection with the highest address to use for the
1004
  // sentinel. We store separately from ExecutableSections as merging of
1005
  // duplicate entries may mean this InputSection is removed from
1006
  // ExecutableSections.
1007
  InputSection *Sentinel = nullptr;
1008
};
1009
1010
// A container for one or more linker generated thunks. Instances of these
1011
// thunks including ARM interworking and Mips LA25 PI to non-PI thunks.
1012
class ThunkSection : public SyntheticSection {
1013
public:
1014
  // ThunkSection in OS, with desired OutSecOff of Off
1015
  ThunkSection(OutputSection *OS, uint64_t Off);
1016
1017
  // Add a newly created Thunk to this container:
1018
  // Thunk is given offset from start of this InputSection
1019
  // Thunk defines a symbol in this InputSection that can be used as target
1020
  // of a relocation
1021
  void addThunk(Thunk *T);
1022
1.69k
  size_t getSize() const override { return Size; }
1023
  void writeTo(uint8_t *Buf) override;
1024
  InputSection *getTargetInputSection() const;
1025
  bool assignOffsets();
1026
1027
private:
1028
  std::vector<Thunk *> Thunks;
1029
  size_t Size = 0;
1030
};
1031
1032
// This section is used to store the addresses of functions that are called
1033
// in range-extending thunks on PowerPC64. When producing position dependant
1034
// code the addresses are link-time constants and the table is written out to
1035
// the binary. When producing position-dependant code the table is allocated and
1036
// filled in by the dynamic linker.
1037
class PPC64LongBranchTargetSection final : public SyntheticSection {
1038
public:
1039
  PPC64LongBranchTargetSection();
1040
  void addEntry(Symbol &Sym);
1041
  size_t getSize() const override;
1042
  void writeTo(uint8_t *Buf) override;
1043
  bool isNeeded() const override;
1044
154
  void finalizeContents() override { Finalized = true; }
1045
1046
private:
1047
  std::vector<const Symbol *> Entries;
1048
  bool Finalized = false;
1049
};
1050
1051
InputSection *createInterpSection();
1052
MergeInputSection *createCommentSection();
1053
template <class ELFT> void splitSections();
1054
void mergeSections();
1055
1056
Defined *addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value,
1057
                           uint64_t Size, InputSectionBase &Section);
1058
1059
void addVerneed(Symbol *SS);
1060
1061
// Linker generated sections which can be used as inputs.
1062
struct InStruct {
1063
  InputSection *ARMAttributes;
1064
  ARMExidxSyntheticSection *ARMExidx;
1065
  BssSection *Bss;
1066
  BssSection *BssRelRo;
1067
  BuildIdSection *BuildId;
1068
  EhFrameHeader *EhFrameHdr;
1069
  EhFrameSection *EhFrame;
1070
  SyntheticSection *Dynamic;
1071
  StringTableSection *DynStrTab;
1072
  SymbolTableBaseSection *DynSymTab;
1073
  GnuHashTableSection *GnuHashTab;
1074
  HashTableSection *HashTab;
1075
  GotSection *Got;
1076
  GotPltSection *GotPlt;
1077
  IgotPltSection *IgotPlt;
1078
  PPC64LongBranchTargetSection *PPC64LongBranchTarget;
1079
  MipsGotSection *MipsGot;
1080
  MipsRldMapSection *MipsRldMap;
1081
  PltSection *Plt;
1082
  PltSection *Iplt;
1083
  RelocationBaseSection *RelaDyn;
1084
  RelrBaseSection *RelrDyn;
1085
  RelocationBaseSection *RelaPlt;
1086
  RelocationBaseSection *RelaIplt;
1087
  StringTableSection *ShStrTab;
1088
  StringTableSection *StrTab;
1089
  SymbolTableBaseSection *SymTab;
1090
  SymtabShndxSection *SymTabShndx;
1091
  VersionDefinitionSection *VerDef;
1092
  SyntheticSection *VerNeed;
1093
  VersionTableSection *VerSym;
1094
};
1095
1096
extern InStruct In;
1097
1098
} // namespace elf
1099
} // namespace lld
1100
1101
#endif