blob: 5cb18234d6b80772dd7aac8d4bbe262069cd9e57 [file] [log] [blame]
Rafael Espindola5805c4f2015-09-21 21:38:08 +00001//===- OutputSections.h -----------------------------------------*- C++ -*-===//
2//
3// The LLVM Linker
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLD_ELF_OUTPUT_SECTIONS_H
11#define LLD_ELF_OUTPUT_SECTIONS_H
12
Davide Italiano85121bb2015-09-25 03:56:11 +000013#include "Config.h"
14
Rui Ueyamaa0752a52016-03-13 20:28:29 +000015#include "lld/Core/LLVM.h"
Simon Atanasyand2980d32016-03-29 14:07:22 +000016#include "llvm/ADT/SmallPtrSet.h"
Rui Ueyamaa0752a52016-03-13 20:28:29 +000017#include "llvm/MC/StringTableBuilder.h"
18#include "llvm/Object/ELF.h"
Rui Ueyama3a41be22016-04-07 22:49:21 +000019#include "llvm/Support/MD5.h"
Rui Ueyamad86ec302016-04-07 23:51:56 +000020#include "llvm/Support/SHA1.h"
Rafael Espindola5805c4f2015-09-21 21:38:08 +000021
22namespace lld {
Rafael Espindolae0df00b2016-02-28 00:25:54 +000023namespace elf {
Rafael Espindola5805c4f2015-09-21 21:38:08 +000024
25class SymbolBody;
Rui Ueyamaf8b285c2016-05-22 23:16:14 +000026struct SectionPiece;
Rui Ueyama3ce825e2015-10-09 21:07:25 +000027template <class ELFT> class SymbolTable;
Rafael Espindola5805c4f2015-09-21 21:38:08 +000028template <class ELFT> class SymbolTableSection;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +000029template <class ELFT> class StringTableSection;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +000030template <class ELFT> class EHInputSection;
Rafael Espindola5805c4f2015-09-21 21:38:08 +000031template <class ELFT> class InputSection;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +000032template <class ELFT> class InputSectionBase;
Rafael Espindolac159c962015-10-19 21:00:02 +000033template <class ELFT> class MergeInputSection;
Simon Atanasyan1d7df402015-12-20 10:57:34 +000034template <class ELFT> class MipsReginfoInputSection;
Rafael Espindola5805c4f2015-09-21 21:38:08 +000035template <class ELFT> class OutputSection;
36template <class ELFT> class ObjectFile;
Peter Collingbourne21a12fc2016-04-27 20:22:31 +000037template <class ELFT> class SharedFile;
38template <class ELFT> class SharedSymbol;
Rafael Espindola5805c4f2015-09-21 21:38:08 +000039template <class ELFT> class DefinedRegular;
40
Rafael Espindola5805c4f2015-09-21 21:38:08 +000041template <class ELFT>
Rui Ueyama9328b2c2016-03-14 23:16:09 +000042static inline typename ELFT::uint getAddend(const typename ELFT::Rel &Rel) {
Rafael Espindola932efcf2015-10-19 20:24:44 +000043 return 0;
44}
Rafael Espindola5805c4f2015-09-21 21:38:08 +000045
46template <class ELFT>
Rui Ueyama9328b2c2016-03-14 23:16:09 +000047static inline typename ELFT::uint getAddend(const typename ELFT::Rela &Rel) {
Rafael Espindola932efcf2015-10-19 20:24:44 +000048 return Rel.r_addend;
49}
50
George Rimar12737b72016-02-25 08:40:26 +000051bool isValidCIdentifier(StringRef S);
52
Rafael Espindola71675852015-09-22 00:16:19 +000053// This represents a section in an output file.
54// Different sub classes represent different types of sections. Some contain
55// input sections, others are created by the linker.
56// The writer creates multiple OutputSections and assign them unique,
Rafael Espindola5805c4f2015-09-21 21:38:08 +000057// non-overlapping file offsets and VAs.
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +000058template <class ELFT> class OutputSectionBase {
Rafael Espindola5805c4f2015-09-21 21:38:08 +000059public:
Rui Ueyama9328b2c2016-03-14 23:16:09 +000060 typedef typename ELFT::uint uintX_t;
61 typedef typename ELFT::Shdr Elf_Shdr;
Rafael Espindola5805c4f2015-09-21 21:38:08 +000062
George Rimar9bec24a2016-02-18 14:20:08 +000063 OutputSectionBase(StringRef Name, uint32_t Type, uintX_t Flags);
Rafael Espindola5805c4f2015-09-21 21:38:08 +000064 void setVA(uintX_t VA) { Header.sh_addr = VA; }
65 uintX_t getVA() const { return Header.sh_addr; }
66 void setFileOffset(uintX_t Off) { Header.sh_offset = Off; }
Rafael Espindolae2c24612016-01-29 01:24:25 +000067 void setSHName(unsigned Val) { Header.sh_name = Val; }
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +000068 void writeHeaderTo(Elf_Shdr *SHdr);
Rafael Espindola5805c4f2015-09-21 21:38:08 +000069 StringRef getName() { return Name; }
Rafael Espindola5805c4f2015-09-21 21:38:08 +000070
Rui Ueyama40845e62015-12-26 05:51:07 +000071 virtual void addSection(InputSectionBase<ELFT> *C) {}
72
Rui Ueyama2317d0d2015-10-15 20:55:22 +000073 unsigned SectionIndex;
Rafael Espindola5805c4f2015-09-21 21:38:08 +000074
75 // Returns the size of the section in the output file.
Rafael Espindola77572242015-10-02 19:37:55 +000076 uintX_t getSize() const { return Header.sh_size; }
Rafael Espindola5805c4f2015-09-21 21:38:08 +000077 void setSize(uintX_t Val) { Header.sh_size = Val; }
Rafael Espindola571452c2016-04-11 13:44:05 +000078 uintX_t getFlags() const { return Header.sh_flags; }
79 uintX_t getFileOff() const { return Header.sh_offset; }
80 uintX_t getAlign() const {
Rafael Espindola5805c4f2015-09-21 21:38:08 +000081 // The ELF spec states that a value of 0 means the section has no alignment
82 // constraits.
83 return std::max<uintX_t>(Header.sh_addralign, 1);
84 }
Rafael Espindola571452c2016-04-11 13:44:05 +000085 uint32_t getType() const { return Header.sh_type; }
Rafael Espindola115f0f32015-11-03 14:13:40 +000086 void updateAlign(uintX_t Align) {
87 if (Align > Header.sh_addralign)
88 Header.sh_addralign = Align;
89 }
Rafael Espindola5805c4f2015-09-21 21:38:08 +000090
Rui Ueyama47091902016-03-30 19:41:51 +000091 // If true, this section will be page aligned on disk.
92 // Typically the first section of each PT_LOAD segment has this flag.
93 bool PageAlign = false;
94
Rafael Espindola5805c4f2015-09-21 21:38:08 +000095 virtual void finalize() {}
Rafael Espindola56004c52016-04-07 14:22:09 +000096 virtual void
97 forEachInputSection(std::function<void(InputSectionBase<ELFT> *)> F) {}
Rafael Espindola4fc60442016-02-10 22:43:13 +000098 virtual void writeTo(uint8_t *Buf) {}
Rui Ueyamad4ea7dd2015-12-26 07:01:26 +000099 virtual ~OutputSectionBase() = default;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000100
101protected:
102 StringRef Name;
Sean Silva580c1b62016-04-20 04:26:16 +0000103 Elf_Shdr Header;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000104};
105
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000106template <class ELFT> class GotSection final : public OutputSectionBase<ELFT> {
107 typedef OutputSectionBase<ELFT> Base;
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000108 typedef typename ELFT::uint uintX_t;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000109
110public:
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000111 GotSection();
Igor Kudrin15cd9ff2015-11-06 07:43:03 +0000112 void finalize() override;
Rafael Espindolaa6627382015-10-06 23:56:53 +0000113 void writeTo(uint8_t *Buf) override;
Rafael Espindola67d72c02016-03-11 12:06:30 +0000114 void addEntry(SymbolBody &Sym);
Rafael Espindola67d72c02016-03-11 12:06:30 +0000115 bool addDynTlsEntry(SymbolBody &Sym);
Rui Ueyama0e53c7d2016-02-05 00:10:02 +0000116 bool addTlsIndex();
Simon Atanasyan56ab5f02016-01-21 05:33:23 +0000117 bool empty() const { return MipsLocalEntries == 0 && Entries.empty(); }
Rafael Espindola58cd5db2016-04-19 22:46:03 +0000118 uintX_t getMipsLocalEntryOffset(uintX_t EntryValue);
119 uintX_t getMipsLocalPageOffset(uintX_t Addr);
George Rimar90cd0a82015-12-01 19:20:26 +0000120 uintX_t getGlobalDynAddr(const SymbolBody &B) const;
Rafael Espindola74031ba2016-04-07 15:20:56 +0000121 uintX_t getGlobalDynOffset(const SymbolBody &B) const;
George Rimar9db204a2015-12-02 09:58:20 +0000122 uintX_t getNumEntries() const { return Entries.size(); }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000123
Igor Kudrin304860a2015-11-12 04:39:49 +0000124 // Returns the symbol which corresponds to the first entry of the global part
125 // of GOT on MIPS platform. It is required to fill up MIPS-specific dynamic
126 // table properties.
127 // Returns nullptr if the global part is empty.
128 const SymbolBody *getMipsFirstGlobalEntry() const;
129
130 // Returns the number of entries in the local part of GOT including
131 // the number of reserved entries. This method is MIPS-specific.
132 unsigned getMipsLocalEntriesNum() const;
133
Rui Ueyama0e53c7d2016-02-05 00:10:02 +0000134 uintX_t getTlsIndexVA() { return Base::getVA() + TlsIndexOff; }
Rafael Espindola74031ba2016-04-07 15:20:56 +0000135 uint32_t getTlsIndexOff() { return TlsIndexOff; }
George Rimarb17f7392015-12-01 18:24:07 +0000136
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000137private:
138 std::vector<const SymbolBody *> Entries;
Rui Ueyama0e53c7d2016-02-05 00:10:02 +0000139 uint32_t TlsIndexOff = -1;
Simon Atanasyan56ab5f02016-01-21 05:33:23 +0000140 uint32_t MipsLocalEntries = 0;
Simon Atanasyand2980d32016-03-29 14:07:22 +0000141 // Output sections referenced by MIPS GOT relocations.
142 llvm::SmallPtrSet<const OutputSectionBase<ELFT> *, 10> MipsOutSections;
Simon Atanasyan56ab5f02016-01-21 05:33:23 +0000143 llvm::DenseMap<uintX_t, size_t> MipsLocalGotPos;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000144};
145
George Rimar648a2c32015-10-20 08:54:27 +0000146template <class ELFT>
147class GotPltSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000148 typedef typename ELFT::uint uintX_t;
George Rimar648a2c32015-10-20 08:54:27 +0000149
150public:
151 GotPltSection();
152 void finalize() override;
153 void writeTo(uint8_t *Buf) override;
Rafael Espindola67d72c02016-03-11 12:06:30 +0000154 void addEntry(SymbolBody &Sym);
George Rimar648a2c32015-10-20 08:54:27 +0000155 bool empty() const;
George Rimar648a2c32015-10-20 08:54:27 +0000156
157private:
158 std::vector<const SymbolBody *> Entries;
159};
160
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000161template <class ELFT> class PltSection final : public OutputSectionBase<ELFT> {
162 typedef OutputSectionBase<ELFT> Base;
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000163 typedef typename ELFT::uint uintX_t;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000164
165public:
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000166 PltSection();
Hal Finkel6c2a3b82015-10-08 21:51:31 +0000167 void finalize() override;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000168 void writeTo(uint8_t *Buf) override;
Rafael Espindola67d72c02016-03-11 12:06:30 +0000169 void addEntry(SymbolBody &Sym);
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000170 bool empty() const { return Entries.empty(); }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000171
172private:
George Rimar77b77792015-11-25 22:15:01 +0000173 std::vector<std::pair<const SymbolBody *, unsigned>> Entries;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000174};
175
176template <class ELFT> struct DynamicReloc {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000177 typedef typename ELFT::uint uintX_t;
Rafael Espindolade9857e2016-02-04 21:33:05 +0000178 uint32_t Type;
179
Rafael Espindolaac568f92016-04-11 13:47:35 +0000180 SymbolBody *Sym;
Rafael Espindola34ffcbb2016-04-11 13:51:23 +0000181 const OutputSectionBase<ELFT> *OffsetSec;
Rafael Espindolaac568f92016-04-11 13:47:35 +0000182 uintX_t OffsetInSec;
183 bool UseSymVA;
184 uintX_t Addend;
Rafael Espindolade9857e2016-02-04 21:33:05 +0000185
Rafael Espindola34ffcbb2016-04-11 13:51:23 +0000186 DynamicReloc(uint32_t Type, const OutputSectionBase<ELFT> *OffsetSec,
Rafael Espindolade9857e2016-02-04 21:33:05 +0000187 uintX_t OffsetInSec, bool UseSymVA, SymbolBody *Sym,
188 uintX_t Addend)
Rafael Espindola74031ba2016-04-07 15:20:56 +0000189 : Type(Type), Sym(Sym), OffsetSec(OffsetSec), OffsetInSec(OffsetInSec),
190 UseSymVA(UseSymVA), Addend(Addend) {}
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000191};
192
193template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000194class SymbolTableSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000195public:
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000196 typedef typename ELFT::Shdr Elf_Shdr;
197 typedef typename ELFT::Sym Elf_Sym;
198 typedef typename ELFT::SymRange Elf_Sym_Range;
199 typedef typename ELFT::uint uintX_t;
Rui Ueyama3ce825e2015-10-09 21:07:25 +0000200 SymbolTableSection(SymbolTable<ELFT> &Table,
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000201 StringTableSection<ELFT> &StrTabSec);
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000202
Rui Ueyama0db335f2015-10-07 16:58:54 +0000203 void finalize() override;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000204 void writeTo(uint8_t *Buf) override;
Igor Kudrinab665fc2015-10-20 21:47:58 +0000205 void addSymbol(SymbolBody *Body);
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000206 StringTableSection<ELFT> &getStrTabSec() const { return StrTabSec; }
Rafael Espindola0e92f242016-01-27 16:41:24 +0000207 unsigned getNumSymbols() const { return NumLocals + Symbols.size() + 1; }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000208
Rui Ueyamac2e863a2016-02-17 05:06:40 +0000209 ArrayRef<std::pair<SymbolBody *, size_t>> getSymbols() const {
Rafael Espindolae2c24612016-01-29 01:24:25 +0000210 return Symbols;
211 }
212
213 unsigned NumLocals = 0;
214 StringTableSection<ELFT> &StrTabSec;
Igor Kudrinab665fc2015-10-20 21:47:58 +0000215
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000216private:
Rui Ueyama8ddfa812015-09-30 00:32:10 +0000217 void writeLocalSymbols(uint8_t *&Buf);
Igor Kudrinea6a8352015-10-19 08:01:51 +0000218 void writeGlobalSymbols(uint8_t *Buf);
Rui Ueyama8ddfa812015-09-30 00:32:10 +0000219
Rui Ueyama874e7ae2016-02-17 04:56:44 +0000220 const OutputSectionBase<ELFT> *getOutputSection(SymbolBody *Sym);
Igor Kudrin853b88d2015-10-20 20:52:14 +0000221
Rui Ueyama3ce825e2015-10-09 21:07:25 +0000222 SymbolTable<ELFT> &Table;
Rui Ueyamac2e863a2016-02-17 05:06:40 +0000223
224 // A vector of symbols and their string table offsets.
225 std::vector<std::pair<SymbolBody *, size_t>> Symbols;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000226};
227
Peter Collingbourne21a12fc2016-04-27 20:22:31 +0000228// For more information about .gnu.version and .gnu.version_r see:
229// https://www.akkadia.org/drepper/symbol-versioning
230
231// The .gnu.version section specifies the required version of each symbol in the
232// dynamic symbol table. It contains one Elf_Versym for each dynamic symbol
233// table entry. An Elf_Versym is just a 16-bit integer that refers to a version
234// identifier defined in the .gnu.version_r section.
235template <class ELFT>
236class VersionTableSection final : public OutputSectionBase<ELFT> {
237 typedef typename ELFT::Versym Elf_Versym;
238
239public:
240 VersionTableSection();
241 void finalize() override;
242 void writeTo(uint8_t *Buf) override;
243};
244
245// The .gnu.version_r section defines the version identifiers used by
246// .gnu.version. It contains a linked list of Elf_Verneed data structures. Each
247// Elf_Verneed specifies the version requirements for a single DSO, and contains
248// a reference to a linked list of Elf_Vernaux data structures which define the
249// mapping from version identifiers to version names.
250template <class ELFT>
251class VersionNeedSection final : public OutputSectionBase<ELFT> {
252 typedef typename ELFT::Verneed Elf_Verneed;
253 typedef typename ELFT::Vernaux Elf_Vernaux;
254
255 // A vector of shared files that need Elf_Verneed data structures and the
256 // string table offsets of their sonames.
257 std::vector<std::pair<SharedFile<ELFT> *, size_t>> Needed;
258
259 // The next available version identifier. Identifiers start at 2 because 0 and
260 // 1 are reserved.
261 unsigned NextIndex = 2;
262
263public:
264 VersionNeedSection();
265 void addSymbol(SharedSymbol<ELFT> *SS);
266 void finalize() override;
267 void writeTo(uint8_t *Buf) override;
268 size_t getNeedNum() const { return Needed.size(); }
269};
270
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000271template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000272class RelocationSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000273 typedef typename ELFT::Rel Elf_Rel;
274 typedef typename ELFT::Rela Elf_Rela;
275 typedef typename ELFT::uint uintX_t;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000276
277public:
George Rimarc191acf2016-05-10 15:47:57 +0000278 RelocationSection(StringRef Name, bool Sort);
Rafael Espindolad30eb7d2016-02-05 15:03:10 +0000279 void addReloc(const DynamicReloc<ELFT> &Reloc);
George Rimar77b77792015-11-25 22:15:01 +0000280 unsigned getRelocOffset();
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000281 void finalize() override;
282 void writeTo(uint8_t *Buf) override;
283 bool hasRelocs() const { return !Relocs.empty(); }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000284
George Rimara07ff662015-12-21 10:12:06 +0000285 bool Static = false;
286
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000287private:
George Rimarc191acf2016-05-10 15:47:57 +0000288 bool Sort;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000289 std::vector<DynamicReloc<ELFT>> Relocs;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000290};
291
292template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000293class OutputSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000294public:
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000295 typedef typename ELFT::Shdr Elf_Shdr;
296 typedef typename ELFT::Sym Elf_Sym;
297 typedef typename ELFT::Rel Elf_Rel;
298 typedef typename ELFT::Rela Elf_Rela;
299 typedef typename ELFT::uint uintX_t;
George Rimar9bec24a2016-02-18 14:20:08 +0000300 OutputSection(StringRef Name, uint32_t Type, uintX_t Flags);
Rui Ueyama40845e62015-12-26 05:51:07 +0000301 void addSection(InputSectionBase<ELFT> *C) override;
Rui Ueyama5af83682016-02-11 23:41:38 +0000302 void sortInitFini();
303 void sortCtorsDtors();
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000304 void writeTo(uint8_t *Buf) override;
George Rimar58941ee2016-02-25 08:23:37 +0000305 void finalize() override;
Rafael Espindola56004c52016-04-07 14:22:09 +0000306 void
307 forEachInputSection(std::function<void(InputSectionBase<ELFT> *)> F) override;
Rafael Espindola71675852015-09-22 00:16:19 +0000308 std::vector<InputSection<ELFT> *> Sections;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000309};
310
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000311template <class ELFT>
Rafael Espindolac159c962015-10-19 21:00:02 +0000312class MergeOutputSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000313 typedef typename ELFT::uint uintX_t;
Rafael Espindolac159c962015-10-19 21:00:02 +0000314
315public:
Rafael Espindola7efa5be2016-02-19 14:17:40 +0000316 MergeOutputSection(StringRef Name, uint32_t Type, uintX_t Flags,
317 uintX_t Alignment);
Rui Ueyama40845e62015-12-26 05:51:07 +0000318 void addSection(InputSectionBase<ELFT> *S) override;
Rafael Espindolac159c962015-10-19 21:00:02 +0000319 void writeTo(uint8_t *Buf) override;
Rafael Espindolaf82ed2a2015-10-24 22:51:01 +0000320 unsigned getOffset(StringRef Val);
321 void finalize() override;
Peter Collingbournee29e1422016-05-05 04:10:12 +0000322 bool shouldTailMerge() const;
Rafael Espindolac159c962015-10-19 21:00:02 +0000323
324private:
Rafael Espindola7efa5be2016-02-19 14:17:40 +0000325 llvm::StringTableBuilder Builder;
Rafael Espindolac159c962015-10-19 21:00:02 +0000326};
327
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000328struct CieRecord {
329 SectionPiece *Piece = nullptr;
330 std::vector<SectionPiece *> FdePieces;
331 uint8_t FdeEncoding = 0;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000332};
333
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000334// Output section for .eh_frame.
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000335template <class ELFT>
Rui Ueyama1e479c22016-05-23 15:07:59 +0000336class EhOutputSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000337 typedef typename ELFT::uint uintX_t;
338 typedef typename ELFT::Shdr Elf_Shdr;
339 typedef typename ELFT::Rel Elf_Rel;
340 typedef typename ELFT::Rela Elf_Rela;
Rui Ueyamaf86cb902016-05-23 15:12:41 +0000341
342public:
343 EhOutputSection();
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000344 void writeTo(uint8_t *Buf) override;
Rafael Espindola56004c52016-04-07 14:22:09 +0000345 void finalize() override;
Rui Ueyama3b31e672016-05-23 16:24:16 +0000346 bool empty() const { return Sections.empty(); }
Rafael Espindola56004c52016-04-07 14:22:09 +0000347 void
348 forEachInputSection(std::function<void(InputSectionBase<ELFT> *)> F) override;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000349
Rui Ueyama40845e62015-12-26 05:51:07 +0000350 void addSection(InputSectionBase<ELFT> *S) override;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000351
Rui Ueyamade9777a2016-05-23 16:30:41 +0000352 size_t NumFdes = 0;
353
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000354private:
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000355 template <class RelTy>
356 void addSectionAux(EHInputSection<ELFT> *S, llvm::ArrayRef<RelTy> Rels);
357
358 std::vector<SectionPiece> splitInputSection(const EHInputSection<ELFT> *Sec);
359
360 template <class RelTy>
Rui Ueyamae2060aa2016-05-22 23:52:56 +0000361 CieRecord *addCie(SectionPiece &Piece, EHInputSection<ELFT> *Sec,
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000362 ArrayRef<RelTy> Rels);
363
364 template <class RelTy>
365 bool isFdeLive(SectionPiece &Piece, EHInputSection<ELFT> *Sec,
366 ArrayRef<RelTy> Rels);
367
George Rimarf6bc65a2016-01-15 13:34:52 +0000368 uint8_t getFdeEncoding(ArrayRef<uint8_t> D);
George Rimar003be4f2015-12-17 09:23:40 +0000369
Rui Ueyamae75e9332016-05-23 03:00:33 +0000370 uintX_t getFdePc(uint8_t *Buf, size_t Off, uint8_t Enc);
371
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000372 std::vector<EHInputSection<ELFT> *> Sections;
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000373 std::vector<CieRecord *> Cies;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000374
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000375 // CIE records are uniquified by their contents and personality functions.
376 llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
377
Rafael Espindola56004c52016-04-07 14:22:09 +0000378 bool Finalized = false;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000379};
380
Rafael Espindolac159c962015-10-19 21:00:02 +0000381template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000382class InterpSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000383public:
384 InterpSection();
Eugene Zelenko6e43b492015-11-04 02:11:57 +0000385 void writeTo(uint8_t *Buf) override;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000386};
387
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000388template <class ELFT>
389class StringTableSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000390public:
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000391 typedef typename ELFT::uint uintX_t;
George Rimar0f5ac9f2015-10-20 17:21:35 +0000392 StringTableSection(StringRef Name, bool Dynamic);
Rafael Espindolae2c24612016-01-29 01:24:25 +0000393 unsigned addString(StringRef S, bool HashIt = true);
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000394 void writeTo(uint8_t *Buf) override;
Rafael Espindolae2c24612016-01-29 01:24:25 +0000395 unsigned getSize() const { return Size; }
Rui Ueyama76c00632016-01-07 02:35:32 +0000396 void finalize() override { this->Header.sh_size = getSize(); }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000397 bool isDynamic() const { return Dynamic; }
398
399private:
400 const bool Dynamic;
Rafael Espindolae2c24612016-01-29 01:24:25 +0000401 llvm::DenseMap<StringRef, unsigned> StringMap;
Rui Ueyama76c00632016-01-07 02:35:32 +0000402 std::vector<StringRef> Strings;
Rafael Espindolae2c24612016-01-29 01:24:25 +0000403 unsigned Size = 1; // ELF string tables start with a NUL byte, so 1.
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000404};
405
406template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000407class HashTableSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000408 typedef typename ELFT::Word Elf_Word;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000409
410public:
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000411 HashTableSection();
Rui Ueyama0db335f2015-10-07 16:58:54 +0000412 void finalize() override;
413 void writeTo(uint8_t *Buf) override;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000414};
415
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000416// Outputs GNU Hash section. For detailed explanation see:
417// https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections
418template <class ELFT>
419class GnuHashTableSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000420 typedef typename ELFT::Off Elf_Off;
421 typedef typename ELFT::Word Elf_Word;
422 typedef typename ELFT::uint uintX_t;
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000423
424public:
425 GnuHashTableSection();
426 void finalize() override;
427 void writeTo(uint8_t *Buf) override;
428
Igor Kudrinf1d60292015-10-28 07:05:56 +0000429 // Adds symbols to the hash table.
430 // Sorts the input to satisfy GNU hash section requirements.
Rui Ueyamac2e863a2016-02-17 05:06:40 +0000431 void addSymbols(std::vector<std::pair<SymbolBody *, size_t>> &Symbols);
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000432
433private:
Igor Kudrinf1d60292015-10-28 07:05:56 +0000434 static unsigned calcNBuckets(unsigned NumHashed);
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000435 static unsigned calcMaskWords(unsigned NumHashed);
436
437 void writeHeader(uint8_t *&Buf);
438 void writeBloomFilter(uint8_t *&Buf);
439 void writeHashTable(uint8_t *Buf);
440
Rui Ueyama861c7312016-02-17 05:40:03 +0000441 struct SymbolData {
Igor Kudrinf1d60292015-10-28 07:05:56 +0000442 SymbolBody *Body;
Rui Ueyamac2e863a2016-02-17 05:06:40 +0000443 size_t STName;
Igor Kudrinf1d60292015-10-28 07:05:56 +0000444 uint32_t Hash;
445 };
446
Rui Ueyama861c7312016-02-17 05:40:03 +0000447 std::vector<SymbolData> Symbols;
Igor Kudrinf1d60292015-10-28 07:05:56 +0000448
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000449 unsigned MaskWords;
450 unsigned NBuckets;
451 unsigned Shift2;
452};
453
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000454template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000455class DynamicSection final : public OutputSectionBase<ELFT> {
456 typedef OutputSectionBase<ELFT> Base;
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000457 typedef typename ELFT::Dyn Elf_Dyn;
458 typedef typename ELFT::Rel Elf_Rel;
459 typedef typename ELFT::Rela Elf_Rela;
460 typedef typename ELFT::Shdr Elf_Shdr;
461 typedef typename ELFT::Sym Elf_Sym;
462 typedef typename ELFT::uint uintX_t;
Rafael Espindolade069362016-01-25 21:32:04 +0000463
Rui Ueyama909cc682016-02-02 03:11:27 +0000464 // The .dynamic section contains information for the dynamic linker.
465 // The section consists of fixed size entries, which consist of
466 // type and value fields. Value are one of plain integers, symbol
467 // addresses, or section addresses. This struct represents the entry.
Rafael Espindolade069362016-01-25 21:32:04 +0000468 struct Entry {
469 int32_t Tag;
470 union {
471 OutputSectionBase<ELFT> *OutSec;
472 uint64_t Val;
473 const SymbolBody *Sym;
474 };
475 enum KindT { SecAddr, SymAddr, PlainInt } Kind;
476 Entry(int32_t Tag, OutputSectionBase<ELFT> *OutSec)
477 : Tag(Tag), OutSec(OutSec), Kind(SecAddr) {}
478 Entry(int32_t Tag, uint64_t Val) : Tag(Tag), Val(Val), Kind(PlainInt) {}
479 Entry(int32_t Tag, const SymbolBody *Sym)
480 : Tag(Tag), Sym(Sym), Kind(SymAddr) {}
481 };
Rui Ueyama909cc682016-02-02 03:11:27 +0000482
483 // finalize() fills this vector with the section contents. finalize()
484 // cannot directly create final section contents because when the
485 // function is called, symbol or section addresses are not fixed yet.
Rafael Espindolade069362016-01-25 21:32:04 +0000486 std::vector<Entry> Entries;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000487
488public:
Rui Ueyama14703662016-05-16 21:06:31 +0000489 explicit DynamicSection(SymbolTable<ELFT> &SymTab);
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000490 void finalize() override;
491 void writeTo(uint8_t *Buf) override;
492
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000493 OutputSectionBase<ELFT> *PreInitArraySec = nullptr;
494 OutputSectionBase<ELFT> *InitArraySec = nullptr;
495 OutputSectionBase<ELFT> *FiniArraySec = nullptr;
Rafael Espindola77572242015-10-02 19:37:55 +0000496
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000497private:
Rui Ueyama3ce825e2015-10-09 21:07:25 +0000498 SymbolTable<ELFT> &SymTab;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000499};
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000500
Simon Atanasyan1d7df402015-12-20 10:57:34 +0000501template <class ELFT>
502class MipsReginfoOutputSection final : public OutputSectionBase<ELFT> {
503 typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
504
505public:
506 MipsReginfoOutputSection();
507 void writeTo(uint8_t *Buf) override;
Rui Ueyama40845e62015-12-26 05:51:07 +0000508 void addSection(InputSectionBase<ELFT> *S) override;
Simon Atanasyan1d7df402015-12-20 10:57:34 +0000509
510private:
Rui Ueyama70eed362016-01-06 22:42:43 +0000511 uint32_t GprMask = 0;
Simon Atanasyan1d7df402015-12-20 10:57:34 +0000512};
513
Simon Atanasyanadd74f32016-05-04 10:07:38 +0000514template <class ELFT>
515class MipsOptionsOutputSection final : public OutputSectionBase<ELFT> {
516 typedef llvm::object::Elf_Mips_Options<ELFT> Elf_Mips_Options;
517 typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
518
519public:
520 MipsOptionsOutputSection();
521 void writeTo(uint8_t *Buf) override;
522 void addSection(InputSectionBase<ELFT> *S) override;
523
524private:
525 uint32_t GprMask = 0;
526};
527
George Rimarf6bc65a2016-01-15 13:34:52 +0000528// --eh-frame-hdr option tells linker to construct a header for all the
529// .eh_frame sections. This header is placed to a section named .eh_frame_hdr
530// and also to a PT_GNU_EH_FRAME segment.
531// At runtime the unwinder then can find all the PT_GNU_EH_FRAME segments by
532// calling dl_iterate_phdr.
533// This section contains a lookup table for quick binary search of FDEs.
534// Detailed info about internals can be found in Ian Lance Taylor's blog:
535// http://www.airs.com/blog/archives/460 (".eh_frame")
536// http://www.airs.com/blog/archives/462 (".eh_frame_hdr")
537template <class ELFT>
538class EhFrameHeader final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000539 typedef typename ELFT::uint uintX_t;
George Rimarf6bc65a2016-01-15 13:34:52 +0000540
541public:
542 EhFrameHeader();
Rui Ueyamade9777a2016-05-23 16:30:41 +0000543 void finalize() override;
George Rimarf6bc65a2016-01-15 13:34:52 +0000544 void writeTo(uint8_t *Buf) override;
Rui Ueyamae75e9332016-05-23 03:00:33 +0000545 void addFde(uint32_t Pc, uint32_t FdeVA);
George Rimarf6bc65a2016-01-15 13:34:52 +0000546
George Rimarf6bc65a2016-01-15 13:34:52 +0000547private:
548 struct FdeData {
Rui Ueyamae75e9332016-05-23 03:00:33 +0000549 uint32_t Pc;
550 uint32_t FdeVA;
George Rimarf6bc65a2016-01-15 13:34:52 +0000551 };
552
553 uintX_t getFdePc(uintX_t EhVA, const FdeData &F);
554
Rui Ueyamae75e9332016-05-23 03:00:33 +0000555 std::vector<FdeData> Fdes;
George Rimarf6bc65a2016-01-15 13:34:52 +0000556};
557
Rui Ueyama3a41be22016-04-07 22:49:21 +0000558template <class ELFT> class BuildIdSection : public OutputSectionBase<ELFT> {
Rui Ueyama634ddf02016-03-11 20:51:53 +0000559public:
Rui Ueyama634ddf02016-03-11 20:51:53 +0000560 void writeTo(uint8_t *Buf) override;
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000561 virtual void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) = 0;
Rui Ueyama3a41be22016-04-07 22:49:21 +0000562
563protected:
564 BuildIdSection(size_t HashSize);
565 size_t HashSize;
566 uint8_t *HashBuf = nullptr;
567};
568
569template <class ELFT> class BuildIdFnv1 final : public BuildIdSection<ELFT> {
570public:
571 BuildIdFnv1() : BuildIdSection<ELFT>(8) {}
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000572 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
Rui Ueyama3a41be22016-04-07 22:49:21 +0000573};
574
575template <class ELFT> class BuildIdMd5 final : public BuildIdSection<ELFT> {
576public:
577 BuildIdMd5() : BuildIdSection<ELFT>(16) {}
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000578 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
Rui Ueyama634ddf02016-03-11 20:51:53 +0000579};
580
Rui Ueyamad86ec302016-04-07 23:51:56 +0000581template <class ELFT> class BuildIdSha1 final : public BuildIdSection<ELFT> {
582public:
583 BuildIdSha1() : BuildIdSection<ELFT>(20) {}
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000584 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
Rui Ueyamad86ec302016-04-07 23:51:56 +0000585};
586
Rui Ueyama9194db72016-05-13 21:55:56 +0000587template <class ELFT>
588class BuildIdHexstring final : public BuildIdSection<ELFT> {
589public:
590 BuildIdHexstring();
591 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
592};
593
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000594// All output sections that are hadnled by the linker specially are
595// globally accessible. Writer initializes them, so don't use them
596// until Writer is initialized.
597template <class ELFT> struct Out {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000598 typedef typename ELFT::uint uintX_t;
599 typedef typename ELFT::Phdr Elf_Phdr;
Rui Ueyama634ddf02016-03-11 20:51:53 +0000600 static BuildIdSection<ELFT> *BuildId;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000601 static DynamicSection<ELFT> *Dynamic;
George Rimarf6bc65a2016-01-15 13:34:52 +0000602 static EhFrameHeader<ELFT> *EhFrameHdr;
Rui Ueyama3b31e672016-05-23 16:24:16 +0000603 static EhOutputSection<ELFT> *EhFrame;
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000604 static GnuHashTableSection<ELFT> *GnuHashTab;
George Rimar648a2c32015-10-20 08:54:27 +0000605 static GotPltSection<ELFT> *GotPlt;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000606 static GotSection<ELFT> *Got;
607 static HashTableSection<ELFT> *HashTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000608 static InterpSection<ELFT> *Interp;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000609 static OutputSection<ELFT> *Bss;
Igor Kudrin304860a2015-11-12 04:39:49 +0000610 static OutputSection<ELFT> *MipsRldMap;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000611 static OutputSectionBase<ELFT> *Opd;
Hal Finkeldaedc122015-10-12 23:16:53 +0000612 static uint8_t *OpdBuf;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000613 static PltSection<ELFT> *Plt;
614 static RelocationSection<ELFT> *RelaDyn;
George Rimar648a2c32015-10-20 08:54:27 +0000615 static RelocationSection<ELFT> *RelaPlt;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000616 static StringTableSection<ELFT> *DynStrTab;
George Rimar0f5ac9f2015-10-20 17:21:35 +0000617 static StringTableSection<ELFT> *ShStrTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000618 static StringTableSection<ELFT> *StrTab;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000619 static SymbolTableSection<ELFT> *DynSymTab;
620 static SymbolTableSection<ELFT> *SymTab;
Peter Collingbourne21a12fc2016-04-27 20:22:31 +0000621 static VersionTableSection<ELFT> *VerSym;
622 static VersionNeedSection<ELFT> *VerNeed;
Rafael Espindolaea7a1e902015-11-06 22:14:44 +0000623 static Elf_Phdr *TlsPhdr;
Rafael Espindola4fc60442016-02-10 22:43:13 +0000624 static OutputSectionBase<ELFT> *ElfHeader;
625 static OutputSectionBase<ELFT> *ProgramHeaders;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000626};
Rui Ueyamad888d102015-10-09 19:34:55 +0000627
Rui Ueyama634ddf02016-03-11 20:51:53 +0000628template <class ELFT> BuildIdSection<ELFT> *Out<ELFT>::BuildId;
Rui Ueyamad888d102015-10-09 19:34:55 +0000629template <class ELFT> DynamicSection<ELFT> *Out<ELFT>::Dynamic;
George Rimarf6bc65a2016-01-15 13:34:52 +0000630template <class ELFT> EhFrameHeader<ELFT> *Out<ELFT>::EhFrameHdr;
Rui Ueyama3b31e672016-05-23 16:24:16 +0000631template <class ELFT> EhOutputSection<ELFT> *Out<ELFT>::EhFrame;
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000632template <class ELFT> GnuHashTableSection<ELFT> *Out<ELFT>::GnuHashTab;
George Rimar648a2c32015-10-20 08:54:27 +0000633template <class ELFT> GotPltSection<ELFT> *Out<ELFT>::GotPlt;
Rui Ueyamad888d102015-10-09 19:34:55 +0000634template <class ELFT> GotSection<ELFT> *Out<ELFT>::Got;
635template <class ELFT> HashTableSection<ELFT> *Out<ELFT>::HashTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000636template <class ELFT> InterpSection<ELFT> *Out<ELFT>::Interp;
Rafael Espindolad7a267b2015-11-03 22:01:20 +0000637template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss;
Igor Kudrin304860a2015-11-12 04:39:49 +0000638template <class ELFT> OutputSection<ELFT> *Out<ELFT>::MipsRldMap;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000639template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::Opd;
Hal Finkeldaedc122015-10-12 23:16:53 +0000640template <class ELFT> uint8_t *Out<ELFT>::OpdBuf;
Rui Ueyamad888d102015-10-09 19:34:55 +0000641template <class ELFT> PltSection<ELFT> *Out<ELFT>::Plt;
642template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaDyn;
George Rimar648a2c32015-10-20 08:54:27 +0000643template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaPlt;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000644template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::DynStrTab;
George Rimar0f5ac9f2015-10-20 17:21:35 +0000645template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::ShStrTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000646template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::StrTab;
Rui Ueyamad888d102015-10-09 19:34:55 +0000647template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::DynSymTab;
648template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::SymTab;
Peter Collingbourne21a12fc2016-04-27 20:22:31 +0000649template <class ELFT> VersionTableSection<ELFT> *Out<ELFT>::VerSym;
650template <class ELFT> VersionNeedSection<ELFT> *Out<ELFT>::VerNeed;
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000651template <class ELFT> typename ELFT::Phdr *Out<ELFT>::TlsPhdr;
Rafael Espindola4fc60442016-02-10 22:43:13 +0000652template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ElfHeader;
653template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ProgramHeaders;
Eugene Zelenko6e43b492015-11-04 02:11:57 +0000654
Rafael Espindolae0df00b2016-02-28 00:25:54 +0000655} // namespace elf
Eugene Zelenko6e43b492015-11-04 02:11:57 +0000656} // namespace lld
657
658#endif // LLD_ELF_OUTPUT_SECTIONS_H