Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 1 | //===- 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 | |
| 13 | #include "lld/Core/LLVM.h" |
| 14 | |
Rafael Espindola | c159c96 | 2015-10-19 21:00:02 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/MapVector.h" |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 16 | #include "llvm/MC/StringTableBuilder.h" |
| 17 | #include "llvm/Object/ELF.h" |
| 18 | |
Davide Italiano | 85121bb | 2015-09-25 03:56:11 +0000 | [diff] [blame] | 19 | #include "Config.h" |
| 20 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 21 | #include <type_traits> |
| 22 | |
| 23 | namespace lld { |
| 24 | namespace elf2 { |
| 25 | |
| 26 | class SymbolBody; |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 27 | template <class ELFT> class SymbolTable; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 28 | template <class ELFT> class SymbolTableSection; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 29 | template <class ELFT> class StringTableSection; |
Rafael Espindola | 0c6a4f1 | 2015-11-11 19:54:14 +0000 | [diff] [blame] | 30 | template <class ELFT> class EHInputSection; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 31 | template <class ELFT> class InputSection; |
Rafael Espindola | 0c6a4f1 | 2015-11-11 19:54:14 +0000 | [diff] [blame] | 32 | template <class ELFT> class InputSectionBase; |
Rafael Espindola | c159c96 | 2015-10-19 21:00:02 +0000 | [diff] [blame] | 33 | template <class ELFT> class MergeInputSection; |
Simon Atanasyan | 1d7df40 | 2015-12-20 10:57:34 +0000 | [diff] [blame] | 34 | template <class ELFT> class MipsReginfoInputSection; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 35 | template <class ELFT> class OutputSection; |
| 36 | template <class ELFT> class ObjectFile; |
| 37 | template <class ELFT> class DefinedRegular; |
| 38 | |
George Rimar | bfb7bf7 | 2015-12-21 10:00:12 +0000 | [diff] [blame] | 39 | // Flag to force GOT to be in output if we have relocations |
| 40 | // that relies on its address. |
| 41 | extern bool HasGotOffRel; |
| 42 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 43 | template <class ELFT> |
Rafael Espindola | 932efcf | 2015-10-19 20:24:44 +0000 | [diff] [blame] | 44 | static inline typename llvm::object::ELFFile<ELFT>::uintX_t |
| 45 | getAddend(const typename llvm::object::ELFFile<ELFT>::Elf_Rel &Rel) { |
| 46 | return 0; |
| 47 | } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 48 | |
| 49 | template <class ELFT> |
Rafael Espindola | 932efcf | 2015-10-19 20:24:44 +0000 | [diff] [blame] | 50 | static inline typename llvm::object::ELFFile<ELFT>::uintX_t |
| 51 | getAddend(const typename llvm::object::ELFFile<ELFT>::Elf_Rela &Rel) { |
| 52 | return Rel.r_addend; |
| 53 | } |
| 54 | |
| 55 | template <class ELFT> |
| 56 | typename llvm::object::ELFFile<ELFT>::uintX_t getSymVA(const SymbolBody &S); |
| 57 | |
| 58 | template <class ELFT, bool IsRela> |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 59 | typename llvm::object::ELFFile<ELFT>::uintX_t |
Rui Ueyama | 126d08f | 2015-10-12 20:28:22 +0000 | [diff] [blame] | 60 | getLocalRelTarget(const ObjectFile<ELFT> &File, |
George Rimar | 0b8ed1d | 2015-12-21 10:37:33 +0000 | [diff] [blame] | 61 | const llvm::object::Elf_Rel_Impl<ELFT, IsRela> &Rel, |
| 62 | typename llvm::object::ELFFile<ELFT>::uintX_t Addend); |
Rafael Espindola | 4f674ed | 2015-10-05 15:24:04 +0000 | [diff] [blame] | 63 | |
Rui Ueyama | 89f4ec7 | 2015-12-25 07:01:09 +0000 | [diff] [blame] | 64 | bool canBePreempted(const SymbolBody *Body, bool NeedsGot); |
Rafael Espindola | d1cf421 | 2015-10-05 16:25:43 +0000 | [diff] [blame] | 65 | |
| 66 | template <class ELFT> |
| 67 | bool shouldKeepInSymtab( |
Rafael Espindola | 444576d | 2015-10-09 19:25:07 +0000 | [diff] [blame] | 68 | const ObjectFile<ELFT> &File, StringRef Name, |
| 69 | const typename llvm::object::ELFFile<ELFT>::Elf_Sym &Sym); |
Davide Italiano | 85121bb | 2015-09-25 03:56:11 +0000 | [diff] [blame] | 70 | |
Rafael Espindola | 7167585 | 2015-09-22 00:16:19 +0000 | [diff] [blame] | 71 | // This represents a section in an output file. |
| 72 | // Different sub classes represent different types of sections. Some contain |
| 73 | // input sections, others are created by the linker. |
| 74 | // The writer creates multiple OutputSections and assign them unique, |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 75 | // non-overlapping file offsets and VAs. |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 76 | template <class ELFT> class OutputSectionBase { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 77 | public: |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 78 | typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t; |
| 79 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Shdr Elf_Shdr; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 80 | |
| 81 | OutputSectionBase(StringRef Name, uint32_t sh_type, uintX_t sh_flags); |
| 82 | void setVA(uintX_t VA) { Header.sh_addr = VA; } |
| 83 | uintX_t getVA() const { return Header.sh_addr; } |
| 84 | void setFileOffset(uintX_t Off) { Header.sh_offset = Off; } |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 85 | void writeHeaderTo(Elf_Shdr *SHdr); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 86 | StringRef getName() { return Name; } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 87 | |
Rui Ueyama | 40845e6 | 2015-12-26 05:51:07 +0000 | [diff] [blame] | 88 | virtual void addSection(InputSectionBase<ELFT> *C) {} |
| 89 | |
Rui Ueyama | 2317d0d | 2015-10-15 20:55:22 +0000 | [diff] [blame] | 90 | unsigned SectionIndex; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 91 | |
| 92 | // Returns the size of the section in the output file. |
Rafael Espindola | 7757224 | 2015-10-02 19:37:55 +0000 | [diff] [blame] | 93 | uintX_t getSize() const { return Header.sh_size; } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 94 | void setSize(uintX_t Val) { Header.sh_size = Val; } |
| 95 | uintX_t getFlags() { return Header.sh_flags; } |
| 96 | uintX_t getFileOff() { return Header.sh_offset; } |
| 97 | uintX_t getAlign() { |
| 98 | // The ELF spec states that a value of 0 means the section has no alignment |
| 99 | // constraits. |
| 100 | return std::max<uintX_t>(Header.sh_addralign, 1); |
| 101 | } |
| 102 | uint32_t getType() { return Header.sh_type; } |
Rafael Espindola | 115f0f3 | 2015-11-03 14:13:40 +0000 | [diff] [blame] | 103 | void updateAlign(uintX_t Align) { |
| 104 | if (Align > Header.sh_addralign) |
| 105 | Header.sh_addralign = Align; |
| 106 | } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 107 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 108 | virtual void finalize() {} |
| 109 | virtual void writeTo(uint8_t *Buf) = 0; |
Rui Ueyama | d4ea7dd | 2015-12-26 07:01:26 +0000 | [diff] [blame] | 110 | virtual ~OutputSectionBase() = default; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 111 | |
| 112 | protected: |
| 113 | StringRef Name; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 114 | Elf_Shdr Header; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 115 | }; |
| 116 | |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 117 | template <class ELFT> class GotSection final : public OutputSectionBase<ELFT> { |
| 118 | typedef OutputSectionBase<ELFT> Base; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 119 | typedef typename Base::uintX_t uintX_t; |
| 120 | |
| 121 | public: |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 122 | GotSection(); |
Igor Kudrin | 15cd9ff | 2015-11-06 07:43:03 +0000 | [diff] [blame] | 123 | void finalize() override; |
Rafael Espindola | a662738 | 2015-10-06 23:56:53 +0000 | [diff] [blame] | 124 | void writeTo(uint8_t *Buf) override; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 125 | void addEntry(SymbolBody *Sym); |
Simon Atanasyan | 56ab5f0 | 2016-01-21 05:33:23 +0000 | [diff] [blame^] | 126 | void addMipsLocalEntry(); |
George Rimar | 90cd0a8 | 2015-12-01 19:20:26 +0000 | [diff] [blame] | 127 | bool addDynTlsEntry(SymbolBody *Sym); |
George Rimar | 95c1a58 | 2015-12-07 08:02:20 +0000 | [diff] [blame] | 128 | bool addCurrentModuleTlsIndex(); |
Simon Atanasyan | 56ab5f0 | 2016-01-21 05:33:23 +0000 | [diff] [blame^] | 129 | bool empty() const { return MipsLocalEntries == 0 && Entries.empty(); } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 130 | uintX_t getEntryAddr(const SymbolBody &B) const; |
Simon Atanasyan | 56ab5f0 | 2016-01-21 05:33:23 +0000 | [diff] [blame^] | 131 | uintX_t getMipsLocalFullAddr(const SymbolBody &B); |
| 132 | uintX_t getMipsLocalPageAddr(uintX_t Addr); |
George Rimar | 90cd0a8 | 2015-12-01 19:20:26 +0000 | [diff] [blame] | 133 | uintX_t getGlobalDynAddr(const SymbolBody &B) const; |
George Rimar | 9db204a | 2015-12-02 09:58:20 +0000 | [diff] [blame] | 134 | uintX_t getNumEntries() const { return Entries.size(); } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 135 | |
Igor Kudrin | 304860a | 2015-11-12 04:39:49 +0000 | [diff] [blame] | 136 | // Returns the symbol which corresponds to the first entry of the global part |
| 137 | // of GOT on MIPS platform. It is required to fill up MIPS-specific dynamic |
| 138 | // table properties. |
| 139 | // Returns nullptr if the global part is empty. |
| 140 | const SymbolBody *getMipsFirstGlobalEntry() const; |
| 141 | |
| 142 | // Returns the number of entries in the local part of GOT including |
| 143 | // the number of reserved entries. This method is MIPS-specific. |
| 144 | unsigned getMipsLocalEntriesNum() const; |
| 145 | |
George Rimar | b17f739 | 2015-12-01 18:24:07 +0000 | [diff] [blame] | 146 | uint32_t getLocalTlsIndexVA() { return Base::getVA() + LocalTlsIndexOff; } |
| 147 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 148 | private: |
| 149 | std::vector<const SymbolBody *> Entries; |
George Rimar | b17f739 | 2015-12-01 18:24:07 +0000 | [diff] [blame] | 150 | uint32_t LocalTlsIndexOff = -1; |
Simon Atanasyan | 56ab5f0 | 2016-01-21 05:33:23 +0000 | [diff] [blame^] | 151 | uint32_t MipsLocalEntries = 0; |
| 152 | llvm::DenseMap<uintX_t, size_t> MipsLocalGotPos; |
| 153 | |
| 154 | uintX_t getMipsLocalEntryAddr(uintX_t EntryValue); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 155 | }; |
| 156 | |
George Rimar | 648a2c3 | 2015-10-20 08:54:27 +0000 | [diff] [blame] | 157 | template <class ELFT> |
| 158 | class GotPltSection final : public OutputSectionBase<ELFT> { |
| 159 | typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t; |
| 160 | |
| 161 | public: |
| 162 | GotPltSection(); |
| 163 | void finalize() override; |
| 164 | void writeTo(uint8_t *Buf) override; |
| 165 | void addEntry(SymbolBody *Sym); |
| 166 | bool empty() const; |
| 167 | uintX_t getEntryAddr(const SymbolBody &B) const; |
| 168 | |
| 169 | private: |
| 170 | std::vector<const SymbolBody *> Entries; |
| 171 | }; |
| 172 | |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 173 | template <class ELFT> class PltSection final : public OutputSectionBase<ELFT> { |
| 174 | typedef OutputSectionBase<ELFT> Base; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 175 | typedef typename Base::uintX_t uintX_t; |
| 176 | |
| 177 | public: |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 178 | PltSection(); |
Hal Finkel | 6c2a3b8 | 2015-10-08 21:51:31 +0000 | [diff] [blame] | 179 | void finalize() override; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 180 | void writeTo(uint8_t *Buf) override; |
| 181 | void addEntry(SymbolBody *Sym); |
| 182 | bool empty() const { return Entries.empty(); } |
| 183 | uintX_t getEntryAddr(const SymbolBody &B) const; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 184 | |
| 185 | private: |
George Rimar | 77b7779 | 2015-11-25 22:15:01 +0000 | [diff] [blame] | 186 | std::vector<std::pair<const SymbolBody *, unsigned>> Entries; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 187 | }; |
| 188 | |
| 189 | template <class ELFT> struct DynamicReloc { |
| 190 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Rel Elf_Rel; |
Michael J. Spencer | 627ae70 | 2015-11-13 00:28:34 +0000 | [diff] [blame] | 191 | InputSectionBase<ELFT> *C; |
| 192 | const Elf_Rel *RI; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 193 | }; |
| 194 | |
| 195 | template <class ELFT> |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 196 | class SymbolTableSection final : public OutputSectionBase<ELFT> { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 197 | public: |
| 198 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Shdr Elf_Shdr; |
| 199 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Sym Elf_Sym; |
| 200 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Sym_Range Elf_Sym_Range; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 201 | typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t; |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 202 | SymbolTableSection(SymbolTable<ELFT> &Table, |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 203 | StringTableSection<ELFT> &StrTabSec); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 204 | |
Rui Ueyama | 0db335f | 2015-10-07 16:58:54 +0000 | [diff] [blame] | 205 | void finalize() override; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 206 | void writeTo(uint8_t *Buf) override; |
Igor Kudrin | ab665fc | 2015-10-20 21:47:58 +0000 | [diff] [blame] | 207 | void addLocalSymbol(StringRef Name); |
| 208 | void addSymbol(SymbolBody *Body); |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 209 | StringTableSection<ELFT> &getStrTabSec() const { return StrTabSec; } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 210 | unsigned getNumSymbols() const { return NumVisible + 1; } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 211 | |
Igor Kudrin | f1d6029 | 2015-10-28 07:05:56 +0000 | [diff] [blame] | 212 | ArrayRef<SymbolBody *> getSymbols() const { return Symbols; } |
Igor Kudrin | ab665fc | 2015-10-20 21:47:58 +0000 | [diff] [blame] | 213 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 214 | private: |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 215 | void writeLocalSymbols(uint8_t *&Buf); |
Igor Kudrin | ea6a835 | 2015-10-19 08:01:51 +0000 | [diff] [blame] | 216 | void writeGlobalSymbols(uint8_t *Buf); |
Rui Ueyama | 8ddfa81 | 2015-09-30 00:32:10 +0000 | [diff] [blame] | 217 | |
Igor Kudrin | 853b88d | 2015-10-20 20:52:14 +0000 | [diff] [blame] | 218 | static uint8_t getSymbolBinding(SymbolBody *Body); |
| 219 | |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 220 | SymbolTable<ELFT> &Table; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 221 | StringTableSection<ELFT> &StrTabSec; |
Igor Kudrin | f1d6029 | 2015-10-28 07:05:56 +0000 | [diff] [blame] | 222 | std::vector<SymbolBody *> Symbols; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 223 | unsigned NumVisible = 0; |
| 224 | unsigned NumLocals = 0; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 225 | }; |
| 226 | |
| 227 | template <class ELFT> |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 228 | class RelocationSection final : public OutputSectionBase<ELFT> { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 229 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Rel Elf_Rel; |
| 230 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Rela Elf_Rela; |
Rafael Espindola | 3c83e2b | 2015-10-05 21:09:37 +0000 | [diff] [blame] | 231 | typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 232 | |
| 233 | public: |
George Rimar | 648a2c3 | 2015-10-20 08:54:27 +0000 | [diff] [blame] | 234 | RelocationSection(StringRef Name, bool IsRela); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 235 | void addReloc(const DynamicReloc<ELFT> &Reloc) { Relocs.push_back(Reloc); } |
George Rimar | 77b7779 | 2015-11-25 22:15:01 +0000 | [diff] [blame] | 236 | unsigned getRelocOffset(); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 237 | void finalize() override; |
| 238 | void writeTo(uint8_t *Buf) override; |
| 239 | bool hasRelocs() const { return !Relocs.empty(); } |
| 240 | bool isRela() const { return IsRela; } |
| 241 | |
George Rimar | a07ff66 | 2015-12-21 10:12:06 +0000 | [diff] [blame] | 242 | bool Static = false; |
| 243 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 244 | private: |
George Rimar | 5828c23 | 2015-11-30 17:49:19 +0000 | [diff] [blame] | 245 | bool applyTlsDynamicReloc(SymbolBody *Body, uint32_t Type, Elf_Rel *P, |
| 246 | Elf_Rel *N); |
| 247 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 248 | std::vector<DynamicReloc<ELFT>> Relocs; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 249 | const bool IsRela; |
| 250 | }; |
| 251 | |
| 252 | template <class ELFT> |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 253 | class OutputSection final : public OutputSectionBase<ELFT> { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 254 | public: |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 255 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Shdr Elf_Shdr; |
| 256 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Sym Elf_Sym; |
| 257 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Rel Elf_Rel; |
| 258 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Rela Elf_Rela; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 259 | typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t; |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 260 | OutputSection(StringRef Name, uint32_t sh_type, uintX_t sh_flags); |
Rui Ueyama | 40845e6 | 2015-12-26 05:51:07 +0000 | [diff] [blame] | 261 | void addSection(InputSectionBase<ELFT> *C) override; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 262 | void writeTo(uint8_t *Buf) override; |
| 263 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 264 | private: |
Rafael Espindola | 7167585 | 2015-09-22 00:16:19 +0000 | [diff] [blame] | 265 | std::vector<InputSection<ELFT> *> Sections; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 266 | }; |
| 267 | |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 268 | template <class ELFT> |
Rafael Espindola | c159c96 | 2015-10-19 21:00:02 +0000 | [diff] [blame] | 269 | class MergeOutputSection final : public OutputSectionBase<ELFT> { |
| 270 | typedef typename OutputSectionBase<ELFT>::uintX_t uintX_t; |
| 271 | |
Rafael Espindola | f82ed2a | 2015-10-24 22:51:01 +0000 | [diff] [blame] | 272 | bool shouldTailMerge() const; |
| 273 | |
Rafael Espindola | c159c96 | 2015-10-19 21:00:02 +0000 | [diff] [blame] | 274 | public: |
| 275 | MergeOutputSection(StringRef Name, uint32_t sh_type, uintX_t sh_flags); |
Rui Ueyama | 40845e6 | 2015-12-26 05:51:07 +0000 | [diff] [blame] | 276 | void addSection(InputSectionBase<ELFT> *S) override; |
Rafael Espindola | c159c96 | 2015-10-19 21:00:02 +0000 | [diff] [blame] | 277 | void writeTo(uint8_t *Buf) override; |
Rafael Espindola | f82ed2a | 2015-10-24 22:51:01 +0000 | [diff] [blame] | 278 | unsigned getOffset(StringRef Val); |
| 279 | void finalize() override; |
Rafael Espindola | c159c96 | 2015-10-19 21:00:02 +0000 | [diff] [blame] | 280 | |
| 281 | private: |
Rafael Espindola | f82ed2a | 2015-10-24 22:51:01 +0000 | [diff] [blame] | 282 | llvm::StringTableBuilder Builder{llvm::StringTableBuilder::RAW}; |
Rafael Espindola | c159c96 | 2015-10-19 21:00:02 +0000 | [diff] [blame] | 283 | }; |
| 284 | |
Rafael Espindola | 0c6a4f1 | 2015-11-11 19:54:14 +0000 | [diff] [blame] | 285 | // FDE or CIE |
| 286 | template <class ELFT> struct EHRegion { |
| 287 | typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t; |
| 288 | EHRegion(EHInputSection<ELFT> *S, unsigned Index); |
| 289 | StringRef data() const; |
| 290 | EHInputSection<ELFT> *S; |
| 291 | unsigned Index; |
| 292 | }; |
| 293 | |
| 294 | template <class ELFT> struct Cie : public EHRegion<ELFT> { |
| 295 | Cie(EHInputSection<ELFT> *S, unsigned Index); |
| 296 | std::vector<EHRegion<ELFT>> Fdes; |
George Rimar | f6bc65a | 2016-01-15 13:34:52 +0000 | [diff] [blame] | 297 | uint8_t FdeEncoding; |
Rafael Espindola | 0c6a4f1 | 2015-11-11 19:54:14 +0000 | [diff] [blame] | 298 | }; |
| 299 | |
| 300 | template <class ELFT> |
| 301 | class EHOutputSection final : public OutputSectionBase<ELFT> { |
| 302 | public: |
| 303 | typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t; |
| 304 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Shdr Elf_Shdr; |
| 305 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Rel Elf_Rel; |
| 306 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Rela Elf_Rela; |
| 307 | EHOutputSection(StringRef Name, uint32_t sh_type, uintX_t sh_flags); |
| 308 | void writeTo(uint8_t *Buf) override; |
| 309 | |
| 310 | template <bool IsRela> |
| 311 | void addSectionAux( |
| 312 | EHInputSection<ELFT> *S, |
| 313 | llvm::iterator_range<const llvm::object::Elf_Rel_Impl<ELFT, IsRela> *> |
| 314 | Rels); |
| 315 | |
Rui Ueyama | 40845e6 | 2015-12-26 05:51:07 +0000 | [diff] [blame] | 316 | void addSection(InputSectionBase<ELFT> *S) override; |
Rafael Espindola | 0c6a4f1 | 2015-11-11 19:54:14 +0000 | [diff] [blame] | 317 | |
| 318 | private: |
George Rimar | f6bc65a | 2016-01-15 13:34:52 +0000 | [diff] [blame] | 319 | uint8_t getFdeEncoding(ArrayRef<uint8_t> D); |
George Rimar | 003be4f | 2015-12-17 09:23:40 +0000 | [diff] [blame] | 320 | uintX_t readEntryLength(ArrayRef<uint8_t> D); |
| 321 | |
Rafael Espindola | 0c6a4f1 | 2015-11-11 19:54:14 +0000 | [diff] [blame] | 322 | std::vector<EHInputSection<ELFT> *> Sections; |
| 323 | std::vector<Cie<ELFT>> Cies; |
| 324 | |
| 325 | // Maps CIE content + personality to a index in Cies. |
| 326 | llvm::DenseMap<std::pair<StringRef, StringRef>, unsigned> CieMap; |
| 327 | }; |
| 328 | |
Rafael Espindola | c159c96 | 2015-10-19 21:00:02 +0000 | [diff] [blame] | 329 | template <class ELFT> |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 330 | class InterpSection final : public OutputSectionBase<ELFT> { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 331 | public: |
| 332 | InterpSection(); |
Eugene Zelenko | 6e43b49 | 2015-11-04 02:11:57 +0000 | [diff] [blame] | 333 | void writeTo(uint8_t *Buf) override; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 334 | }; |
| 335 | |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 336 | template <class ELFT> |
| 337 | class StringTableSection final : public OutputSectionBase<ELFT> { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 338 | public: |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 339 | typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t; |
George Rimar | 0f5ac9f | 2015-10-20 17:21:35 +0000 | [diff] [blame] | 340 | StringTableSection(StringRef Name, bool Dynamic); |
Rui Ueyama | 76c0063 | 2016-01-07 02:35:32 +0000 | [diff] [blame] | 341 | void reserve(StringRef S); |
| 342 | size_t addString(StringRef S); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 343 | void writeTo(uint8_t *Buf) override; |
Rui Ueyama | 76c0063 | 2016-01-07 02:35:32 +0000 | [diff] [blame] | 344 | size_t getSize() const { return Used + Reserved; } |
| 345 | void finalize() override { this->Header.sh_size = getSize(); } |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 346 | bool isDynamic() const { return Dynamic; } |
| 347 | |
| 348 | private: |
| 349 | const bool Dynamic; |
Rui Ueyama | 76c0063 | 2016-01-07 02:35:32 +0000 | [diff] [blame] | 350 | std::vector<StringRef> Strings; |
| 351 | size_t Used = 1; // ELF string tables start with a NUL byte, so 1. |
| 352 | size_t Reserved = 0; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 353 | }; |
| 354 | |
| 355 | template <class ELFT> |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 356 | class HashTableSection final : public OutputSectionBase<ELFT> { |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 357 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Word Elf_Word; |
| 358 | |
| 359 | public: |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 360 | HashTableSection(); |
Rui Ueyama | 0db335f | 2015-10-07 16:58:54 +0000 | [diff] [blame] | 361 | void finalize() override; |
| 362 | void writeTo(uint8_t *Buf) override; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 363 | }; |
| 364 | |
Igor Kudrin | 1b0d706 | 2015-10-22 08:21:35 +0000 | [diff] [blame] | 365 | // Outputs GNU Hash section. For detailed explanation see: |
| 366 | // https://blogs.oracle.com/ali/entry/gnu_hash_elf_sections |
| 367 | template <class ELFT> |
| 368 | class GnuHashTableSection final : public OutputSectionBase<ELFT> { |
| 369 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Off Elf_Off; |
| 370 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Word Elf_Word; |
| 371 | typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t; |
| 372 | |
| 373 | public: |
| 374 | GnuHashTableSection(); |
| 375 | void finalize() override; |
| 376 | void writeTo(uint8_t *Buf) override; |
| 377 | |
Igor Kudrin | f1d6029 | 2015-10-28 07:05:56 +0000 | [diff] [blame] | 378 | // Adds symbols to the hash table. |
| 379 | // Sorts the input to satisfy GNU hash section requirements. |
| 380 | void addSymbols(std::vector<SymbolBody *> &Symbols); |
Igor Kudrin | 1b0d706 | 2015-10-22 08:21:35 +0000 | [diff] [blame] | 381 | |
| 382 | private: |
Igor Kudrin | f1d6029 | 2015-10-28 07:05:56 +0000 | [diff] [blame] | 383 | static unsigned calcNBuckets(unsigned NumHashed); |
Igor Kudrin | 1b0d706 | 2015-10-22 08:21:35 +0000 | [diff] [blame] | 384 | static unsigned calcMaskWords(unsigned NumHashed); |
| 385 | |
| 386 | void writeHeader(uint8_t *&Buf); |
| 387 | void writeBloomFilter(uint8_t *&Buf); |
| 388 | void writeHashTable(uint8_t *Buf); |
| 389 | |
Igor Kudrin | f1d6029 | 2015-10-28 07:05:56 +0000 | [diff] [blame] | 390 | struct HashedSymbolData { |
| 391 | SymbolBody *Body; |
| 392 | uint32_t Hash; |
| 393 | }; |
| 394 | |
| 395 | std::vector<HashedSymbolData> HashedSymbols; |
| 396 | |
Igor Kudrin | 1b0d706 | 2015-10-22 08:21:35 +0000 | [diff] [blame] | 397 | unsigned MaskWords; |
| 398 | unsigned NBuckets; |
| 399 | unsigned Shift2; |
| 400 | }; |
| 401 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 402 | template <class ELFT> |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 403 | class DynamicSection final : public OutputSectionBase<ELFT> { |
| 404 | typedef OutputSectionBase<ELFT> Base; |
| 405 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Dyn Elf_Dyn; |
Rui Ueyama | 2dfd74f | 2015-09-30 21:57:53 +0000 | [diff] [blame] | 406 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Rel Elf_Rel; |
| 407 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Rela Elf_Rela; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 408 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Shdr Elf_Shdr; |
Rui Ueyama | 2dfd74f | 2015-09-30 21:57:53 +0000 | [diff] [blame] | 409 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Sym Elf_Sym; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 410 | |
| 411 | public: |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 412 | DynamicSection(SymbolTable<ELFT> &SymTab); |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 413 | void finalize() override; |
| 414 | void writeTo(uint8_t *Buf) override; |
| 415 | |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 416 | OutputSectionBase<ELFT> *PreInitArraySec = nullptr; |
| 417 | OutputSectionBase<ELFT> *InitArraySec = nullptr; |
| 418 | OutputSectionBase<ELFT> *FiniArraySec = nullptr; |
Rafael Espindola | 7757224 | 2015-10-02 19:37:55 +0000 | [diff] [blame] | 419 | |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 420 | private: |
Rui Ueyama | 3ce825e | 2015-10-09 21:07:25 +0000 | [diff] [blame] | 421 | SymbolTable<ELFT> &SymTab; |
Rafael Espindola | 167e62f | 2015-12-21 20:59:29 +0000 | [diff] [blame] | 422 | const SymbolBody *InitSym = nullptr; |
| 423 | const SymbolBody *FiniSym = nullptr; |
Rui Ueyama | c96d0dd | 2015-10-21 17:47:10 +0000 | [diff] [blame] | 424 | uint32_t DtFlags = 0; |
| 425 | uint32_t DtFlags1 = 0; |
Rafael Espindola | 5805c4f | 2015-09-21 21:38:08 +0000 | [diff] [blame] | 426 | }; |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 427 | |
Simon Atanasyan | 1d7df40 | 2015-12-20 10:57:34 +0000 | [diff] [blame] | 428 | template <class ELFT> |
| 429 | class MipsReginfoOutputSection final : public OutputSectionBase<ELFT> { |
| 430 | typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo; |
| 431 | |
| 432 | public: |
| 433 | MipsReginfoOutputSection(); |
| 434 | void writeTo(uint8_t *Buf) override; |
Rui Ueyama | 40845e6 | 2015-12-26 05:51:07 +0000 | [diff] [blame] | 435 | void addSection(InputSectionBase<ELFT> *S) override; |
Simon Atanasyan | 1d7df40 | 2015-12-20 10:57:34 +0000 | [diff] [blame] | 436 | |
| 437 | private: |
Rui Ueyama | 70eed36 | 2016-01-06 22:42:43 +0000 | [diff] [blame] | 438 | uint32_t GprMask = 0; |
Simon Atanasyan | 1d7df40 | 2015-12-20 10:57:34 +0000 | [diff] [blame] | 439 | }; |
| 440 | |
George Rimar | f6bc65a | 2016-01-15 13:34:52 +0000 | [diff] [blame] | 441 | // --eh-frame-hdr option tells linker to construct a header for all the |
| 442 | // .eh_frame sections. This header is placed to a section named .eh_frame_hdr |
| 443 | // and also to a PT_GNU_EH_FRAME segment. |
| 444 | // At runtime the unwinder then can find all the PT_GNU_EH_FRAME segments by |
| 445 | // calling dl_iterate_phdr. |
| 446 | // This section contains a lookup table for quick binary search of FDEs. |
| 447 | // Detailed info about internals can be found in Ian Lance Taylor's blog: |
| 448 | // http://www.airs.com/blog/archives/460 (".eh_frame") |
| 449 | // http://www.airs.com/blog/archives/462 (".eh_frame_hdr") |
| 450 | template <class ELFT> |
| 451 | class EhFrameHeader final : public OutputSectionBase<ELFT> { |
| 452 | typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t; |
| 453 | |
| 454 | public: |
| 455 | EhFrameHeader(); |
| 456 | void writeTo(uint8_t *Buf) override; |
| 457 | |
| 458 | void addFde(uint8_t Enc, size_t Off, uint8_t *PCRel); |
| 459 | void assignEhFrame(EHOutputSection<ELFT> *Sec); |
| 460 | void reserveFde(); |
| 461 | |
| 462 | bool Live = false; |
| 463 | |
| 464 | private: |
| 465 | struct FdeData { |
| 466 | uint8_t Enc; |
| 467 | size_t Off; |
| 468 | uint8_t *PCRel; |
| 469 | }; |
| 470 | |
| 471 | uintX_t getFdePc(uintX_t EhVA, const FdeData &F); |
| 472 | |
| 473 | EHOutputSection<ELFT> *Sec = nullptr; |
| 474 | std::vector<FdeData> FdeList; |
| 475 | }; |
| 476 | |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 477 | // All output sections that are hadnled by the linker specially are |
| 478 | // globally accessible. Writer initializes them, so don't use them |
| 479 | // until Writer is initialized. |
| 480 | template <class ELFT> struct Out { |
Michael J. Spencer | d77f0d2 | 2015-11-03 22:39:09 +0000 | [diff] [blame] | 481 | typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t; |
Rafael Espindola | ea7a1e90 | 2015-11-06 22:14:44 +0000 | [diff] [blame] | 482 | typedef typename llvm::object::ELFFile<ELFT>::Elf_Phdr Elf_Phdr; |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 483 | static DynamicSection<ELFT> *Dynamic; |
George Rimar | f6bc65a | 2016-01-15 13:34:52 +0000 | [diff] [blame] | 484 | static EhFrameHeader<ELFT> *EhFrameHdr; |
Igor Kudrin | 1b0d706 | 2015-10-22 08:21:35 +0000 | [diff] [blame] | 485 | static GnuHashTableSection<ELFT> *GnuHashTab; |
George Rimar | 648a2c3 | 2015-10-20 08:54:27 +0000 | [diff] [blame] | 486 | static GotPltSection<ELFT> *GotPlt; |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 487 | static GotSection<ELFT> *Got; |
| 488 | static HashTableSection<ELFT> *HashTab; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 489 | static InterpSection<ELFT> *Interp; |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 490 | static OutputSection<ELFT> *Bss; |
Igor Kudrin | 304860a | 2015-11-12 04:39:49 +0000 | [diff] [blame] | 491 | static OutputSection<ELFT> *MipsRldMap; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 492 | static OutputSectionBase<ELFT> *Opd; |
Hal Finkel | daedc12 | 2015-10-12 23:16:53 +0000 | [diff] [blame] | 493 | static uint8_t *OpdBuf; |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 494 | static PltSection<ELFT> *Plt; |
| 495 | static RelocationSection<ELFT> *RelaDyn; |
George Rimar | 648a2c3 | 2015-10-20 08:54:27 +0000 | [diff] [blame] | 496 | static RelocationSection<ELFT> *RelaPlt; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 497 | static StringTableSection<ELFT> *DynStrTab; |
George Rimar | 0f5ac9f | 2015-10-20 17:21:35 +0000 | [diff] [blame] | 498 | static StringTableSection<ELFT> *ShStrTab; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 499 | static StringTableSection<ELFT> *StrTab; |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 500 | static SymbolTableSection<ELFT> *DynSymTab; |
| 501 | static SymbolTableSection<ELFT> *SymTab; |
Rafael Espindola | ea7a1e90 | 2015-11-06 22:14:44 +0000 | [diff] [blame] | 502 | static Elf_Phdr *TlsPhdr; |
Rui Ueyama | 15ef5e1 | 2015-10-07 19:18:16 +0000 | [diff] [blame] | 503 | }; |
Rui Ueyama | d888d10 | 2015-10-09 19:34:55 +0000 | [diff] [blame] | 504 | |
| 505 | template <class ELFT> DynamicSection<ELFT> *Out<ELFT>::Dynamic; |
George Rimar | f6bc65a | 2016-01-15 13:34:52 +0000 | [diff] [blame] | 506 | template <class ELFT> EhFrameHeader<ELFT> *Out<ELFT>::EhFrameHdr; |
Igor Kudrin | 1b0d706 | 2015-10-22 08:21:35 +0000 | [diff] [blame] | 507 | template <class ELFT> GnuHashTableSection<ELFT> *Out<ELFT>::GnuHashTab; |
George Rimar | 648a2c3 | 2015-10-20 08:54:27 +0000 | [diff] [blame] | 508 | template <class ELFT> GotPltSection<ELFT> *Out<ELFT>::GotPlt; |
Rui Ueyama | d888d10 | 2015-10-09 19:34:55 +0000 | [diff] [blame] | 509 | template <class ELFT> GotSection<ELFT> *Out<ELFT>::Got; |
| 510 | template <class ELFT> HashTableSection<ELFT> *Out<ELFT>::HashTab; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 511 | template <class ELFT> InterpSection<ELFT> *Out<ELFT>::Interp; |
Rafael Espindola | d7a267b | 2015-11-03 22:01:20 +0000 | [diff] [blame] | 512 | template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss; |
Igor Kudrin | 304860a | 2015-11-12 04:39:49 +0000 | [diff] [blame] | 513 | template <class ELFT> OutputSection<ELFT> *Out<ELFT>::MipsRldMap; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 514 | template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::Opd; |
Hal Finkel | daedc12 | 2015-10-12 23:16:53 +0000 | [diff] [blame] | 515 | template <class ELFT> uint8_t *Out<ELFT>::OpdBuf; |
Rui Ueyama | d888d10 | 2015-10-09 19:34:55 +0000 | [diff] [blame] | 516 | template <class ELFT> PltSection<ELFT> *Out<ELFT>::Plt; |
| 517 | template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaDyn; |
George Rimar | 648a2c3 | 2015-10-20 08:54:27 +0000 | [diff] [blame] | 518 | template <class ELFT> RelocationSection<ELFT> *Out<ELFT>::RelaPlt; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 519 | template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::DynStrTab; |
George Rimar | 0f5ac9f | 2015-10-20 17:21:35 +0000 | [diff] [blame] | 520 | template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::ShStrTab; |
Rui Ueyama | c7cc6ec | 2015-10-15 22:27:29 +0000 | [diff] [blame] | 521 | template <class ELFT> StringTableSection<ELFT> *Out<ELFT>::StrTab; |
Rui Ueyama | d888d10 | 2015-10-09 19:34:55 +0000 | [diff] [blame] | 522 | template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::DynSymTab; |
| 523 | template <class ELFT> SymbolTableSection<ELFT> *Out<ELFT>::SymTab; |
Rafael Espindola | ea7a1e90 | 2015-11-06 22:14:44 +0000 | [diff] [blame] | 524 | template <class ELFT> typename Out<ELFT>::Elf_Phdr *Out<ELFT>::TlsPhdr; |
Eugene Zelenko | 6e43b49 | 2015-11-04 02:11:57 +0000 | [diff] [blame] | 525 | |
| 526 | } // namespace elf2 |
| 527 | } // namespace lld |
| 528 | |
| 529 | #endif // LLD_ELF_OUTPUT_SECTIONS_H |