blob: 89665a063bc66ac85ceb0f740bfebeff1e5567cc [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;
Rui Ueyama0b9a9032016-05-24 04:19:20 +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; }
Rui Ueyama424b4082016-06-17 01:18:46 +000080 uintX_t getAlignment() 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; }
Rui Ueyama424b4082016-06-17 01:18:46 +000086 void updateAlignment(uintX_t Alignment) {
87 if (Alignment > Header.sh_addralign)
88 Header.sh_addralign = Alignment;
Rafael Espindola115f0f32015-11-03 14:13:40 +000089 }
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() {}
Rui Ueyama406b4692016-05-27 14:39:13 +000096 virtual void finalizePieces() {}
Rafael Espindola56004c52016-04-07 14:22:09 +000097 virtual void
98 forEachInputSection(std::function<void(InputSectionBase<ELFT> *)> F) {}
Rafael Espindola4fc60442016-02-10 22:43:13 +000099 virtual void writeTo(uint8_t *Buf) {}
Rui Ueyamad4ea7dd2015-12-26 07:01:26 +0000100 virtual ~OutputSectionBase() = default;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000101
102protected:
103 StringRef Name;
Sean Silva580c1b62016-04-20 04:26:16 +0000104 Elf_Shdr Header;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000105};
106
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000107template <class ELFT> class GotSection final : public OutputSectionBase<ELFT> {
108 typedef OutputSectionBase<ELFT> Base;
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000109 typedef typename ELFT::uint uintX_t;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000110
111public:
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000112 GotSection();
Igor Kudrin15cd9ff2015-11-06 07:43:03 +0000113 void finalize() override;
Rafael Espindolaa6627382015-10-06 23:56:53 +0000114 void writeTo(uint8_t *Buf) override;
Rafael Espindola67d72c02016-03-11 12:06:30 +0000115 void addEntry(SymbolBody &Sym);
Rafael Espindola67d72c02016-03-11 12:06:30 +0000116 bool addDynTlsEntry(SymbolBody &Sym);
Rui Ueyama0e53c7d2016-02-05 00:10:02 +0000117 bool addTlsIndex();
Simon Atanasyan56ab5f02016-01-21 05:33:23 +0000118 bool empty() const { return MipsLocalEntries == 0 && Entries.empty(); }
Rafael Espindola58cd5db2016-04-19 22:46:03 +0000119 uintX_t getMipsLocalEntryOffset(uintX_t EntryValue);
120 uintX_t getMipsLocalPageOffset(uintX_t Addr);
George Rimar90cd0a82015-12-01 19:20:26 +0000121 uintX_t getGlobalDynAddr(const SymbolBody &B) const;
Rafael Espindola74031ba2016-04-07 15:20:56 +0000122 uintX_t getGlobalDynOffset(const SymbolBody &B) const;
George Rimar9db204a2015-12-02 09:58:20 +0000123 uintX_t getNumEntries() const { return Entries.size(); }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000124
Igor Kudrin304860a2015-11-12 04:39:49 +0000125 // Returns the symbol which corresponds to the first entry of the global part
126 // of GOT on MIPS platform. It is required to fill up MIPS-specific dynamic
127 // table properties.
128 // Returns nullptr if the global part is empty.
129 const SymbolBody *getMipsFirstGlobalEntry() const;
130
131 // Returns the number of entries in the local part of GOT including
132 // the number of reserved entries. This method is MIPS-specific.
133 unsigned getMipsLocalEntriesNum() const;
134
Rui Ueyama0e53c7d2016-02-05 00:10:02 +0000135 uintX_t getTlsIndexVA() { return Base::getVA() + TlsIndexOff; }
Rafael Espindola74031ba2016-04-07 15:20:56 +0000136 uint32_t getTlsIndexOff() { return TlsIndexOff; }
George Rimarb17f7392015-12-01 18:24:07 +0000137
Rui Ueyama022d8e82016-05-24 03:36:07 +0000138 // Flag to force GOT to be in output if we have relocations
139 // that relies on its address.
140 bool HasGotOffRel = false;
141
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000142private:
143 std::vector<const SymbolBody *> Entries;
Rui Ueyama0e53c7d2016-02-05 00:10:02 +0000144 uint32_t TlsIndexOff = -1;
Simon Atanasyan56ab5f02016-01-21 05:33:23 +0000145 uint32_t MipsLocalEntries = 0;
Simon Atanasyand2980d32016-03-29 14:07:22 +0000146 // Output sections referenced by MIPS GOT relocations.
147 llvm::SmallPtrSet<const OutputSectionBase<ELFT> *, 10> MipsOutSections;
Simon Atanasyan56ab5f02016-01-21 05:33:23 +0000148 llvm::DenseMap<uintX_t, size_t> MipsLocalGotPos;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000149};
150
George Rimar648a2c32015-10-20 08:54:27 +0000151template <class ELFT>
152class GotPltSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000153 typedef typename ELFT::uint uintX_t;
George Rimar648a2c32015-10-20 08:54:27 +0000154
155public:
156 GotPltSection();
157 void finalize() override;
158 void writeTo(uint8_t *Buf) override;
Rafael Espindola67d72c02016-03-11 12:06:30 +0000159 void addEntry(SymbolBody &Sym);
George Rimar648a2c32015-10-20 08:54:27 +0000160 bool empty() const;
George Rimar648a2c32015-10-20 08:54:27 +0000161
162private:
163 std::vector<const SymbolBody *> Entries;
164};
165
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000166template <class ELFT> class PltSection final : public OutputSectionBase<ELFT> {
167 typedef OutputSectionBase<ELFT> Base;
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000168 typedef typename ELFT::uint uintX_t;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000169
170public:
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000171 PltSection();
Hal Finkel6c2a3b82015-10-08 21:51:31 +0000172 void finalize() override;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000173 void writeTo(uint8_t *Buf) override;
Rafael Espindola67d72c02016-03-11 12:06:30 +0000174 void addEntry(SymbolBody &Sym);
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000175 bool empty() const { return Entries.empty(); }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000176
177private:
George Rimar77b77792015-11-25 22:15:01 +0000178 std::vector<std::pair<const SymbolBody *, unsigned>> Entries;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000179};
180
181template <class ELFT> struct DynamicReloc {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000182 typedef typename ELFT::uint uintX_t;
Rafael Espindolade9857e2016-02-04 21:33:05 +0000183 uint32_t Type;
184
Rafael Espindolaac568f92016-04-11 13:47:35 +0000185 SymbolBody *Sym;
Rafael Espindola34ffcbb2016-04-11 13:51:23 +0000186 const OutputSectionBase<ELFT> *OffsetSec;
Rafael Espindolaac568f92016-04-11 13:47:35 +0000187 uintX_t OffsetInSec;
188 bool UseSymVA;
189 uintX_t Addend;
Rafael Espindolade9857e2016-02-04 21:33:05 +0000190
Rafael Espindola34ffcbb2016-04-11 13:51:23 +0000191 DynamicReloc(uint32_t Type, const OutputSectionBase<ELFT> *OffsetSec,
Rafael Espindolade9857e2016-02-04 21:33:05 +0000192 uintX_t OffsetInSec, bool UseSymVA, SymbolBody *Sym,
193 uintX_t Addend)
Rafael Espindola74031ba2016-04-07 15:20:56 +0000194 : Type(Type), Sym(Sym), OffsetSec(OffsetSec), OffsetInSec(OffsetInSec),
195 UseSymVA(UseSymVA), Addend(Addend) {}
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000196};
197
198template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000199class SymbolTableSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000200public:
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000201 typedef typename ELFT::Shdr Elf_Shdr;
202 typedef typename ELFT::Sym Elf_Sym;
203 typedef typename ELFT::SymRange Elf_Sym_Range;
204 typedef typename ELFT::uint uintX_t;
Rui Ueyamaace4f902016-05-24 04:25:47 +0000205 SymbolTableSection(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 Ueyamac2e863a2016-02-17 05:06:40 +0000226 // A vector of symbols and their string table offsets.
227 std::vector<std::pair<SymbolBody *, size_t>> Symbols;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000228};
229
Peter Collingbourne21a12fc2016-04-27 20:22:31 +0000230// For more information about .gnu.version and .gnu.version_r see:
231// https://www.akkadia.org/drepper/symbol-versioning
232
233// The .gnu.version section specifies the required version of each symbol in the
234// dynamic symbol table. It contains one Elf_Versym for each dynamic symbol
235// table entry. An Elf_Versym is just a 16-bit integer that refers to a version
236// identifier defined in the .gnu.version_r section.
237template <class ELFT>
238class VersionTableSection final : public OutputSectionBase<ELFT> {
239 typedef typename ELFT::Versym Elf_Versym;
240
241public:
242 VersionTableSection();
243 void finalize() override;
244 void writeTo(uint8_t *Buf) override;
245};
246
247// The .gnu.version_r section defines the version identifiers used by
248// .gnu.version. It contains a linked list of Elf_Verneed data structures. Each
249// Elf_Verneed specifies the version requirements for a single DSO, and contains
250// a reference to a linked list of Elf_Vernaux data structures which define the
251// mapping from version identifiers to version names.
252template <class ELFT>
253class VersionNeedSection final : public OutputSectionBase<ELFT> {
254 typedef typename ELFT::Verneed Elf_Verneed;
255 typedef typename ELFT::Vernaux Elf_Vernaux;
256
257 // A vector of shared files that need Elf_Verneed data structures and the
258 // string table offsets of their sonames.
259 std::vector<std::pair<SharedFile<ELFT> *, size_t>> Needed;
260
261 // The next available version identifier. Identifiers start at 2 because 0 and
262 // 1 are reserved.
263 unsigned NextIndex = 2;
264
265public:
266 VersionNeedSection();
267 void addSymbol(SharedSymbol<ELFT> *SS);
268 void finalize() override;
269 void writeTo(uint8_t *Buf) override;
270 size_t getNeedNum() const { return Needed.size(); }
271};
272
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000273template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000274class RelocationSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000275 typedef typename ELFT::Rel Elf_Rel;
276 typedef typename ELFT::Rela Elf_Rela;
277 typedef typename ELFT::uint uintX_t;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000278
279public:
George Rimarc191acf2016-05-10 15:47:57 +0000280 RelocationSection(StringRef Name, bool Sort);
Rafael Espindolad30eb7d2016-02-05 15:03:10 +0000281 void addReloc(const DynamicReloc<ELFT> &Reloc);
George Rimar77b77792015-11-25 22:15:01 +0000282 unsigned getRelocOffset();
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000283 void finalize() override;
284 void writeTo(uint8_t *Buf) override;
285 bool hasRelocs() const { return !Relocs.empty(); }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000286
George Rimara07ff662015-12-21 10:12:06 +0000287 bool Static = false;
288
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000289private:
George Rimarc191acf2016-05-10 15:47:57 +0000290 bool Sort;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000291 std::vector<DynamicReloc<ELFT>> Relocs;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000292};
293
294template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000295class OutputSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000296public:
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000297 typedef typename ELFT::Shdr Elf_Shdr;
298 typedef typename ELFT::Sym Elf_Sym;
299 typedef typename ELFT::Rel Elf_Rel;
300 typedef typename ELFT::Rela Elf_Rela;
301 typedef typename ELFT::uint uintX_t;
George Rimar9bec24a2016-02-18 14:20:08 +0000302 OutputSection(StringRef Name, uint32_t Type, uintX_t Flags);
Rui Ueyama40845e62015-12-26 05:51:07 +0000303 void addSection(InputSectionBase<ELFT> *C) override;
Rui Ueyama5af83682016-02-11 23:41:38 +0000304 void sortInitFini();
305 void sortCtorsDtors();
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000306 void writeTo(uint8_t *Buf) override;
George Rimar58941ee2016-02-25 08:23:37 +0000307 void finalize() override;
Rafael Espindola56004c52016-04-07 14:22:09 +0000308 void
309 forEachInputSection(std::function<void(InputSectionBase<ELFT> *)> F) override;
Rafael Espindola71675852015-09-22 00:16:19 +0000310 std::vector<InputSection<ELFT> *> Sections;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000311};
312
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000313template <class ELFT>
Rafael Espindolac159c962015-10-19 21:00:02 +0000314class MergeOutputSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000315 typedef typename ELFT::uint uintX_t;
Rafael Espindolac159c962015-10-19 21:00:02 +0000316
317public:
Rafael Espindola7efa5be2016-02-19 14:17:40 +0000318 MergeOutputSection(StringRef Name, uint32_t Type, uintX_t Flags,
319 uintX_t Alignment);
Rui Ueyama40845e62015-12-26 05:51:07 +0000320 void addSection(InputSectionBase<ELFT> *S) override;
Rafael Espindolac159c962015-10-19 21:00:02 +0000321 void writeTo(uint8_t *Buf) override;
Rafael Espindolaf82ed2a2015-10-24 22:51:01 +0000322 unsigned getOffset(StringRef Val);
323 void finalize() override;
Rui Ueyama406b4692016-05-27 14:39:13 +0000324 void finalizePieces() override;
Peter Collingbournee29e1422016-05-05 04:10:12 +0000325 bool shouldTailMerge() const;
Rafael Espindolac159c962015-10-19 21:00:02 +0000326
327private:
Rafael Espindola7efa5be2016-02-19 14:17:40 +0000328 llvm::StringTableBuilder Builder;
Rui Ueyama406b4692016-05-27 14:39:13 +0000329 std::vector<MergeInputSection<ELFT> *> Sections;
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>
Rui Ueyama0b9a9032016-05-24 04:19:20 +0000359 void addSectionAux(EhInputSection<ELFT> *S, llvm::ArrayRef<RelTy> Rels);
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000360
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000361 template <class RelTy>
Rui Ueyama0b9a9032016-05-24 04:19:20 +0000362 CieRecord *addCie(SectionPiece &Piece, EhInputSection<ELFT> *Sec,
Rui Ueyama19ccffe2016-05-24 15:40:46 +0000363 ArrayRef<RelTy> &Rels);
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000364
365 template <class RelTy>
Rui Ueyama0b9a9032016-05-24 04:19:20 +0000366 bool isFdeLive(SectionPiece &Piece, EhInputSection<ELFT> *Sec,
Rui Ueyama19ccffe2016-05-24 15:40:46 +0000367 ArrayRef<RelTy> &Rels);
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000368
Rui Ueyamae75e9332016-05-23 03:00:33 +0000369 uintX_t getFdePc(uint8_t *Buf, size_t Off, uint8_t Enc);
370
Rui Ueyama0b9a9032016-05-24 04:19:20 +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 Ueyamaace4f902016-05-24 04:25:47 +0000488 explicit DynamicSection();
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 Espindola5805c4f2015-09-21 21:38:08 +0000495};
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000496
Simon Atanasyan1d7df402015-12-20 10:57:34 +0000497template <class ELFT>
498class MipsReginfoOutputSection final : public OutputSectionBase<ELFT> {
499 typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
500
501public:
502 MipsReginfoOutputSection();
503 void writeTo(uint8_t *Buf) override;
Rui Ueyama40845e62015-12-26 05:51:07 +0000504 void addSection(InputSectionBase<ELFT> *S) override;
Simon Atanasyan1d7df402015-12-20 10:57:34 +0000505
506private:
Rui Ueyama70eed362016-01-06 22:42:43 +0000507 uint32_t GprMask = 0;
Simon Atanasyan1d7df402015-12-20 10:57:34 +0000508};
509
Simon Atanasyanadd74f32016-05-04 10:07:38 +0000510template <class ELFT>
511class MipsOptionsOutputSection final : public OutputSectionBase<ELFT> {
512 typedef llvm::object::Elf_Mips_Options<ELFT> Elf_Mips_Options;
513 typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
514
515public:
516 MipsOptionsOutputSection();
517 void writeTo(uint8_t *Buf) override;
518 void addSection(InputSectionBase<ELFT> *S) override;
519
520private:
521 uint32_t GprMask = 0;
522};
523
George Rimarf6bc65a2016-01-15 13:34:52 +0000524// --eh-frame-hdr option tells linker to construct a header for all the
525// .eh_frame sections. This header is placed to a section named .eh_frame_hdr
526// and also to a PT_GNU_EH_FRAME segment.
527// At runtime the unwinder then can find all the PT_GNU_EH_FRAME segments by
528// calling dl_iterate_phdr.
529// This section contains a lookup table for quick binary search of FDEs.
530// Detailed info about internals can be found in Ian Lance Taylor's blog:
531// http://www.airs.com/blog/archives/460 (".eh_frame")
532// http://www.airs.com/blog/archives/462 (".eh_frame_hdr")
533template <class ELFT>
534class EhFrameHeader final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000535 typedef typename ELFT::uint uintX_t;
George Rimarf6bc65a2016-01-15 13:34:52 +0000536
537public:
538 EhFrameHeader();
Rui Ueyamade9777a2016-05-23 16:30:41 +0000539 void finalize() override;
George Rimarf6bc65a2016-01-15 13:34:52 +0000540 void writeTo(uint8_t *Buf) override;
Rui Ueyamae75e9332016-05-23 03:00:33 +0000541 void addFde(uint32_t Pc, uint32_t FdeVA);
George Rimarf6bc65a2016-01-15 13:34:52 +0000542
George Rimarf6bc65a2016-01-15 13:34:52 +0000543private:
544 struct FdeData {
Rui Ueyamae75e9332016-05-23 03:00:33 +0000545 uint32_t Pc;
546 uint32_t FdeVA;
George Rimarf6bc65a2016-01-15 13:34:52 +0000547 };
548
Rui Ueyamae75e9332016-05-23 03:00:33 +0000549 std::vector<FdeData> Fdes;
George Rimarf6bc65a2016-01-15 13:34:52 +0000550};
551
Rui Ueyama3a41be22016-04-07 22:49:21 +0000552template <class ELFT> class BuildIdSection : public OutputSectionBase<ELFT> {
Rui Ueyama634ddf02016-03-11 20:51:53 +0000553public:
Rui Ueyama634ddf02016-03-11 20:51:53 +0000554 void writeTo(uint8_t *Buf) override;
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000555 virtual void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) = 0;
Rui Ueyama3a41be22016-04-07 22:49:21 +0000556
557protected:
558 BuildIdSection(size_t HashSize);
559 size_t HashSize;
560 uint8_t *HashBuf = nullptr;
561};
562
563template <class ELFT> class BuildIdFnv1 final : public BuildIdSection<ELFT> {
564public:
565 BuildIdFnv1() : BuildIdSection<ELFT>(8) {}
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000566 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
Rui Ueyama3a41be22016-04-07 22:49:21 +0000567};
568
569template <class ELFT> class BuildIdMd5 final : public BuildIdSection<ELFT> {
570public:
571 BuildIdMd5() : BuildIdSection<ELFT>(16) {}
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000572 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
Rui Ueyama634ddf02016-03-11 20:51:53 +0000573};
574
Rui Ueyamad86ec302016-04-07 23:51:56 +0000575template <class ELFT> class BuildIdSha1 final : public BuildIdSection<ELFT> {
576public:
577 BuildIdSha1() : BuildIdSection<ELFT>(20) {}
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000578 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
Rui Ueyamad86ec302016-04-07 23:51:56 +0000579};
580
Rui Ueyama9194db72016-05-13 21:55:56 +0000581template <class ELFT>
582class BuildIdHexstring final : public BuildIdSection<ELFT> {
583public:
584 BuildIdHexstring();
585 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
586};
587
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000588// All output sections that are hadnled by the linker specially are
589// globally accessible. Writer initializes them, so don't use them
590// until Writer is initialized.
591template <class ELFT> struct Out {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000592 typedef typename ELFT::uint uintX_t;
593 typedef typename ELFT::Phdr Elf_Phdr;
Rui Ueyama634ddf02016-03-11 20:51:53 +0000594 static BuildIdSection<ELFT> *BuildId;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000595 static DynamicSection<ELFT> *Dynamic;
George Rimarf6bc65a2016-01-15 13:34:52 +0000596 static EhFrameHeader<ELFT> *EhFrameHdr;
Rui Ueyama3b31e672016-05-23 16:24:16 +0000597 static EhOutputSection<ELFT> *EhFrame;
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000598 static GnuHashTableSection<ELFT> *GnuHashTab;
George Rimar648a2c32015-10-20 08:54:27 +0000599 static GotPltSection<ELFT> *GotPlt;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000600 static GotSection<ELFT> *Got;
601 static HashTableSection<ELFT> *HashTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000602 static InterpSection<ELFT> *Interp;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000603 static OutputSection<ELFT> *Bss;
Igor Kudrin304860a2015-11-12 04:39:49 +0000604 static OutputSection<ELFT> *MipsRldMap;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000605 static OutputSectionBase<ELFT> *Opd;
Hal Finkeldaedc122015-10-12 23:16:53 +0000606 static uint8_t *OpdBuf;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000607 static PltSection<ELFT> *Plt;
608 static RelocationSection<ELFT> *RelaDyn;
George Rimar648a2c32015-10-20 08:54:27 +0000609 static RelocationSection<ELFT> *RelaPlt;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000610 static StringTableSection<ELFT> *DynStrTab;
George Rimar0f5ac9f2015-10-20 17:21:35 +0000611 static StringTableSection<ELFT> *ShStrTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000612 static StringTableSection<ELFT> *StrTab;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000613 static SymbolTableSection<ELFT> *DynSymTab;
614 static SymbolTableSection<ELFT> *SymTab;
Peter Collingbourne21a12fc2016-04-27 20:22:31 +0000615 static VersionTableSection<ELFT> *VerSym;
616 static VersionNeedSection<ELFT> *VerNeed;
Rafael Espindolaea7a1e902015-11-06 22:14:44 +0000617 static Elf_Phdr *TlsPhdr;
Rafael Espindola4fc60442016-02-10 22:43:13 +0000618 static OutputSectionBase<ELFT> *ElfHeader;
619 static OutputSectionBase<ELFT> *ProgramHeaders;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000620};
Rui Ueyamad888d102015-10-09 19:34:55 +0000621
Rui Ueyama634ddf02016-03-11 20:51:53 +0000622template <class ELFT> BuildIdSection<ELFT> *Out<ELFT>::BuildId;
Rui Ueyamad888d102015-10-09 19:34:55 +0000623template <class ELFT> DynamicSection<ELFT> *Out<ELFT>::Dynamic;
George Rimarf6bc65a2016-01-15 13:34:52 +0000624template <class ELFT> EhFrameHeader<ELFT> *Out<ELFT>::EhFrameHdr;
Rui Ueyama3b31e672016-05-23 16:24:16 +0000625template <class ELFT> EhOutputSection<ELFT> *Out<ELFT>::EhFrame;
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000626template <class ELFT> GnuHashTableSection<ELFT> *Out<ELFT>::GnuHashTab;
George Rimar648a2c32015-10-20 08:54:27 +0000627template <class ELFT> GotPltSection<ELFT> *Out<ELFT>::GotPlt;
Rui Ueyamad888d102015-10-09 19:34:55 +0000628template <class ELFT> GotSection<ELFT> *Out<ELFT>::Got;
629template <class ELFT> HashTableSection<ELFT> *Out<ELFT>::HashTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000630template <class ELFT> InterpSection<ELFT> *Out<ELFT>::Interp;
Rafael Espindolad7a267b2015-11-03 22:01:20 +0000631template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss;
Igor Kudrin304860a2015-11-12 04:39:49 +0000632template <class ELFT> OutputSection<ELFT> *Out<ELFT>::MipsRldMap;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000633template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::Opd;
Hal Finkeldaedc122015-10-12 23:16:53 +0000634template <class ELFT> uint8_t *Out<ELFT>::OpdBuf;
Rui Ueyamad888d102015-10-09 19:34:55 +0000635template <class ELFT> PltSection<ELFT> *Out<ELFT>::Plt;
636template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaDyn;
George Rimar648a2c32015-10-20 08:54:27 +0000637template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaPlt;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000638template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::DynStrTab;
George Rimar0f5ac9f2015-10-20 17:21:35 +0000639template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::ShStrTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000640template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::StrTab;
Rui Ueyamad888d102015-10-09 19:34:55 +0000641template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::DynSymTab;
642template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::SymTab;
Peter Collingbourne21a12fc2016-04-27 20:22:31 +0000643template <class ELFT> VersionTableSection<ELFT> *Out<ELFT>::VerSym;
644template <class ELFT> VersionNeedSection<ELFT> *Out<ELFT>::VerNeed;
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000645template <class ELFT> typename ELFT::Phdr *Out<ELFT>::TlsPhdr;
Rafael Espindola4fc60442016-02-10 22:43:13 +0000646template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ElfHeader;
647template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ProgramHeaders;
Eugene Zelenko6e43b492015-11-04 02:11:57 +0000648
Rafael Espindolae0df00b2016-02-28 00:25:54 +0000649} // namespace elf
Eugene Zelenko6e43b492015-11-04 02:11:57 +0000650} // namespace lld
651
652#endif // LLD_ELF_OUTPUT_SECTIONS_H