blob: 33efe40d59f2c55e3b8babcf031cc33e37c4143b [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; }
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 Ueyamaace4f902016-05-24 04:25:47 +0000204 SymbolTableSection(StringTableSection<ELFT> &StrTabSec);
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000205
Rui Ueyama0db335f2015-10-07 16:58:54 +0000206 void finalize() override;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000207 void writeTo(uint8_t *Buf) override;
Igor Kudrinab665fc2015-10-20 21:47:58 +0000208 void addSymbol(SymbolBody *Body);
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000209 StringTableSection<ELFT> &getStrTabSec() const { return StrTabSec; }
Rafael Espindola0e92f242016-01-27 16:41:24 +0000210 unsigned getNumSymbols() const { return NumLocals + Symbols.size() + 1; }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000211
Rui Ueyamac2e863a2016-02-17 05:06:40 +0000212 ArrayRef<std::pair<SymbolBody *, size_t>> getSymbols() const {
Rafael Espindolae2c24612016-01-29 01:24:25 +0000213 return Symbols;
214 }
215
216 unsigned NumLocals = 0;
217 StringTableSection<ELFT> &StrTabSec;
Igor Kudrinab665fc2015-10-20 21:47:58 +0000218
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000219private:
Rui Ueyama8ddfa812015-09-30 00:32:10 +0000220 void writeLocalSymbols(uint8_t *&Buf);
Igor Kudrinea6a8352015-10-19 08:01:51 +0000221 void writeGlobalSymbols(uint8_t *Buf);
Rui Ueyama8ddfa812015-09-30 00:32:10 +0000222
Rui Ueyama874e7ae2016-02-17 04:56:44 +0000223 const OutputSectionBase<ELFT> *getOutputSection(SymbolBody *Sym);
Igor Kudrin853b88d2015-10-20 20:52:14 +0000224
Rui Ueyamac2e863a2016-02-17 05:06:40 +0000225 // A vector of symbols and their string table offsets.
226 std::vector<std::pair<SymbolBody *, size_t>> Symbols;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000227};
228
Peter Collingbourne21a12fc2016-04-27 20:22:31 +0000229// For more information about .gnu.version and .gnu.version_r see:
230// https://www.akkadia.org/drepper/symbol-versioning
231
232// The .gnu.version section specifies the required version of each symbol in the
233// dynamic symbol table. It contains one Elf_Versym for each dynamic symbol
234// table entry. An Elf_Versym is just a 16-bit integer that refers to a version
235// identifier defined in the .gnu.version_r section.
236template <class ELFT>
237class VersionTableSection final : public OutputSectionBase<ELFT> {
238 typedef typename ELFT::Versym Elf_Versym;
239
240public:
241 VersionTableSection();
242 void finalize() override;
243 void writeTo(uint8_t *Buf) override;
244};
245
246// The .gnu.version_r section defines the version identifiers used by
247// .gnu.version. It contains a linked list of Elf_Verneed data structures. Each
248// Elf_Verneed specifies the version requirements for a single DSO, and contains
249// a reference to a linked list of Elf_Vernaux data structures which define the
250// mapping from version identifiers to version names.
251template <class ELFT>
252class VersionNeedSection final : public OutputSectionBase<ELFT> {
253 typedef typename ELFT::Verneed Elf_Verneed;
254 typedef typename ELFT::Vernaux Elf_Vernaux;
255
256 // A vector of shared files that need Elf_Verneed data structures and the
257 // string table offsets of their sonames.
258 std::vector<std::pair<SharedFile<ELFT> *, size_t>> Needed;
259
260 // The next available version identifier. Identifiers start at 2 because 0 and
261 // 1 are reserved.
262 unsigned NextIndex = 2;
263
264public:
265 VersionNeedSection();
266 void addSymbol(SharedSymbol<ELFT> *SS);
267 void finalize() override;
268 void writeTo(uint8_t *Buf) override;
269 size_t getNeedNum() const { return Needed.size(); }
270};
271
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000272template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000273class RelocationSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000274 typedef typename ELFT::Rel Elf_Rel;
275 typedef typename ELFT::Rela Elf_Rela;
276 typedef typename ELFT::uint uintX_t;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000277
278public:
George Rimarc191acf2016-05-10 15:47:57 +0000279 RelocationSection(StringRef Name, bool Sort);
Rafael Espindolad30eb7d2016-02-05 15:03:10 +0000280 void addReloc(const DynamicReloc<ELFT> &Reloc);
George Rimar77b77792015-11-25 22:15:01 +0000281 unsigned getRelocOffset();
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000282 void finalize() override;
283 void writeTo(uint8_t *Buf) override;
284 bool hasRelocs() const { return !Relocs.empty(); }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000285
George Rimara07ff662015-12-21 10:12:06 +0000286 bool Static = false;
287
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000288private:
George Rimarc191acf2016-05-10 15:47:57 +0000289 bool Sort;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000290 std::vector<DynamicReloc<ELFT>> Relocs;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000291};
292
293template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000294class OutputSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000295public:
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000296 typedef typename ELFT::Shdr Elf_Shdr;
297 typedef typename ELFT::Sym Elf_Sym;
298 typedef typename ELFT::Rel Elf_Rel;
299 typedef typename ELFT::Rela Elf_Rela;
300 typedef typename ELFT::uint uintX_t;
George Rimar9bec24a2016-02-18 14:20:08 +0000301 OutputSection(StringRef Name, uint32_t Type, uintX_t Flags);
Rui Ueyama40845e62015-12-26 05:51:07 +0000302 void addSection(InputSectionBase<ELFT> *C) override;
Rui Ueyama5af83682016-02-11 23:41:38 +0000303 void sortInitFini();
304 void sortCtorsDtors();
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000305 void writeTo(uint8_t *Buf) override;
George Rimar58941ee2016-02-25 08:23:37 +0000306 void finalize() override;
Rafael Espindola56004c52016-04-07 14:22:09 +0000307 void
308 forEachInputSection(std::function<void(InputSectionBase<ELFT> *)> F) override;
Rafael Espindola71675852015-09-22 00:16:19 +0000309 std::vector<InputSection<ELFT> *> Sections;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000310};
311
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000312template <class ELFT>
Rafael Espindolac159c962015-10-19 21:00:02 +0000313class MergeOutputSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000314 typedef typename ELFT::uint uintX_t;
Rafael Espindolac159c962015-10-19 21:00:02 +0000315
316public:
Rafael Espindola7efa5be2016-02-19 14:17:40 +0000317 MergeOutputSection(StringRef Name, uint32_t Type, uintX_t Flags,
318 uintX_t Alignment);
Rui Ueyama40845e62015-12-26 05:51:07 +0000319 void addSection(InputSectionBase<ELFT> *S) override;
Rafael Espindolac159c962015-10-19 21:00:02 +0000320 void writeTo(uint8_t *Buf) override;
Rafael Espindolaf82ed2a2015-10-24 22:51:01 +0000321 unsigned getOffset(StringRef Val);
322 void finalize() override;
Peter Collingbournee29e1422016-05-05 04:10:12 +0000323 bool shouldTailMerge() const;
Rafael Espindolac159c962015-10-19 21:00:02 +0000324
325private:
Rafael Espindola7efa5be2016-02-19 14:17:40 +0000326 llvm::StringTableBuilder Builder;
Rafael Espindolac159c962015-10-19 21:00:02 +0000327};
328
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000329struct CieRecord {
330 SectionPiece *Piece = nullptr;
331 std::vector<SectionPiece *> FdePieces;
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>
Rui Ueyama0b9a9032016-05-24 04:19:20 +0000356 void addSectionAux(EhInputSection<ELFT> *S, llvm::ArrayRef<RelTy> Rels);
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000357
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000358 template <class RelTy>
Rui Ueyama0b9a9032016-05-24 04:19:20 +0000359 CieRecord *addCie(SectionPiece &Piece, EhInputSection<ELFT> *Sec,
Rui Ueyama19ccffe2016-05-24 15:40:46 +0000360 ArrayRef<RelTy> &Rels);
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000361
362 template <class RelTy>
Rui Ueyama0b9a9032016-05-24 04:19:20 +0000363 bool isFdeLive(SectionPiece &Piece, EhInputSection<ELFT> *Sec,
Rui Ueyama19ccffe2016-05-24 15:40:46 +0000364 ArrayRef<RelTy> &Rels);
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000365
Rui Ueyamae75e9332016-05-23 03:00:33 +0000366 uintX_t getFdePc(uint8_t *Buf, size_t Off, uint8_t Enc);
367
Rui Ueyama0b9a9032016-05-24 04:19:20 +0000368 std::vector<EhInputSection<ELFT> *> Sections;
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000369 std::vector<CieRecord *> Cies;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000370
Rui Ueyamaf8b285c2016-05-22 23:16:14 +0000371 // CIE records are uniquified by their contents and personality functions.
372 llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
373
Rafael Espindola56004c52016-04-07 14:22:09 +0000374 bool Finalized = false;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000375};
376
Rafael Espindolac159c962015-10-19 21:00:02 +0000377template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000378class InterpSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000379public:
380 InterpSection();
Eugene Zelenko6e43b492015-11-04 02:11:57 +0000381 void writeTo(uint8_t *Buf) override;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000382};
383
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000384template <class ELFT>
385class StringTableSection final : public OutputSectionBase<ELFT> {
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000386public:
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000387 typedef typename ELFT::uint uintX_t;
George Rimar0f5ac9f2015-10-20 17:21:35 +0000388 StringTableSection(StringRef Name, bool Dynamic);
Rafael Espindolae2c24612016-01-29 01:24:25 +0000389 unsigned addString(StringRef S, bool HashIt = true);
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000390 void writeTo(uint8_t *Buf) override;
Rafael Espindolae2c24612016-01-29 01:24:25 +0000391 unsigned getSize() const { return Size; }
Rui Ueyama76c00632016-01-07 02:35:32 +0000392 void finalize() override { this->Header.sh_size = getSize(); }
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000393 bool isDynamic() const { return Dynamic; }
394
395private:
396 const bool Dynamic;
Rafael Espindolae2c24612016-01-29 01:24:25 +0000397 llvm::DenseMap<StringRef, unsigned> StringMap;
Rui Ueyama76c00632016-01-07 02:35:32 +0000398 std::vector<StringRef> Strings;
Rafael Espindolae2c24612016-01-29 01:24:25 +0000399 unsigned Size = 1; // ELF string tables start with a NUL byte, so 1.
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000400};
401
402template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000403class HashTableSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000404 typedef typename ELFT::Word Elf_Word;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000405
406public:
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000407 HashTableSection();
Rui Ueyama0db335f2015-10-07 16:58:54 +0000408 void finalize() override;
409 void writeTo(uint8_t *Buf) override;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000410};
411
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000412// Outputs GNU Hash section. For detailed explanation see:
413// https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections
414template <class ELFT>
415class GnuHashTableSection final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000416 typedef typename ELFT::Off Elf_Off;
417 typedef typename ELFT::Word Elf_Word;
418 typedef typename ELFT::uint uintX_t;
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000419
420public:
421 GnuHashTableSection();
422 void finalize() override;
423 void writeTo(uint8_t *Buf) override;
424
Igor Kudrinf1d60292015-10-28 07:05:56 +0000425 // Adds symbols to the hash table.
426 // Sorts the input to satisfy GNU hash section requirements.
Rui Ueyamac2e863a2016-02-17 05:06:40 +0000427 void addSymbols(std::vector<std::pair<SymbolBody *, size_t>> &Symbols);
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000428
429private:
Igor Kudrinf1d60292015-10-28 07:05:56 +0000430 static unsigned calcNBuckets(unsigned NumHashed);
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000431 static unsigned calcMaskWords(unsigned NumHashed);
432
433 void writeHeader(uint8_t *&Buf);
434 void writeBloomFilter(uint8_t *&Buf);
435 void writeHashTable(uint8_t *Buf);
436
Rui Ueyama861c7312016-02-17 05:40:03 +0000437 struct SymbolData {
Igor Kudrinf1d60292015-10-28 07:05:56 +0000438 SymbolBody *Body;
Rui Ueyamac2e863a2016-02-17 05:06:40 +0000439 size_t STName;
Igor Kudrinf1d60292015-10-28 07:05:56 +0000440 uint32_t Hash;
441 };
442
Rui Ueyama861c7312016-02-17 05:40:03 +0000443 std::vector<SymbolData> Symbols;
Igor Kudrinf1d60292015-10-28 07:05:56 +0000444
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000445 unsigned MaskWords;
446 unsigned NBuckets;
447 unsigned Shift2;
448};
449
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000450template <class ELFT>
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000451class DynamicSection final : public OutputSectionBase<ELFT> {
452 typedef OutputSectionBase<ELFT> Base;
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000453 typedef typename ELFT::Dyn Elf_Dyn;
454 typedef typename ELFT::Rel Elf_Rel;
455 typedef typename ELFT::Rela Elf_Rela;
456 typedef typename ELFT::Shdr Elf_Shdr;
457 typedef typename ELFT::Sym Elf_Sym;
458 typedef typename ELFT::uint uintX_t;
Rafael Espindolade069362016-01-25 21:32:04 +0000459
Rui Ueyama909cc682016-02-02 03:11:27 +0000460 // The .dynamic section contains information for the dynamic linker.
461 // The section consists of fixed size entries, which consist of
462 // type and value fields. Value are one of plain integers, symbol
463 // addresses, or section addresses. This struct represents the entry.
Rafael Espindolade069362016-01-25 21:32:04 +0000464 struct Entry {
465 int32_t Tag;
466 union {
467 OutputSectionBase<ELFT> *OutSec;
468 uint64_t Val;
469 const SymbolBody *Sym;
470 };
471 enum KindT { SecAddr, SymAddr, PlainInt } Kind;
472 Entry(int32_t Tag, OutputSectionBase<ELFT> *OutSec)
473 : Tag(Tag), OutSec(OutSec), Kind(SecAddr) {}
474 Entry(int32_t Tag, uint64_t Val) : Tag(Tag), Val(Val), Kind(PlainInt) {}
475 Entry(int32_t Tag, const SymbolBody *Sym)
476 : Tag(Tag), Sym(Sym), Kind(SymAddr) {}
477 };
Rui Ueyama909cc682016-02-02 03:11:27 +0000478
479 // finalize() fills this vector with the section contents. finalize()
480 // cannot directly create final section contents because when the
481 // function is called, symbol or section addresses are not fixed yet.
Rafael Espindolade069362016-01-25 21:32:04 +0000482 std::vector<Entry> Entries;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000483
484public:
Rui Ueyamaace4f902016-05-24 04:25:47 +0000485 explicit DynamicSection();
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000486 void finalize() override;
487 void writeTo(uint8_t *Buf) override;
488
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000489 OutputSectionBase<ELFT> *PreInitArraySec = nullptr;
490 OutputSectionBase<ELFT> *InitArraySec = nullptr;
491 OutputSectionBase<ELFT> *FiniArraySec = nullptr;
Rafael Espindola5805c4f2015-09-21 21:38:08 +0000492};
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000493
Simon Atanasyan1d7df402015-12-20 10:57:34 +0000494template <class ELFT>
495class MipsReginfoOutputSection final : public OutputSectionBase<ELFT> {
496 typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
497
498public:
499 MipsReginfoOutputSection();
500 void writeTo(uint8_t *Buf) override;
Rui Ueyama40845e62015-12-26 05:51:07 +0000501 void addSection(InputSectionBase<ELFT> *S) override;
Simon Atanasyan1d7df402015-12-20 10:57:34 +0000502
503private:
Rui Ueyama70eed362016-01-06 22:42:43 +0000504 uint32_t GprMask = 0;
Simon Atanasyan1d7df402015-12-20 10:57:34 +0000505};
506
Simon Atanasyanadd74f32016-05-04 10:07:38 +0000507template <class ELFT>
508class MipsOptionsOutputSection final : public OutputSectionBase<ELFT> {
509 typedef llvm::object::Elf_Mips_Options<ELFT> Elf_Mips_Options;
510 typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
511
512public:
513 MipsOptionsOutputSection();
514 void writeTo(uint8_t *Buf) override;
515 void addSection(InputSectionBase<ELFT> *S) override;
516
517private:
518 uint32_t GprMask = 0;
519};
520
George Rimarf6bc65a2016-01-15 13:34:52 +0000521// --eh-frame-hdr option tells linker to construct a header for all the
522// .eh_frame sections. This header is placed to a section named .eh_frame_hdr
523// and also to a PT_GNU_EH_FRAME segment.
524// At runtime the unwinder then can find all the PT_GNU_EH_FRAME segments by
525// calling dl_iterate_phdr.
526// This section contains a lookup table for quick binary search of FDEs.
527// Detailed info about internals can be found in Ian Lance Taylor's blog:
528// http://www.airs.com/blog/archives/460 (".eh_frame")
529// http://www.airs.com/blog/archives/462 (".eh_frame_hdr")
530template <class ELFT>
531class EhFrameHeader final : public OutputSectionBase<ELFT> {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000532 typedef typename ELFT::uint uintX_t;
George Rimarf6bc65a2016-01-15 13:34:52 +0000533
534public:
535 EhFrameHeader();
Rui Ueyamade9777a2016-05-23 16:30:41 +0000536 void finalize() override;
George Rimarf6bc65a2016-01-15 13:34:52 +0000537 void writeTo(uint8_t *Buf) override;
Rui Ueyamae75e9332016-05-23 03:00:33 +0000538 void addFde(uint32_t Pc, uint32_t FdeVA);
George Rimarf6bc65a2016-01-15 13:34:52 +0000539
George Rimarf6bc65a2016-01-15 13:34:52 +0000540private:
541 struct FdeData {
Rui Ueyamae75e9332016-05-23 03:00:33 +0000542 uint32_t Pc;
543 uint32_t FdeVA;
George Rimarf6bc65a2016-01-15 13:34:52 +0000544 };
545
Rui Ueyamae75e9332016-05-23 03:00:33 +0000546 std::vector<FdeData> Fdes;
George Rimarf6bc65a2016-01-15 13:34:52 +0000547};
548
Rui Ueyama3a41be22016-04-07 22:49:21 +0000549template <class ELFT> class BuildIdSection : public OutputSectionBase<ELFT> {
Rui Ueyama634ddf02016-03-11 20:51:53 +0000550public:
Rui Ueyama634ddf02016-03-11 20:51:53 +0000551 void writeTo(uint8_t *Buf) override;
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000552 virtual void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) = 0;
Rui Ueyama3a41be22016-04-07 22:49:21 +0000553
554protected:
555 BuildIdSection(size_t HashSize);
556 size_t HashSize;
557 uint8_t *HashBuf = nullptr;
558};
559
560template <class ELFT> class BuildIdFnv1 final : public BuildIdSection<ELFT> {
561public:
562 BuildIdFnv1() : BuildIdSection<ELFT>(8) {}
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000563 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
Rui Ueyama3a41be22016-04-07 22:49:21 +0000564};
565
566template <class ELFT> class BuildIdMd5 final : public BuildIdSection<ELFT> {
567public:
568 BuildIdMd5() : BuildIdSection<ELFT>(16) {}
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000569 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
Rui Ueyama634ddf02016-03-11 20:51:53 +0000570};
571
Rui Ueyamad86ec302016-04-07 23:51:56 +0000572template <class ELFT> class BuildIdSha1 final : public BuildIdSection<ELFT> {
573public:
574 BuildIdSha1() : BuildIdSection<ELFT>(20) {}
Rui Ueyamadd368fc2016-05-02 23:35:59 +0000575 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
Rui Ueyamad86ec302016-04-07 23:51:56 +0000576};
577
Rui Ueyama9194db72016-05-13 21:55:56 +0000578template <class ELFT>
579class BuildIdHexstring final : public BuildIdSection<ELFT> {
580public:
581 BuildIdHexstring();
582 void writeBuildId(ArrayRef<ArrayRef<uint8_t>> Bufs) override;
583};
584
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000585// All output sections that are hadnled by the linker specially are
586// globally accessible. Writer initializes them, so don't use them
587// until Writer is initialized.
588template <class ELFT> struct Out {
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000589 typedef typename ELFT::uint uintX_t;
590 typedef typename ELFT::Phdr Elf_Phdr;
Rui Ueyama634ddf02016-03-11 20:51:53 +0000591 static BuildIdSection<ELFT> *BuildId;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000592 static DynamicSection<ELFT> *Dynamic;
George Rimarf6bc65a2016-01-15 13:34:52 +0000593 static EhFrameHeader<ELFT> *EhFrameHdr;
Rui Ueyama3b31e672016-05-23 16:24:16 +0000594 static EhOutputSection<ELFT> *EhFrame;
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000595 static GnuHashTableSection<ELFT> *GnuHashTab;
George Rimar648a2c32015-10-20 08:54:27 +0000596 static GotPltSection<ELFT> *GotPlt;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000597 static GotSection<ELFT> *Got;
598 static HashTableSection<ELFT> *HashTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000599 static InterpSection<ELFT> *Interp;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000600 static OutputSection<ELFT> *Bss;
Igor Kudrin304860a2015-11-12 04:39:49 +0000601 static OutputSection<ELFT> *MipsRldMap;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000602 static OutputSectionBase<ELFT> *Opd;
Hal Finkeldaedc122015-10-12 23:16:53 +0000603 static uint8_t *OpdBuf;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000604 static PltSection<ELFT> *Plt;
605 static RelocationSection<ELFT> *RelaDyn;
George Rimar648a2c32015-10-20 08:54:27 +0000606 static RelocationSection<ELFT> *RelaPlt;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000607 static StringTableSection<ELFT> *DynStrTab;
George Rimar0f5ac9f2015-10-20 17:21:35 +0000608 static StringTableSection<ELFT> *ShStrTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000609 static StringTableSection<ELFT> *StrTab;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000610 static SymbolTableSection<ELFT> *DynSymTab;
611 static SymbolTableSection<ELFT> *SymTab;
Peter Collingbourne21a12fc2016-04-27 20:22:31 +0000612 static VersionTableSection<ELFT> *VerSym;
613 static VersionNeedSection<ELFT> *VerNeed;
Rafael Espindolaea7a1e902015-11-06 22:14:44 +0000614 static Elf_Phdr *TlsPhdr;
Rafael Espindola4fc60442016-02-10 22:43:13 +0000615 static OutputSectionBase<ELFT> *ElfHeader;
616 static OutputSectionBase<ELFT> *ProgramHeaders;
Rui Ueyama15ef5e12015-10-07 19:18:16 +0000617};
Rui Ueyamad888d102015-10-09 19:34:55 +0000618
Rui Ueyama634ddf02016-03-11 20:51:53 +0000619template <class ELFT> BuildIdSection<ELFT> *Out<ELFT>::BuildId;
Rui Ueyamad888d102015-10-09 19:34:55 +0000620template <class ELFT> DynamicSection<ELFT> *Out<ELFT>::Dynamic;
George Rimarf6bc65a2016-01-15 13:34:52 +0000621template <class ELFT> EhFrameHeader<ELFT> *Out<ELFT>::EhFrameHdr;
Rui Ueyama3b31e672016-05-23 16:24:16 +0000622template <class ELFT> EhOutputSection<ELFT> *Out<ELFT>::EhFrame;
Igor Kudrin1b0d7062015-10-22 08:21:35 +0000623template <class ELFT> GnuHashTableSection<ELFT> *Out<ELFT>::GnuHashTab;
George Rimar648a2c32015-10-20 08:54:27 +0000624template <class ELFT> GotPltSection<ELFT> *Out<ELFT>::GotPlt;
Rui Ueyamad888d102015-10-09 19:34:55 +0000625template <class ELFT> GotSection<ELFT> *Out<ELFT>::Got;
626template <class ELFT> HashTableSection<ELFT> *Out<ELFT>::HashTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000627template <class ELFT> InterpSection<ELFT> *Out<ELFT>::Interp;
Rafael Espindolad7a267b2015-11-03 22:01:20 +0000628template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss;
Igor Kudrin304860a2015-11-12 04:39:49 +0000629template <class ELFT> OutputSection<ELFT> *Out<ELFT>::MipsRldMap;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000630template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::Opd;
Hal Finkeldaedc122015-10-12 23:16:53 +0000631template <class ELFT> uint8_t *Out<ELFT>::OpdBuf;
Rui Ueyamad888d102015-10-09 19:34:55 +0000632template <class ELFT> PltSection<ELFT> *Out<ELFT>::Plt;
633template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaDyn;
George Rimar648a2c32015-10-20 08:54:27 +0000634template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaPlt;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000635template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::DynStrTab;
George Rimar0f5ac9f2015-10-20 17:21:35 +0000636template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::ShStrTab;
Rui Ueyamac7cc6ec2015-10-15 22:27:29 +0000637template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::StrTab;
Rui Ueyamad888d102015-10-09 19:34:55 +0000638template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::DynSymTab;
639template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::SymTab;
Peter Collingbourne21a12fc2016-04-27 20:22:31 +0000640template <class ELFT> VersionTableSection<ELFT> *Out<ELFT>::VerSym;
641template <class ELFT> VersionNeedSection<ELFT> *Out<ELFT>::VerNeed;
Rui Ueyama9328b2c2016-03-14 23:16:09 +0000642template <class ELFT> typename ELFT::Phdr *Out<ELFT>::TlsPhdr;
Rafael Espindola4fc60442016-02-10 22:43:13 +0000643template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ElfHeader;
644template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ProgramHeaders;
Eugene Zelenko6e43b492015-11-04 02:11:57 +0000645
Rafael Espindolae0df00b2016-02-28 00:25:54 +0000646} // namespace elf
Eugene Zelenko6e43b492015-11-04 02:11:57 +0000647} // namespace lld
648
649#endif // LLD_ELF_OUTPUT_SECTIONS_H