1 //===- OutputSections.h -----------------------------------------*- C++ -*-===//
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLD_ELF_OUTPUT_SECTIONS_H
11 #define LLD_ELF_OUTPUT_SECTIONS_H
14 #include "Relocations.h"
16 #include "lld/Core/LLVM.h"
17 #include "llvm/ADT/SmallPtrSet.h"
18 #include "llvm/MC/StringTableBuilder.h"
19 #include "llvm/Object/ELF.h"
20 #include "llvm/Support/MD5.h"
21 #include "llvm/Support/SHA1.h"
28 template <class ELFT> class SymbolTable;
29 template <class ELFT> class SymbolTableSection;
30 template <class ELFT> class StringTableSection;
31 template <class ELFT> class EhInputSection;
32 template <class ELFT> class InputSection;
33 template <class ELFT> class InputSectionBase;
34 template <class ELFT> class MergeInputSection;
35 template <class ELFT> class MipsReginfoInputSection;
36 template <class ELFT> class OutputSection;
37 template <class ELFT> class ObjectFile;
38 template <class ELFT> class SharedFile;
39 template <class ELFT> class SharedSymbol;
40 template <class ELFT> class DefinedRegular;
42 // This represents a section in an output file.
43 // Different sub classes represent different types of sections. Some contain
44 // input sections, others are created by the linker.
45 // The writer creates multiple OutputSections and assign them unique,
46 // non-overlapping file offsets and VAs.
47 template <class ELFT> class OutputSectionBase {
49 typedef typename ELFT::uint uintX_t;
50 typedef typename ELFT::Shdr Elf_Shdr;
52 OutputSectionBase(StringRef Name, uint32_t Type, uintX_t Flags);
53 void setVA(uintX_t VA) { Header.sh_addr = VA; }
54 uintX_t getVA() const { return Header.sh_addr; }
55 void setFileOffset(uintX_t Off) { Header.sh_offset = Off; }
56 void setSHName(unsigned Val) { Header.sh_name = Val; }
57 void writeHeaderTo(Elf_Shdr *SHdr);
58 StringRef getName() { return Name; }
60 virtual void addSection(InputSectionBase<ELFT> *C) {}
62 unsigned SectionIndex;
64 // Returns the size of the section in the output file.
65 uintX_t getSize() const { return Header.sh_size; }
66 void setSize(uintX_t Val) { Header.sh_size = Val; }
67 uintX_t getFlags() const { return Header.sh_flags; }
68 uintX_t getFileOff() const { return Header.sh_offset; }
69 uintX_t getAlignment() const { return Header.sh_addralign; }
70 uint32_t getType() const { return Header.sh_type; }
72 void updateAlignment(uintX_t Alignment) {
73 if (Alignment > Header.sh_addralign)
74 Header.sh_addralign = Alignment;
77 // If true, this section will be page aligned on disk.
78 // Typically the first section of each PT_LOAD segment has this flag.
79 bool PageAlign = false;
81 virtual void finalize() {}
82 virtual void finalizePieces() {}
83 virtual void assignOffsets() {}
84 virtual void writeTo(uint8_t *Buf) {}
85 virtual ~OutputSectionBase() = default;
92 template <class ELFT> class GotSection final : public OutputSectionBase<ELFT> {
93 typedef OutputSectionBase<ELFT> Base;
94 typedef typename ELFT::uint uintX_t;
98 void finalize() override;
99 void writeTo(uint8_t *Buf) override;
100 void addEntry(SymbolBody &Sym);
101 void addMipsEntry(SymbolBody &Sym, uintX_t Addend, RelExpr Expr);
102 bool addDynTlsEntry(SymbolBody &Sym);
104 bool empty() const { return MipsPageEntries == 0 && Entries.empty(); }
105 uintX_t getMipsLocalPageOffset(uintX_t Addr);
106 uintX_t getMipsGotOffset(const SymbolBody &B, uintX_t Addend) const;
107 uintX_t getGlobalDynAddr(const SymbolBody &B) const;
108 uintX_t getGlobalDynOffset(const SymbolBody &B) const;
109 uintX_t getNumEntries() const { return Entries.size(); }
111 // Returns the symbol which corresponds to the first entry of the global part
112 // of GOT on MIPS platform. It is required to fill up MIPS-specific dynamic
114 // Returns nullptr if the global part is empty.
115 const SymbolBody *getMipsFirstGlobalEntry() const;
117 // Returns the number of entries in the local part of GOT including
118 // the number of reserved entries. This method is MIPS-specific.
119 unsigned getMipsLocalEntriesNum() const;
121 // Returns offset of TLS part of the MIPS GOT table. This part goes
122 // after 'local' and 'global' entries.
123 uintX_t getMipsTlsOffset();
125 uintX_t getTlsIndexVA() { return Base::getVA() + TlsIndexOff; }
126 uint32_t getTlsIndexOff() { return TlsIndexOff; }
128 // Flag to force GOT to be in output if we have relocations
129 // that relies on its address.
130 bool HasGotOffRel = false;
133 std::vector<const SymbolBody *> Entries;
134 uint32_t TlsIndexOff = -1;
135 uint32_t MipsPageEntries = 0;
136 // Output sections referenced by MIPS GOT relocations.
137 llvm::SmallPtrSet<const OutputSectionBase<ELFT> *, 10> MipsOutSections;
138 llvm::DenseMap<uintX_t, size_t> MipsLocalGotPos;
140 // MIPS ABI requires to create unique GOT entry for each Symbol/Addend
141 // pairs. The `MipsGotMap` maps (S,A) pair to the GOT index in the `MipsLocal`
142 // or `MipsGlobal` vectors. In general it does not have a sence to take in
143 // account addend for preemptible symbols because the corresponding
144 // GOT entries should have one-to-one mapping with dynamic symbols table.
145 // But we use the same container's types for both kind of GOT entries
146 // to handle them uniformly.
147 typedef std::pair<const SymbolBody*, uintX_t> MipsGotEntry;
148 typedef std::vector<MipsGotEntry> MipsGotEntries;
149 llvm::DenseMap<MipsGotEntry, size_t> MipsGotMap;
150 MipsGotEntries MipsLocal;
151 MipsGotEntries MipsGlobal;
153 // Write MIPS-specific parts of the GOT.
154 void writeMipsGot(uint8_t *&Buf);
157 template <class ELFT>
158 class GotPltSection final : public OutputSectionBase<ELFT> {
159 typedef typename ELFT::uint uintX_t;
163 void finalize() override;
164 void writeTo(uint8_t *Buf) override;
165 void addEntry(SymbolBody &Sym);
169 std::vector<const SymbolBody *> Entries;
172 template <class ELFT> class PltSection final : public OutputSectionBase<ELFT> {
173 typedef OutputSectionBase<ELFT> Base;
174 typedef typename ELFT::uint uintX_t;
178 void finalize() override;
179 void writeTo(uint8_t *Buf) override;
180 void addEntry(SymbolBody &Sym);
181 bool empty() const { return Entries.empty(); }
184 std::vector<std::pair<const SymbolBody *, unsigned>> Entries;
187 template <class ELFT> class DynamicReloc {
188 typedef typename ELFT::uint uintX_t;
191 DynamicReloc(uint32_t Type, const InputSectionBase<ELFT> *InputSec,
192 uintX_t OffsetInSec, bool UseSymVA, SymbolBody *Sym,
194 : Type(Type), Sym(Sym), InputSec(InputSec), OffsetInSec(OffsetInSec),
195 UseSymVA(UseSymVA), Addend(Addend) {}
197 DynamicReloc(uint32_t Type, const OutputSectionBase<ELFT> *OutputSec,
198 uintX_t OffsetInSec, bool UseSymVA, SymbolBody *Sym,
200 : Type(Type), Sym(Sym), OutputSec(OutputSec), OffsetInSec(OffsetInSec),
201 UseSymVA(UseSymVA), Addend(Addend) {}
203 uintX_t getOffset() const;
204 uintX_t getAddend() const;
205 uint32_t getSymIndex() const;
206 const OutputSectionBase<ELFT> *getOutputSec() const { return OutputSec; }
212 const InputSectionBase<ELFT> *InputSec = nullptr;
213 const OutputSectionBase<ELFT> *OutputSec = nullptr;
219 template <class ELFT>
220 class SymbolTableSection final : public OutputSectionBase<ELFT> {
222 typedef typename ELFT::Shdr Elf_Shdr;
223 typedef typename ELFT::Sym Elf_Sym;
224 typedef typename ELFT::SymRange Elf_Sym_Range;
225 typedef typename ELFT::uint uintX_t;
226 SymbolTableSection(StringTableSection<ELFT> &StrTabSec);
228 void finalize() override;
229 void writeTo(uint8_t *Buf) override;
230 void addSymbol(SymbolBody *Body);
231 StringTableSection<ELFT> &getStrTabSec() const { return StrTabSec; }
232 unsigned getNumSymbols() const { return NumLocals + Symbols.size() + 1; }
234 ArrayRef<std::pair<SymbolBody *, size_t>> getSymbols() const {
238 unsigned NumLocals = 0;
239 StringTableSection<ELFT> &StrTabSec;
242 void writeLocalSymbols(uint8_t *&Buf);
243 void writeGlobalSymbols(uint8_t *Buf);
245 const OutputSectionBase<ELFT> *getOutputSection(SymbolBody *Sym);
247 // A vector of symbols and their string table offsets.
248 std::vector<std::pair<SymbolBody *, size_t>> Symbols;
251 // For more information about .gnu.version and .gnu.version_r see:
252 // https://www.akkadia.org/drepper/symbol-versioning
254 // The .gnu.version_d section which has a section type of SHT_GNU_verdef shall
255 // contain symbol version definitions. The number of entries in this section
256 // shall be contained in the DT_VERDEFNUM entry of the .dynamic section.
257 // The section shall contain an array of Elf_Verdef structures, optionally
258 // followed by an array of Elf_Verdaux structures.
259 template <class ELFT>
260 class VersionDefinitionSection final : public OutputSectionBase<ELFT> {
261 typedef typename ELFT::Verdef Elf_Verdef;
262 typedef typename ELFT::Verdaux Elf_Verdaux;
265 VersionDefinitionSection();
266 void finalize() override;
267 void writeTo(uint8_t *Buf) override;
270 void writeOne(uint8_t *Buf, uint32_t Index, StringRef Name, size_t NameOff);
272 unsigned FileDefNameOff;
275 // The .gnu.version section specifies the required version of each symbol in the
276 // dynamic symbol table. It contains one Elf_Versym for each dynamic symbol
277 // table entry. An Elf_Versym is just a 16-bit integer that refers to a version
278 // identifier defined in the either .gnu.version_r or .gnu.version_d section.
279 // The values 0 and 1 are reserved. All other values are used for versions in
280 // the own object or in any of the dependencies.
281 template <class ELFT>
282 class VersionTableSection final : public OutputSectionBase<ELFT> {
283 typedef typename ELFT::Versym Elf_Versym;
286 VersionTableSection();
287 void finalize() override;
288 void writeTo(uint8_t *Buf) override;
291 // The .gnu.version_r section defines the version identifiers used by
292 // .gnu.version. It contains a linked list of Elf_Verneed data structures. Each
293 // Elf_Verneed specifies the version requirements for a single DSO, and contains
294 // a reference to a linked list of Elf_Vernaux data structures which define the
295 // mapping from version identifiers to version names.
296 template <class ELFT>
297 class VersionNeedSection final : public OutputSectionBase<ELFT> {
298 typedef typename ELFT::Verneed Elf_Verneed;
299 typedef typename ELFT::Vernaux Elf_Vernaux;
301 // A vector of shared files that need Elf_Verneed data structures and the
302 // string table offsets of their sonames.
303 std::vector<std::pair<SharedFile<ELFT> *, size_t>> Needed;
305 // The next available version identifier.
309 VersionNeedSection();
310 void addSymbol(SharedSymbol<ELFT> *SS);
311 void finalize() override;
312 void writeTo(uint8_t *Buf) override;
313 size_t getNeedNum() const { return Needed.size(); }
316 template <class ELFT>
317 class RelocationSection final : public OutputSectionBase<ELFT> {
318 typedef typename ELFT::Rel Elf_Rel;
319 typedef typename ELFT::Rela Elf_Rela;
320 typedef typename ELFT::uint uintX_t;
323 RelocationSection(StringRef Name, bool Sort);
324 void addReloc(const DynamicReloc<ELFT> &Reloc);
325 unsigned getRelocOffset();
326 void finalize() override;
327 void writeTo(uint8_t *Buf) override;
328 bool hasRelocs() const { return !Relocs.empty(); }
334 std::vector<DynamicReloc<ELFT>> Relocs;
337 template <class ELFT>
338 class OutputSection final : public OutputSectionBase<ELFT> {
340 typedef typename ELFT::Shdr Elf_Shdr;
341 typedef typename ELFT::Sym Elf_Sym;
342 typedef typename ELFT::Rel Elf_Rel;
343 typedef typename ELFT::Rela Elf_Rela;
344 typedef typename ELFT::uint uintX_t;
345 OutputSection(StringRef Name, uint32_t Type, uintX_t Flags);
346 void addSection(InputSectionBase<ELFT> *C) override;
348 void sortCtorsDtors();
349 void writeTo(uint8_t *Buf) override;
350 void finalize() override;
351 void assignOffsets() override;
352 std::vector<InputSection<ELFT> *> Sections;
355 template <class ELFT>
356 class MergeOutputSection final : public OutputSectionBase<ELFT> {
357 typedef typename ELFT::uint uintX_t;
360 MergeOutputSection(StringRef Name, uint32_t Type, uintX_t Flags,
362 void addSection(InputSectionBase<ELFT> *S) override;
363 void writeTo(uint8_t *Buf) override;
364 unsigned getOffset(StringRef Val);
365 void finalize() override;
366 void finalizePieces() override;
367 bool shouldTailMerge() const;
370 llvm::StringTableBuilder Builder;
371 std::vector<MergeInputSection<ELFT> *> Sections;
375 SectionPiece *Piece = nullptr;
376 std::vector<SectionPiece *> FdePieces;
379 // Output section for .eh_frame.
380 template <class ELFT>
381 class EhOutputSection final : public OutputSectionBase<ELFT> {
382 typedef typename ELFT::uint uintX_t;
383 typedef typename ELFT::Shdr Elf_Shdr;
384 typedef typename ELFT::Rel Elf_Rel;
385 typedef typename ELFT::Rela Elf_Rela;
389 void writeTo(uint8_t *Buf) override;
390 void finalize() override;
391 bool empty() const { return Sections.empty(); }
393 void addSection(InputSectionBase<ELFT> *S) override;
398 template <class RelTy>
399 void addSectionAux(EhInputSection<ELFT> *S, llvm::ArrayRef<RelTy> Rels);
401 template <class RelTy>
402 CieRecord *addCie(SectionPiece &Piece, EhInputSection<ELFT> *Sec,
403 ArrayRef<RelTy> &Rels);
405 template <class RelTy>
406 bool isFdeLive(SectionPiece &Piece, EhInputSection<ELFT> *Sec,
407 ArrayRef<RelTy> &Rels);
409 uintX_t getFdePc(uint8_t *Buf, size_t Off, uint8_t Enc);
411 std::vector<EhInputSection<ELFT> *> Sections;
412 std::vector<CieRecord *> Cies;
414 // CIE records are uniquified by their contents and personality functions.
415 llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
418 template <class ELFT>
419 class InterpSection final : public OutputSectionBase<ELFT> {
422 void writeTo(uint8_t *Buf) override;
425 template <class ELFT>
426 class StringTableSection final : public OutputSectionBase<ELFT> {
428 typedef typename ELFT::uint uintX_t;
429 StringTableSection(StringRef Name, bool Dynamic);
430 unsigned addString(StringRef S, bool HashIt = true);
431 void writeTo(uint8_t *Buf) override;
432 unsigned getSize() const { return Size; }
433 void finalize() override { this->Header.sh_size = getSize(); }
434 bool isDynamic() const { return Dynamic; }
438 llvm::DenseMap<StringRef, unsigned> StringMap;
439 std::vector<StringRef> Strings;
440 unsigned Size = 1; // ELF string tables start with a NUL byte, so 1.
443 template <class ELFT>
444 class HashTableSection final : public OutputSectionBase<ELFT> {
445 typedef typename ELFT::Word Elf_Word;
449 void finalize() override;
450 void writeTo(uint8_t *Buf) override;
453 // Outputs GNU Hash section. For detailed explanation see:
454 // https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections
455 template <class ELFT>
456 class GnuHashTableSection final : public OutputSectionBase<ELFT> {
457 typedef typename ELFT::Off Elf_Off;
458 typedef typename ELFT::Word Elf_Word;
459 typedef typename ELFT::uint uintX_t;
462 GnuHashTableSection();
463 void finalize() override;
464 void writeTo(uint8_t *Buf) override;
466 // Adds symbols to the hash table.
467 // Sorts the input to satisfy GNU hash section requirements.
468 void addSymbols(std::vector<std::pair<SymbolBody *, size_t>> &Symbols);
471 static unsigned calcNBuckets(unsigned NumHashed);
472 static unsigned calcMaskWords(unsigned NumHashed);
474 void writeHeader(uint8_t *&Buf);
475 void writeBloomFilter(uint8_t *&Buf);
476 void writeHashTable(uint8_t *Buf);
484 std::vector<SymbolData> Symbols;
491 template <class ELFT>
492 class DynamicSection final : public OutputSectionBase<ELFT> {
493 typedef OutputSectionBase<ELFT> Base;
494 typedef typename ELFT::Dyn Elf_Dyn;
495 typedef typename ELFT::Rel Elf_Rel;
496 typedef typename ELFT::Rela Elf_Rela;
497 typedef typename ELFT::Shdr Elf_Shdr;
498 typedef typename ELFT::Sym Elf_Sym;
499 typedef typename ELFT::uint uintX_t;
501 // The .dynamic section contains information for the dynamic linker.
502 // The section consists of fixed size entries, which consist of
503 // type and value fields. Value are one of plain integers, symbol
504 // addresses, or section addresses. This struct represents the entry.
508 OutputSectionBase<ELFT> *OutSec;
510 const SymbolBody *Sym;
512 enum KindT { SecAddr, SymAddr, PlainInt } Kind;
513 Entry(int32_t Tag, OutputSectionBase<ELFT> *OutSec)
514 : Tag(Tag), OutSec(OutSec), Kind(SecAddr) {}
515 Entry(int32_t Tag, uint64_t Val) : Tag(Tag), Val(Val), Kind(PlainInt) {}
516 Entry(int32_t Tag, const SymbolBody *Sym)
517 : Tag(Tag), Sym(Sym), Kind(SymAddr) {}
520 // finalize() fills this vector with the section contents. finalize()
521 // cannot directly create final section contents because when the
522 // function is called, symbol or section addresses are not fixed yet.
523 std::vector<Entry> Entries;
526 explicit DynamicSection();
527 void finalize() override;
528 void writeTo(uint8_t *Buf) override;
530 OutputSectionBase<ELFT> *PreInitArraySec = nullptr;
531 OutputSectionBase<ELFT> *InitArraySec = nullptr;
532 OutputSectionBase<ELFT> *FiniArraySec = nullptr;
535 template <class ELFT>
536 class MipsReginfoOutputSection final : public OutputSectionBase<ELFT> {
537 typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
540 MipsReginfoOutputSection();
541 void writeTo(uint8_t *Buf) override;
542 void addSection(InputSectionBase<ELFT> *S) override;
545 uint32_t GprMask = 0;
548 template <class ELFT>
549 class MipsOptionsOutputSection final : public OutputSectionBase<ELFT> {
550 typedef llvm::object::Elf_Mips_Options<ELFT> Elf_Mips_Options;
551 typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
554 MipsOptionsOutputSection();
555 void writeTo(uint8_t *Buf) override;
556 void addSection(InputSectionBase<ELFT> *S) override;
559 uint32_t GprMask = 0;
562 // --eh-frame-hdr option tells linker to construct a header for all the
563 // .eh_frame sections. This header is placed to a section named .eh_frame_hdr
564 // and also to a PT_GNU_EH_FRAME segment.
565 // At runtime the unwinder then can find all the PT_GNU_EH_FRAME segments by
566 // calling dl_iterate_phdr.
567 // This section contains a lookup table for quick binary search of FDEs.
568 // Detailed info about internals can be found in Ian Lance Taylor's blog:
569 // http://www.airs.com/blog/archives/460 (".eh_frame")
570 // http://www.airs.com/blog/archives/462 (".eh_frame_hdr")
571 template <class ELFT>
572 class EhFrameHeader final : public OutputSectionBase<ELFT> {
573 typedef typename ELFT::uint uintX_t;
577 void finalize() override;
578 void writeTo(uint8_t *Buf) override;
579 void addFde(uint32_t Pc, uint32_t FdeVA);
587 std::vector<FdeData> Fdes;
590 template <class ELFT> class BuildIdSection : public OutputSectionBase<ELFT> {
592 void writeTo(uint8_t *Buf) override;
593 virtual void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) = 0;
596 BuildIdSection(size_t HashSize);
598 uint8_t *HashBuf = nullptr;
601 template <class ELFT> class BuildIdFnv1 final : public BuildIdSection<ELFT> {
603 BuildIdFnv1() : BuildIdSection<ELFT>(8) {}
604 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
607 template <class ELFT> class BuildIdMd5 final : public BuildIdSection<ELFT> {
609 BuildIdMd5() : BuildIdSection<ELFT>(16) {}
610 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
613 template <class ELFT> class BuildIdSha1 final : public BuildIdSection<ELFT> {
615 BuildIdSha1() : BuildIdSection<ELFT>(20) {}
616 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
619 template <class ELFT>
620 class BuildIdHexstring final : public BuildIdSection<ELFT> {
623 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
626 // All output sections that are hadnled by the linker specially are
627 // globally accessible. Writer initializes them, so don't use them
628 // until Writer is initialized.
629 template <class ELFT> struct Out {
630 typedef typename ELFT::uint uintX_t;
631 typedef typename ELFT::Phdr Elf_Phdr;
632 static BuildIdSection<ELFT> *BuildId;
633 static DynamicSection<ELFT> *Dynamic;
634 static EhFrameHeader<ELFT> *EhFrameHdr;
635 static EhOutputSection<ELFT> *EhFrame;
636 static GnuHashTableSection<ELFT> *GnuHashTab;
637 static GotPltSection<ELFT> *GotPlt;
638 static GotSection<ELFT> *Got;
639 static HashTableSection<ELFT> *HashTab;
640 static InterpSection<ELFT> *Interp;
641 static OutputSection<ELFT> *Bss;
642 static OutputSection<ELFT> *MipsRldMap;
643 static OutputSectionBase<ELFT> *Opd;
644 static uint8_t *OpdBuf;
645 static PltSection<ELFT> *Plt;
646 static RelocationSection<ELFT> *RelaDyn;
647 static RelocationSection<ELFT> *RelaPlt;
648 static StringTableSection<ELFT> *DynStrTab;
649 static StringTableSection<ELFT> *ShStrTab;
650 static StringTableSection<ELFT> *StrTab;
651 static SymbolTableSection<ELFT> *DynSymTab;
652 static SymbolTableSection<ELFT> *SymTab;
653 static VersionDefinitionSection<ELFT> *VerDef;
654 static VersionTableSection<ELFT> *VerSym;
655 static VersionNeedSection<ELFT> *VerNeed;
656 static Elf_Phdr *TlsPhdr;
657 static OutputSectionBase<ELFT> *ElfHeader;
658 static OutputSectionBase<ELFT> *ProgramHeaders;
661 template <bool Is64Bits> struct SectionKey {
662 typedef typename std::conditional<Is64Bits, uint64_t, uint32_t>::type uintX_t;
669 // This class knows how to create an output section for a given
670 // input section. Output section type is determined by various
671 // factors, including input section's sh_flags, sh_type and
673 template <class ELFT> class OutputSectionFactory {
674 typedef typename ELFT::Shdr Elf_Shdr;
675 typedef typename ELFT::uint uintX_t;
676 typedef typename elf::SectionKey<ELFT::Is64Bits> Key;
679 std::pair<OutputSectionBase<ELFT> *, bool> create(InputSectionBase<ELFT> *C,
680 StringRef OutsecName);
682 OutputSectionBase<ELFT> *lookup(StringRef Name, uint32_t Type, uintX_t Flags);
685 Key createKey(InputSectionBase<ELFT> *C, StringRef OutsecName);
687 llvm::SmallDenseMap<Key, OutputSectionBase<ELFT> *> Map;
690 template <class ELFT> BuildIdSection<ELFT> *Out<ELFT>::BuildId;
691 template <class ELFT> DynamicSection<ELFT> *Out<ELFT>::Dynamic;
692 template <class ELFT> EhFrameHeader<ELFT> *Out<ELFT>::EhFrameHdr;
693 template <class ELFT> EhOutputSection<ELFT> *Out<ELFT>::EhFrame;
694 template <class ELFT> GnuHashTableSection<ELFT> *Out<ELFT>::GnuHashTab;
695 template <class ELFT> GotPltSection<ELFT> *Out<ELFT>::GotPlt;
696 template <class ELFT> GotSection<ELFT> *Out<ELFT>::Got;
697 template <class ELFT> HashTableSection<ELFT> *Out<ELFT>::HashTab;
698 template <class ELFT> InterpSection<ELFT> *Out<ELFT>::Interp;
699 template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss;
700 template <class ELFT> OutputSection<ELFT> *Out<ELFT>::MipsRldMap;
701 template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::Opd;
702 template <class ELFT> uint8_t *Out<ELFT>::OpdBuf;
703 template <class ELFT> PltSection<ELFT> *Out<ELFT>::Plt;
704 template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaDyn;
705 template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaPlt;
706 template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::DynStrTab;
707 template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::ShStrTab;
708 template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::StrTab;
709 template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::DynSymTab;
710 template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::SymTab;
711 template <class ELFT> VersionDefinitionSection<ELFT> *Out<ELFT>::VerDef;
712 template <class ELFT> VersionTableSection<ELFT> *Out<ELFT>::VerSym;
713 template <class ELFT> VersionNeedSection<ELFT> *Out<ELFT>::VerNeed;
714 template <class ELFT> typename ELFT::Phdr *Out<ELFT>::TlsPhdr;
715 template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ElfHeader;
716 template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ProgramHeaders;
722 template <bool Is64Bits> struct DenseMapInfo<lld::elf::SectionKey<Is64Bits>> {
723 typedef typename lld::elf::SectionKey<Is64Bits> Key;
725 static Key getEmptyKey();
726 static Key getTombstoneKey();
727 static unsigned getHashValue(const Key &Val);
728 static bool isEqual(const Key &LHS, const Key &RHS);