blob: e2bf3949d648407bf09f45533435d23f48aae5ed [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
Rui Ueyama022d8e82016-05-24 03:36:07 +0000137 // Flag to force GOT to be in output if we have relocations
138 // that relies on its address.
139 bool HasGotOffRel = false;
140
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000141private:
142 std::vector<const SymbolBody *> Entries;
Rui Ueyama0e53c7d2016-02-05 00:10:02 +0000143 uint32_t TlsIndexOff = -1;
Simon Atanasyan56ab5f02016-01-21 05:33:23 +0000144 uint32_t MipsLocalEntries = 0;
Simon Atanasyand2980d32016-03-29 14:07:22 +0000145 // Output sections referenced by MIPS GOT relocations.
146 llvm::SmallPtrSet<const OutputSectionBase<ELFT> *, 10> MipsOutSections;
Simon Atanasyan56ab5f02016-01-21 05:33:23 +0000147 llvm::DenseMap<uintX_t, size_t> MipsLocalGotPos;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000148};
149
George Rimar648a2c32015-10-20 08:54:27 +0000150template <class ELFT>
151class GotPltSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000152 typedef typename ELFT::uint uintX_t;
George Rimar648a2c32015-10-20 08:54:27 +0000153
154public:
155 GotPltSection();
156 void finalize() override;
157 void writeTo(uint8_t *Buf) override;
Rafael Espindola67d72c02016-03-11 12:06:30 +0000158 void addEntry(SymbolBody &Sym);
George Rimar648a2c32015-10-20 08:54:27 +0000159 bool empty() const;
George Rimar648a2c32015-10-20 08:54:27 +0000160
161private:
162 std::vector<const SymbolBody *> Entries;
163};
164
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000165template <class ELFT> class PltSection final : public OutputSectionBase<ELFT> {
166 typedef OutputSectionBase<ELFT> Base;
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000167 typedef typename ELFT::uint uintX_t;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000168
169public:
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000170 PltSection();
Hal Finkel6c2a3b82015-10-08 21:51:31 +0000171 void finalize() override;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000172 void writeTo(uint8_t *Buf) override;
Rafael Espindola67d72c02016-03-11 12:06:30 +0000173 void addEntry(SymbolBody &Sym);
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000174 bool empty() const { return Entries.empty(); }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000175
176private:
George Rimar77b77792015-11-25 22:15:01 +0000177 std::vector<std::pair<const SymbolBody *, unsigned>> Entries;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000178};
179
180template <class ELFT> struct DynamicReloc {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000181 typedef typename ELFT::uint uintX_t;
Rafael Espindolade9857e2016-02-04 21:33:05 +0000182 uint32_t Type;
183
Rafael Espindolaac568f92016-04-11 13:47:35 +0000184 SymbolBody *Sym;
Rafael Espindola34ffcbb2016-04-11 13:51:23 +0000185 const OutputSectionBase<ELFT> *OffsetSec;
Rafael Espindolaac568f92016-04-11 13:47:35 +0000186 uintX_t OffsetInSec;
187 bool UseSymVA;
188 uintX_t Addend;
Rafael Espindolade9857e2016-02-04 21:33:05 +0000189
Rafael Espindola34ffcbb2016-04-11 13:51:23 +0000190 DynamicReloc(uint32_t Type, const OutputSectionBase<ELFT> *OffsetSec,
Rafael Espindolade9857e2016-02-04 21:33:05 +0000191 uintX_t OffsetInSec, bool UseSymVA, SymbolBody *Sym,
192 uintX_t Addend)
Rafael Espindola74031ba2016-04-07 15:20:56 +0000193 : Type(Type), Sym(Sym), OffsetSec(OffsetSec), OffsetInSec(OffsetInSec),
194 UseSymVA(UseSymVA), Addend(Addend) {}
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000195};
196
197template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000198class SymbolTableSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000199public:
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000200 typedef typename ELFT::Shdr Elf_Shdr;
201 typedef typename ELFT::Sym Elf_Sym;
202 typedef typename ELFT::SymRange Elf_Sym_Range;
203 typedef typename ELFT::uint uintX_t;
Rui Ueyama3ce825e2015-10-09 21:07:25 +0000204 SymbolTableSection(SymbolTable<ELFT> &Table,
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000205 StringTableSection<ELFT> &StrTabSec);
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000206
Rui Ueyama0db335f2015-10-07 16:58:54 +0000207 void finalize() override;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000208 void writeTo(uint8_t *Buf) override;
Igor Kudrinab665fc2015-10-20 21:47:58 +0000209 void addSymbol(SymbolBody *Body);
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000210 StringTableSection<ELFT> &getStrTabSec() const { return StrTabSec; }
Rafael Espindola0e92f242016-01-27 16:41:24 +0000211 unsigned getNumSymbols() const { return NumLocals + Symbols.size() + 1; }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000212
Rui Ueyamac2e863a2016-02-17 05:06:40 +0000213 ArrayRef<std::pair<SymbolBody *, size_t>> getSymbols() const {
Rafael Espindolae2c24612016-01-29 01:24:25 +0000214 return Symbols;
215 }
216
217 unsigned NumLocals = 0;
218 StringTableSection<ELFT> &StrTabSec;
Igor Kudrinab665fc2015-10-20 21:47:58 +0000219
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000220private:
Rui Ueyama8ddfa812015-09-30 00:32:10 +0000221 void writeLocalSymbols(uint8_t *&Buf);
Igor Kudrinea6a8352015-10-19 08:01:51 +0000222 void writeGlobalSymbols(uint8_t *Buf);
Rui Ueyama8ddfa812015-09-30 00:32:10 +0000223
Rui Ueyama874e7ae2016-02-17 04:56:44 +0000224 const OutputSectionBase<ELFT> *getOutputSection(SymbolBody *Sym);
Igor Kudrin853b88d2015-10-20 20:52:14 +0000225
Rui Ueyama3ce825e2015-10-09 21:07:25 +0000226 SymbolTable<ELFT> &Table;
Rui Ueyamac2e863a2016-02-17 05:06:40 +0000227
228 // A vector of symbols and their string table offsets.
229 std::vector<std::pair<SymbolBody *, size_t>> Symbols;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000230};
231
Peter Collingbourne21a12fc2016-04-27 20:22:31 +0000232// For more information about .gnu.version and .gnu.version_r see:
233// https://www.akkadia.org/drepper/symbol-versioning
234
235// The .gnu.version section specifies the required version of each symbol in the
236// dynamic symbol table. It contains one Elf_Versym for each dynamic symbol
237// table entry. An Elf_Versym is just a 16-bit integer that refers to a version
238// identifier defined in the .gnu.version_r section.
239template <class ELFT>
240class VersionTableSection final : public OutputSectionBase<ELFT> {
241 typedef typename ELFT::Versym Elf_Versym;
242
243public:
244 VersionTableSection();
245 void finalize() override;
246 void writeTo(uint8_t *Buf) override;
247};
248
249// The .gnu.version_r section defines the version identifiers used by
250// .gnu.version. It contains a linked list of Elf_Verneed data structures. Each
251// Elf_Verneed specifies the version requirements for a single DSO, and contains
252// a reference to a linked list of Elf_Vernaux data structures which define the
253// mapping from version identifiers to version names.
254template <class ELFT>
255class VersionNeedSection final : public OutputSectionBase<ELFT> {
256 typedef typename ELFT::Verneed Elf_Verneed;
257 typedef typename ELFT::Vernaux Elf_Vernaux;
258
259 // A vector of shared files that need Elf_Verneed data structures and the
260 // string table offsets of their sonames.
261 std::vector<std::pair<SharedFile<ELFT> *, size_t>> Needed;
262
263 // The next available version identifier. Identifiers start at 2 because 0 and
264 // 1 are reserved.
265 unsigned NextIndex = 2;
266
267public:
268 VersionNeedSection();
269 void addSymbol(SharedSymbol<ELFT> *SS);
270 void finalize() override;
271 void writeTo(uint8_t *Buf) override;
272 size_t getNeedNum() const { return Needed.size(); }
273};
274
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000275template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000276class RelocationSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000277 typedef typename ELFT::Rel Elf_Rel;
278 typedef typename ELFT::Rela Elf_Rela;
279 typedef typename ELFT::uint uintX_t;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000280
281public:
George Rimarc191acf2016-05-10 15:47:57 +0000282 RelocationSection(StringRef Name, bool Sort);
Rafael Espindolad30eb7d2016-02-05 15:03:10 +0000283 void addReloc(const DynamicReloc<ELFT> &Reloc);
George Rimar77b77792015-11-25 22:15:01 +0000284 unsigned getRelocOffset();
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000285 void finalize() override;
286 void writeTo(uint8_t *Buf) override;
287 bool hasRelocs() const { return !Relocs.empty(); }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000288
George Rimara07ff662015-12-21 10:12:06 +0000289 bool Static = false;
290
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000291private:
George Rimarc191acf2016-05-10 15:47:57 +0000292 bool Sort;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000293 std::vector<DynamicReloc<ELFT>> Relocs;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000294};
295
296template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000297class OutputSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000298public:
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000299 typedef typename ELFT::Shdr Elf_Shdr;
300 typedef typename ELFT::Sym Elf_Sym;
301 typedef typename ELFT::Rel Elf_Rel;
302 typedef typename ELFT::Rela Elf_Rela;
303 typedef typename ELFT::uint uintX_t;
George Rimar9bec24a2016-02-18 14:20:08 +0000304 OutputSection(StringRef Name, uint32_t Type, uintX_t Flags);
Rui Ueyama40845e62015-12-26 05:51:07 +0000305 void addSection(InputSectionBase<ELFT> *C) override;
Rui Ueyama5af83682016-02-11 23:41:38 +0000306 void sortInitFini();
307 void sortCtorsDtors();
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000308 void writeTo(uint8_t *Buf) override;
George Rimar58941ee2016-02-25 08:23:37 +0000309 void finalize() override;
Rafael Espindola56004c52016-04-07 14:22:09 +0000310 void
311 forEachInputSection(std::function<void(InputSectionBase<ELFT> *)> F) override;
Rafael Espindola71675852015-09-22 00:16:19 +0000312 std::vector<InputSection<ELFT> *> Sections;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000313};
314
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000315template <class ELFT>
Rafael Espindolac159c962015-10-19 21:00:02 +0000316class MergeOutputSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000317 typedef typename ELFT::uint uintX_t;
Rafael Espindolac159c962015-10-19 21:00:02 +0000318
319public:
Rafael Espindola7efa5be2016-02-19 14:17:40 +0000320 MergeOutputSection(StringRef Name, uint32_t Type, uintX_t Flags,
321 uintX_t Alignment);
Rui Ueyama40845e62015-12-26 05:51:07 +0000322 void addSection(InputSectionBase<ELFT> *S) override;
Rafael Espindolac159c962015-10-19 21:00:02 +0000323 void writeTo(uint8_t *Buf) override;
Rafael Espindolaf82ed2a2015-10-24 22:51:01 +0000324 unsigned getOffset(StringRef Val);
325 void finalize() override;
Peter Collingbournee29e1422016-05-05 04:10:12 +0000326 bool shouldTailMerge() const;
Rafael Espindolac159c962015-10-19 21:00:02 +0000327
328private:
Rafael Espindola7efa5be2016-02-19 14:17:40 +0000329 llvm::StringTableBuilder Builder;
Rafael Espindolac159c962015-10-19 21:00:02 +0000330};
331
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000332struct CieRecord {
333 SectionPiece *Piece = nullptr;
334 std::vector<SectionPiece *> FdePieces;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000335};
336
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000337// Output section for .eh_frame.
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000338template <class ELFT>
Rui Ueyama1e479c22016-05-23 15:07:59 +0000339class EhOutputSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000340 typedef typename ELFT::uint uintX_t;
341 typedef typename ELFT::Shdr Elf_Shdr;
342 typedef typename ELFT::Rel Elf_Rel;
343 typedef typename ELFT::Rela Elf_Rela;
Rui Ueyamaf86cb902016-05-23 15:12:41 +0000344
345public:
346 EhOutputSection();
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000347 void writeTo(uint8_t *Buf) override;
Rafael Espindola56004c52016-04-07 14:22:09 +0000348 void finalize() override;
Rui Ueyama3b31e672016-05-23 16:24:16 +0000349 bool empty() const { return Sections.empty(); }
Rafael Espindola56004c52016-04-07 14:22:09 +0000350 void
351 forEachInputSection(std::function<void(InputSectionBase<ELFT> *)> F) override;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000352
Rui Ueyama40845e62015-12-26 05:51:07 +0000353 void addSection(InputSectionBase<ELFT> *S) override;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000354
Rui Ueyamade9777a2016-05-23 16:30:41 +0000355 size_t NumFdes = 0;
356
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000357private:
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000358 template <class RelTy>
359 void addSectionAux(EHInputSection<ELFT> *S, llvm::ArrayRef<RelTy> Rels);
360
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000361 template <class RelTy>
Rui Ueyamae2060aa2016-05-22 23:52:56 +0000362 CieRecord *addCie(SectionPiece &Piece, EHInputSection<ELFT> *Sec,
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000363 ArrayRef<RelTy> Rels);
364
365 template <class RelTy>
366 bool isFdeLive(SectionPiece &Piece, EHInputSection<ELFT> *Sec,
367 ArrayRef<RelTy> Rels);
368
Rui Ueyamae75e9332016-05-23 03:00:33 +0000369 uintX_t getFdePc(uint8_t *Buf, size_t Off, uint8_t Enc);
370
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000371 std::vector<EHInputSection<ELFT> *> Sections;
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000372 std::vector<CieRecord *> Cies;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000373
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000374 // CIE records are uniquified by their contents and personality functions.
375 llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
376
Rafael Espindola56004c52016-04-07 14:22:09 +0000377 bool Finalized = false;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000378};
379
Rafael Espindolac159c962015-10-19 21:00:02 +0000380template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000381class InterpSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000382public:
383 InterpSection();
Eugene Zelenko6e43b492015-11-04 02:11:57 +0000384 void writeTo(uint8_t *Buf) override;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000385};
386
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000387template <class ELFT>
388class StringTableSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000389public:
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000390 typedef typename ELFT::uint uintX_t;
George Rimar0f5ac9f2015-10-20 17:21:35 +0000391 StringTableSection(StringRef Name, bool Dynamic);
Rafael Espindolae2c24612016-01-29 01:24:25 +0000392 unsigned addString(StringRef S, bool HashIt = true);
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000393 void writeTo(uint8_t *Buf) override;
Rafael Espindolae2c24612016-01-29 01:24:25 +0000394 unsigned getSize() const { return Size; }
Rui Ueyama76c00632016-01-07 02:35:32 +0000395 void finalize() override { this->Header.sh_size = getSize(); }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000396 bool isDynamic() const { return Dynamic; }
397
398private:
399 const bool Dynamic;
Rafael Espindolae2c24612016-01-29 01:24:25 +0000400 llvm::DenseMap<StringRef, unsigned> StringMap;
Rui Ueyama76c00632016-01-07 02:35:32 +0000401 std::vector<StringRef> Strings;
Rafael Espindolae2c24612016-01-29 01:24:25 +0000402 unsigned Size = 1; // ELF string tables start with a NUL byte, so 1.
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000403};
404
405template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000406class HashTableSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000407 typedef typename ELFT::Word Elf_Word;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000408
409public:
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000410 HashTableSection();
Rui Ueyama0db335f2015-10-07 16:58:54 +0000411 void finalize() override;
412 void writeTo(uint8_t *Buf) override;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000413};
414
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000415// Outputs GNU Hash section. For detailed explanation see:
416// https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections
417template <class ELFT>
418class GnuHashTableSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000419 typedef typename ELFT::Off Elf_Off;
420 typedef typename ELFT::Word Elf_Word;
421 typedef typename ELFT::uint uintX_t;
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000422
423public:
424 GnuHashTableSection();
425 void finalize() override;
426 void writeTo(uint8_t *Buf) override;
427
Igor Kudrinf1d60292015-10-28 07:05:56 +0000428 // Adds symbols to the hash table.
429 // Sorts the input to satisfy GNU hash section requirements.
Rui Ueyamac2e863a2016-02-17 05:06:40 +0000430 void addSymbols(std::vector<std::pair<SymbolBody *, size_t>> &Symbols);
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000431
432private:
Igor Kudrinf1d60292015-10-28 07:05:56 +0000433 static unsigned calcNBuckets(unsigned NumHashed);
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000434 static unsigned calcMaskWords(unsigned NumHashed);
435
436 void writeHeader(uint8_t *&Buf);
437 void writeBloomFilter(uint8_t *&Buf);
438 void writeHashTable(uint8_t *Buf);
439
Rui Ueyama861c7312016-02-17 05:40:03 +0000440 struct SymbolData {
Igor Kudrinf1d60292015-10-28 07:05:56 +0000441 SymbolBody *Body;
Rui Ueyamac2e863a2016-02-17 05:06:40 +0000442 size_t STName;
Igor Kudrinf1d60292015-10-28 07:05:56 +0000443 uint32_t Hash;
444 };
445
Rui Ueyama861c7312016-02-17 05:40:03 +0000446 std::vector<SymbolData> Symbols;
Igor Kudrinf1d60292015-10-28 07:05:56 +0000447
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000448 unsigned MaskWords;
449 unsigned NBuckets;
450 unsigned Shift2;
451};
452
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000453template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000454class DynamicSection final : public OutputSectionBase<ELFT> {
455 typedef OutputSectionBase<ELFT> Base;
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000456 typedef typename ELFT::Dyn Elf_Dyn;
457 typedef typename ELFT::Rel Elf_Rel;
458 typedef typename ELFT::Rela Elf_Rela;
459 typedef typename ELFT::Shdr Elf_Shdr;
460 typedef typename ELFT::Sym Elf_Sym;
461 typedef typename ELFT::uint uintX_t;
Rafael Espindolade069362016-01-25 21:32:04 +0000462
Rui Ueyama909cc682016-02-02 03:11:27 +0000463 // The .dynamic section contains information for the dynamic linker.
464 // The section consists of fixed size entries, which consist of
465 // type and value fields. Value are one of plain integers, symbol
466 // addresses, or section addresses. This struct represents the entry.
Rafael Espindolade069362016-01-25 21:32:04 +0000467 struct Entry {
468 int32_t Tag;
469 union {
470 OutputSectionBase<ELFT> *OutSec;
471 uint64_t Val;
472 const SymbolBody *Sym;
473 };
474 enum KindT { SecAddr, SymAddr, PlainInt } Kind;
475 Entry(int32_t Tag, OutputSectionBase<ELFT> *OutSec)
476 : Tag(Tag), OutSec(OutSec), Kind(SecAddr) {}
477 Entry(int32_t Tag, uint64_t Val) : Tag(Tag), Val(Val), Kind(PlainInt) {}
478 Entry(int32_t Tag, const SymbolBody *Sym)
479 : Tag(Tag), Sym(Sym), Kind(SymAddr) {}
480 };
Rui Ueyama909cc682016-02-02 03:11:27 +0000481
482 // finalize() fills this vector with the section contents. finalize()
483 // cannot directly create final section contents because when the
484 // function is called, symbol or section addresses are not fixed yet.
Rafael Espindolade069362016-01-25 21:32:04 +0000485 std::vector<Entry> Entries;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000486
487public:
Rui Ueyama14703662016-05-16 21:06:31 +0000488 explicit DynamicSection(SymbolTable<ELFT> &SymTab);
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000489 void finalize() override;
490 void writeTo(uint8_t *Buf) override;
491
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000492 OutputSectionBase<ELFT> *PreInitArraySec = nullptr;
493 OutputSectionBase<ELFT> *InitArraySec = nullptr;
494 OutputSectionBase<ELFT> *FiniArraySec = nullptr;
Rafael Espindola77572242015-10-02 19:37:55 +0000495
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000496private:
Rui Ueyama3ce825e2015-10-09 21:07:25 +0000497 SymbolTable<ELFT> &SymTab;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000498};
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000499
Simon Atanasyan1d7df402015-12-20 10:57:34 +0000500template <class ELFT>
501class MipsReginfoOutputSection final : public OutputSectionBase<ELFT> {
502 typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
503
504public:
505 MipsReginfoOutputSection();
506 void writeTo(uint8_t *Buf) override;
Rui Ueyama40845e62015-12-26 05:51:07 +0000507 void addSection(InputSectionBase<ELFT> *S) override;
Simon Atanasyan1d7df402015-12-20 10:57:34 +0000508
509private:
Rui Ueyama70eed362016-01-06 22:42:43 +0000510 uint32_t GprMask = 0;
Simon Atanasyan1d7df402015-12-20 10:57:34 +0000511};
512
Simon Atanasyanadd74f32016-05-04 10:07:38 +0000513template <class ELFT>
514class MipsOptionsOutputSection final : public OutputSectionBase<ELFT> {
515 typedef llvm::object::Elf_Mips_Options<ELFT> Elf_Mips_Options;
516 typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
517
518public:
519 MipsOptionsOutputSection();
520 void writeTo(uint8_t *Buf) override;
521 void addSection(InputSectionBase<ELFT> *S) override;
522
523private:
524 uint32_t GprMask = 0;
525};
526
George Rimarf6bc65a2016-01-15 13:34:52 +0000527// --eh-frame-hdr option tells linker to construct a header for all the
528// .eh_frame sections. This header is placed to a section named .eh_frame_hdr
529// and also to a PT_GNU_EH_FRAME segment.
530// At runtime the unwinder then can find all the PT_GNU_EH_FRAME segments by
531// calling dl_iterate_phdr.
532// This section contains a lookup table for quick binary search of FDEs.
533// Detailed info about internals can be found in Ian Lance Taylor's blog:
534// http://www.airs.com/blog/archives/460 (".eh_frame")
535// http://www.airs.com/blog/archives/462 (".eh_frame_hdr")
536template <class ELFT>
537class EhFrameHeader final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000538 typedef typename ELFT::uint uintX_t;
George Rimarf6bc65a2016-01-15 13:34:52 +0000539
540public:
541 EhFrameHeader();
Rui Ueyamade9777a2016-05-23 16:30:41 +0000542 void finalize() override;
George Rimarf6bc65a2016-01-15 13:34:52 +0000543 void writeTo(uint8_t *Buf) override;
Rui Ueyamae75e9332016-05-23 03:00:33 +0000544 void addFde(uint32_t Pc, uint32_t FdeVA);
George Rimarf6bc65a2016-01-15 13:34:52 +0000545
George Rimarf6bc65a2016-01-15 13:34:52 +0000546private:
547 struct FdeData {
Rui Ueyamae75e9332016-05-23 03:00:33 +0000548 uint32_t Pc;
549 uint32_t FdeVA;
George Rimarf6bc65a2016-01-15 13:34:52 +0000550 };
551
Rui Ueyamae75e9332016-05-23 03:00:33 +0000552 std::vector<FdeData> Fdes;
George Rimarf6bc65a2016-01-15 13:34:52 +0000553};
554
Rui Ueyama3a41be22016-04-07 22:49:21 +0000555template <class ELFT> class BuildIdSection : public OutputSectionBase<ELFT> {
Rui Ueyama634ddf02016-03-11 20:51:53 +0000556public:
Rui Ueyama634ddf02016-03-11 20:51:53 +0000557 void writeTo(uint8_t *Buf) override;
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000558 virtual void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) = 0;
Rui Ueyama3a41be22016-04-07 22:49:21 +0000559
560protected:
561 BuildIdSection(size_t HashSize);
562 size_t HashSize;
563 uint8_t *HashBuf = nullptr;
564};
565
566template <class ELFT> class BuildIdFnv1 final : public BuildIdSection<ELFT> {
567public:
568 BuildIdFnv1() : BuildIdSection<ELFT>(8) {}
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000569 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
Rui Ueyama3a41be22016-04-07 22:49:21 +0000570};
571
572template <class ELFT> class BuildIdMd5 final : public BuildIdSection<ELFT> {
573public:
574 BuildIdMd5() : BuildIdSection<ELFT>(16) {}
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000575 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
Rui Ueyama634ddf02016-03-11 20:51:53 +0000576};
577
Rui Ueyamad86ec302016-04-07 23:51:56 +0000578template <class ELFT> class BuildIdSha1 final : public BuildIdSection<ELFT> {
579public:
580 BuildIdSha1() : BuildIdSection<ELFT>(20) {}
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000581 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
Rui Ueyamad86ec302016-04-07 23:51:56 +0000582};
583
Rui Ueyama9194db72016-05-13 21:55:56 +0000584template <class ELFT>
585class BuildIdHexstring final : public BuildIdSection<ELFT> {
586public:
587 BuildIdHexstring();
588 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
589};
590
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000591// All output sections that are hadnled by the linker specially are
592// globally accessible. Writer initializes them, so don't use them
593// until Writer is initialized.
594template <class ELFT> struct Out {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000595 typedef typename ELFT::uint uintX_t;
596 typedef typename ELFT::Phdr Elf_Phdr;
Rui Ueyama634ddf02016-03-11 20:51:53 +0000597 static BuildIdSection<ELFT> *BuildId;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000598 static DynamicSection<ELFT> *Dynamic;
George Rimarf6bc65a2016-01-15 13:34:52 +0000599 static EhFrameHeader<ELFT> *EhFrameHdr;
Rui Ueyama3b31e672016-05-23 16:24:16 +0000600 static EhOutputSection<ELFT> *EhFrame;
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000601 static GnuHashTableSection<ELFT> *GnuHashTab;
George Rimar648a2c32015-10-20 08:54:27 +0000602 static GotPltSection<ELFT> *GotPlt;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000603 static GotSection<ELFT> *Got;
604 static HashTableSection<ELFT> *HashTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000605 static InterpSection<ELFT> *Interp;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000606 static OutputSection<ELFT> *Bss;
Igor Kudrin304860a2015-11-12 04:39:49 +0000607 static OutputSection<ELFT> *MipsRldMap;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000608 static OutputSectionBase<ELFT> *Opd;
Hal Finkeldaedc122015-10-12 23:16:53 +0000609 static uint8_t *OpdBuf;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000610 static PltSection<ELFT> *Plt;
611 static RelocationSection<ELFT> *RelaDyn;
George Rimar648a2c32015-10-20 08:54:27 +0000612 static RelocationSection<ELFT> *RelaPlt;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000613 static StringTableSection<ELFT> *DynStrTab;
George Rimar0f5ac9f2015-10-20 17:21:35 +0000614 static StringTableSection<ELFT> *ShStrTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000615 static StringTableSection<ELFT> *StrTab;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000616 static SymbolTableSection<ELFT> *DynSymTab;
617 static SymbolTableSection<ELFT> *SymTab;
Peter Collingbourne21a12fc2016-04-27 20:22:31 +0000618 static VersionTableSection<ELFT> *VerSym;
619 static VersionNeedSection<ELFT> *VerNeed;
Rafael Espindolaea7a1e902015-11-06 22:14:44 +0000620 static Elf_Phdr *TlsPhdr;
Rafael Espindola4fc60442016-02-10 22:43:13 +0000621 static OutputSectionBase<ELFT> *ElfHeader;
622 static OutputSectionBase<ELFT> *ProgramHeaders;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000623};
Rui Ueyamad888d102015-10-09 19:34:55 +0000624
Rui Ueyama634ddf02016-03-11 20:51:53 +0000625template <class ELFT> BuildIdSection<ELFT> *Out<ELFT>::BuildId;
Rui Ueyamad888d102015-10-09 19:34:55 +0000626template <class ELFT> DynamicSection<ELFT> *Out<ELFT>::Dynamic;
George Rimarf6bc65a2016-01-15 13:34:52 +0000627template <class ELFT> EhFrameHeader<ELFT> *Out<ELFT>::EhFrameHdr;
Rui Ueyama3b31e672016-05-23 16:24:16 +0000628template <class ELFT> EhOutputSection<ELFT> *Out<ELFT>::EhFrame;
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000629template <class ELFT> GnuHashTableSection<ELFT> *Out<ELFT>::GnuHashTab;
George Rimar648a2c32015-10-20 08:54:27 +0000630template <class ELFT> GotPltSection<ELFT> *Out<ELFT>::GotPlt;
Rui Ueyamad888d102015-10-09 19:34:55 +0000631template <class ELFT> GotSection<ELFT> *Out<ELFT>::Got;
632template <class ELFT> HashTableSection<ELFT> *Out<ELFT>::HashTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000633template <class ELFT> InterpSection<ELFT> *Out<ELFT>::Interp;
Rafael Espindolad7a267b2015-11-03 22:01:20 +0000634template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss;
Igor Kudrin304860a2015-11-12 04:39:49 +0000635template <class ELFT> OutputSection<ELFT> *Out<ELFT>::MipsRldMap;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000636template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::Opd;
Hal Finkeldaedc122015-10-12 23:16:53 +0000637template <class ELFT> uint8_t *Out<ELFT>::OpdBuf;
Rui Ueyamad888d102015-10-09 19:34:55 +0000638template <class ELFT> PltSection<ELFT> *Out<ELFT>::Plt;
639template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaDyn;
George Rimar648a2c32015-10-20 08:54:27 +0000640template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaPlt;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000641template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::DynStrTab;
George Rimar0f5ac9f2015-10-20 17:21:35 +0000642template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::ShStrTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000643template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::StrTab;
Rui Ueyamad888d102015-10-09 19:34:55 +0000644template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::DynSymTab;
645template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::SymTab;
Peter Collingbourne21a12fc2016-04-27 20:22:31 +0000646template <class ELFT> VersionTableSection<ELFT> *Out<ELFT>::VerSym;
647template <class ELFT> VersionNeedSection<ELFT> *Out<ELFT>::VerNeed;
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000648template <class ELFT> typename ELFT::Phdr *Out<ELFT>::TlsPhdr;
Rafael Espindola4fc60442016-02-10 22:43:13 +0000649template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ElfHeader;
650template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ProgramHeaders;
Eugene Zelenko6e43b492015-11-04 02:11:57 +0000651
Rafael Espindolae0df00b2016-02-28 00:25:54 +0000652} // namespace elf
Eugene Zelenko6e43b492015-11-04 02:11:57 +0000653} // namespace lld
654
655#endif // LLD_ELF_OUTPUT_SECTIONS_H