blob: dd518e5a2e8d5a27e67a728bc5ce434cd864067d [file] [log] [blame]
Rafael Espindola9d06ab62015-09-22 00:01:39 +00001//===- InputSection.h -------------------------------------------*- C++ -*-===//
Michael J. Spencer84487f12015-07-24 21:03:07 +00002//
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
Rafael Espindola9d06ab62015-09-22 00:01:39 +000010#ifndef LLD_ELF_INPUT_SECTION_H
11#define LLD_ELF_INPUT_SECTION_H
Michael J. Spencer84487f12015-07-24 21:03:07 +000012
Rui Ueyamac4aaed92015-10-22 18:49:53 +000013#include "Config.h"
Rui Ueyama0fcdc732016-05-24 20:24:43 +000014#include "Relocations.h"
Peter Smithfb05cd92016-07-08 16:10:27 +000015#include "Thunks.h"
Michael J. Spencer84487f12015-07-24 21:03:07 +000016#include "lld/Core/LLVM.h"
Rui Ueyama8f687f72016-12-19 03:14:16 +000017#include "llvm/ADT/CachedHashString.h"
Rui Ueyamab91bf1a2016-05-23 16:55:43 +000018#include "llvm/ADT/DenseSet.h"
Rui Ueyamac00718f2016-02-23 03:34:37 +000019#include "llvm/ADT/TinyPtrVector.h"
Michael J. Spencer84487f12015-07-24 21:03:07 +000020#include "llvm/Object/ELF.h"
Kamil Rytarowskie739e492017-05-24 18:31:48 +000021#include "llvm/Support/Threading.h"
Rui Ueyama77f2a872016-11-18 05:05:43 +000022#include <mutex>
Michael J. Spencer84487f12015-07-24 21:03:07 +000023
24namespace lld {
Rafael Espindolae0df00b2016-02-28 00:25:54 +000025namespace elf {
Michael J. Spencer84487f12015-07-24 21:03:07 +000026
Rafael Espindolae7553e42016-08-31 13:28:33 +000027class DefinedCommon;
Rui Ueyama014b0f22017-09-19 23:36:48 +000028class EhInputSection;
Rafael Espindola38c67a22016-04-15 14:41:56 +000029class SymbolBody;
Rafael Espindola32aca872016-10-05 18:40:00 +000030struct SectionPiece;
Rafael Espindola38c67a22016-04-15 14:41:56 +000031
Rui Ueyama80474a22017-02-28 19:29:55 +000032class DefinedRegular;
Rafael Espindola5c02b742017-03-06 21:17:18 +000033class SyntheticSection;
Rafael Espindola66b4e212017-02-23 22:06:28 +000034template <class ELFT> class EhFrameSection;
Rafael Espindola6119b862017-03-06 20:23:56 +000035class MergeSyntheticSection;
Rui Ueyama709fb2bb12017-07-26 22:13:32 +000036template <class ELFT> class ObjFile;
Rafael Espindola24e6f362017-02-24 15:07:30 +000037class OutputSection;
Michael J. Spencer84487f12015-07-24 21:03:07 +000038
Rafael Espindola5616adf2017-03-08 22:36:28 +000039// This is the base class of all sections that lld handles. Some are sections in
40// input files, some are sections in the produced output file and some exist
41// just as a convenience for implementing special ways of combining some
42// sections.
43class SectionBase {
Eugene Leviant97403d12016-09-01 09:55:57 +000044public:
Rafael Espindola5616adf2017-03-08 22:36:28 +000045 enum Kind { Regular, EHFrame, Merge, Synthetic, Output };
Eugene Leviant97403d12016-09-01 09:55:57 +000046
Rafael Espindola16853bb2016-09-08 12:33:41 +000047 Kind kind() const { return (Kind)SectionKind; }
Rafael Espindolac404d502017-02-23 02:32:18 +000048
49 StringRef Name;
50
51 unsigned SectionKind : 3;
52
Rafael Espindola5616adf2017-03-08 22:36:28 +000053 // The next two bit fields are only used by InputSectionBase, but we
54 // put them here so the struct packs better.
55
Rafael Espindolac404d502017-02-23 02:32:18 +000056 // The garbage collector sets sections' Live bits.
57 // If GC is disabled, all sections are considered live by default.
58 unsigned Live : 1; // for garbage collection
59 unsigned Assigned : 1; // for linker script
60
61 uint32_t Alignment;
62
Rafael Espindola0e090522016-10-26 00:54:03 +000063 // These corresponds to the fields in Elf_Shdr.
Rafael Espindolab4c9b812017-02-23 02:28:28 +000064 uint64_t Flags;
Rafael Espindolab4c9b812017-02-23 02:28:28 +000065 uint64_t Entsize;
Rafael Espindola0e090522016-10-26 00:54:03 +000066 uint32_t Type;
67 uint32_t Link;
68 uint32_t Info;
69
Rafael Espindola5616adf2017-03-08 22:36:28 +000070 OutputSection *getOutputSection();
71 const OutputSection *getOutputSection() const {
72 return const_cast<SectionBase *>(this)->getOutputSection();
73 }
74
75 // Translate an offset in the input section to an offset in the output
76 // section.
77 uint64_t getOffset(uint64_t Offset) const;
78
79 uint64_t getOffset(const DefinedRegular &Sym) const;
80
81protected:
82 SectionBase(Kind SectionKind, StringRef Name, uint64_t Flags,
83 uint64_t Entsize, uint64_t Alignment, uint32_t Type,
84 uint32_t Info, uint32_t Link)
85 : Name(Name), SectionKind(SectionKind), Alignment(Alignment),
86 Flags(Flags), Entsize(Entsize), Type(Type), Link(Link), Info(Info) {
87 Live = false;
88 Assigned = false;
89 }
90};
91
92// This corresponds to a section of an input file.
93class InputSectionBase : public SectionBase {
94public:
95 static bool classof(const SectionBase *S);
96
97 // The file this section is from.
98 InputFile *File;
99
100 ArrayRef<uint8_t> Data;
Rafael Espindola35ae65e2017-03-08 15:57:17 +0000101 uint64_t getOffsetInFile() const;
Rafael Espindolabdd2e3e2017-03-08 14:12:52 +0000102
Rafael Espindola2a80e112017-03-06 22:36:19 +0000103 static InputSectionBase Discarded;
104
Rafael Espindola042a3f22016-09-08 14:06:08 +0000105 InputSectionBase()
Rafael Espindola5616adf2017-03-08 22:36:28 +0000106 : SectionBase(Regular, "", /*Flags*/ 0, /*Entsize*/ 0, /*Alignment*/ 0,
107 /*Type*/ 0,
108 /*Info*/ 0, /*Link*/ 0),
109 Repl(this) {
110 Live = false;
111 Assigned = false;
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000112 NumRelocations = 0;
113 AreRelocsRela = false;
114 }
Rafael Espindolaccfe3cb2016-04-04 14:04:16 +0000115
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000116 template <class ELFT>
Rui Ueyama709fb2bb12017-07-26 22:13:32 +0000117 InputSectionBase(ObjFile<ELFT> *File, const typename ELFT::Shdr *Header,
Rafael Espindola042a3f22016-09-08 14:06:08 +0000118 StringRef Name, Kind SectionKind);
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000119
120 InputSectionBase(InputFile *File, uint64_t Flags, uint32_t Type,
121 uint64_t Entsize, uint32_t Link, uint32_t Info,
Rafael Espindolafcd208f2017-03-08 19:35:29 +0000122 uint32_t Alignment, ArrayRef<uint8_t> Data, StringRef Name,
Rafael Espindola0e090522016-10-26 00:54:03 +0000123 Kind SectionKind);
Rafael Espindoladb5e56f2017-05-31 20:17:44 +0000124
125 // Input sections are part of an output section. Special sections
126 // like .eh_frame and merge sections are first combined into a
127 // synthetic section that is then added to an output section. In all
128 // cases this points one level up.
129 SectionBase *Parent = nullptr;
Rui Ueyamac4aaed92015-10-22 18:49:53 +0000130
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000131 // Relocations that refer to this section.
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000132 const void *FirstRelocation = nullptr;
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000133 unsigned NumRelocations : 31;
134 unsigned AreRelocsRela : 1;
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000135 template <class ELFT> ArrayRef<typename ELFT::Rel> rels() const {
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000136 assert(!AreRelocsRela);
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000137 return llvm::makeArrayRef(
138 static_cast<const typename ELFT::Rel *>(FirstRelocation),
139 NumRelocations);
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000140 }
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000141 template <class ELFT> ArrayRef<typename ELFT::Rela> relas() const {
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000142 assert(AreRelocsRela);
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000143 return llvm::makeArrayRef(
144 static_cast<const typename ELFT::Rela *>(FirstRelocation),
145 NumRelocations);
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000146 }
147
Rui Ueyama0b289522016-02-25 18:43:51 +0000148 // This pointer points to the "real" instance of this instance.
149 // Usually Repl == this. However, if ICF merges two sections,
150 // Repl pointer of one section points to another section. So,
151 // if you need to get a pointer to this instance, do not use
152 // this but instead this->Repl.
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000153 InputSectionBase *Repl;
Rui Ueyama0b289522016-02-25 18:43:51 +0000154
George Rimar647c1682017-02-17 19:34:05 +0000155 // InputSections that are dependent on us (reverse dependency for GC)
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000156 llvm::TinyPtrVector<InputSectionBase *> DependentSections;
George Rimar647c1682017-02-17 19:34:05 +0000157
Rafael Espindola1a541122016-11-08 14:47:16 +0000158 // Returns the size of this section (even if this is a common or BSS.)
Rafael Espindola76b6bd32017-03-08 15:44:30 +0000159 size_t getSize() const;
Rafael Espindola1a541122016-11-08 14:47:16 +0000160
Rui Ueyama709fb2bb12017-07-26 22:13:32 +0000161 template <class ELFT> ObjFile<ELFT> *getFile() const;
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000162
163 template <class ELFT> llvm::object::ELFFile<ELFT> getObj() const {
164 return getFile<ELFT>()->getObj();
165 }
166
Rafael Espindolab47c6e52017-05-31 19:09:52 +0000167 InputSection *getLinkOrderDep() const;
Rafael Espindoladb9bf4d2015-11-11 16:50:37 +0000168
George Rimar76e562a2017-03-21 09:08:58 +0000169 void uncompress();
George Rimar602fbee2016-06-24 11:18:44 +0000170
Rui Ueyamada06bfb2016-11-25 18:51:53 +0000171 // Returns a source location string. Used to construct an error message.
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000172 template <class ELFT> std::string getLocation(uint64_t Offset);
Rui Ueyamab8760202017-03-30 19:13:47 +0000173 template <class ELFT> std::string getSrcMsg(uint64_t Offset);
174 template <class ELFT> std::string getObjMsg(uint64_t Offset);
Rui Ueyamada06bfb2016-11-25 18:51:53 +0000175
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000176 template <class ELFT> void relocate(uint8_t *Buf, uint8_t *BufEnd);
Rafael Espindolaa6465bb2017-05-18 16:45:36 +0000177 void relocateAlloc(uint8_t *Buf, uint8_t *BufEnd);
178 template <class ELFT> void relocateNonAlloc(uint8_t *Buf, uint8_t *BufEnd);
Rafael Espindolac404d502017-02-23 02:32:18 +0000179
180 std::vector<Relocation> Relocations;
181
182 template <typename T> llvm::ArrayRef<T> getDataAs() const {
183 size_t S = Data.size();
184 assert(S % sizeof(T) == 0);
185 return llvm::makeArrayRef<T>((const T *)Data.data(), S / sizeof(T));
186 }
Rui Ueyama314a0052017-08-17 00:27:55 +0000187
188private:
189 // A pointer that owns uncompressed data if a section is compressed by zlib.
190 // Since the feature is not used often, this is usually a nullptr.
Rafael Espindola17e93d22017-09-06 22:16:32 +0000191 std::unique_ptr<char[]> UncompressBuf;
Rafael Espindolac159c962015-10-19 21:00:02 +0000192};
193
Rui Ueyama3ea87272016-05-22 00:13:04 +0000194// SectionPiece represents a piece of splittable section contents.
Rafael Espindola113860b2016-10-20 10:55:58 +0000195// We allocate a lot of these and binary search on them. This means that they
196// have to be as compact as possible, which is why we don't store the size (can
197// be found by looking at the next one) and put the hash in a side table.
Rui Ueyama3ea87272016-05-22 00:13:04 +0000198struct SectionPiece {
Rafael Espindola113860b2016-10-20 10:55:58 +0000199 SectionPiece(size_t Off, bool Live = false)
200 : InputOff(Off), OutputOff(-1), Live(Live || !Config->GcSections) {}
Rui Ueyama34dc99e2016-05-22 01:15:32 +0000201
Rui Ueyama3ea87272016-05-22 00:13:04 +0000202 size_t InputOff;
Rafael Espindola113860b2016-10-20 10:55:58 +0000203 ssize_t OutputOff : 8 * sizeof(ssize_t) - 1;
Hans Wennborg7314c482016-10-20 15:59:08 +0000204 size_t Live : 1;
Rui Ueyama3ea87272016-05-22 00:13:04 +0000205};
Rafael Espindola113860b2016-10-20 10:55:58 +0000206static_assert(sizeof(SectionPiece) == 2 * sizeof(size_t),
207 "SectionPiece is too big");
Rui Ueyama3ea87272016-05-22 00:13:04 +0000208
Rafael Espindolac159c962015-10-19 21:00:02 +0000209// This corresponds to a SHF_MERGE section of an input file.
Rafael Espindola6119b862017-03-06 20:23:56 +0000210class MergeInputSection : public InputSectionBase {
Rafael Espindolac159c962015-10-19 21:00:02 +0000211public:
Rafael Espindola6119b862017-03-06 20:23:56 +0000212 template <class ELFT>
Rui Ueyama709fb2bb12017-07-26 22:13:32 +0000213 MergeInputSection(ObjFile<ELFT> *F, const typename ELFT::Shdr *Header,
Rafael Espindola042a3f22016-09-08 14:06:08 +0000214 StringRef Name);
Rafael Espindola5616adf2017-03-08 22:36:28 +0000215 static bool classof(const SectionBase *S);
Rui Ueyamab91bf1a2016-05-23 16:55:43 +0000216 void splitIntoPieces();
217
218 // Mark the piece at a given offset live. Used by GC.
Rafael Espindola6119b862017-03-06 20:23:56 +0000219 void markLiveAt(uint64_t Offset) {
Rafael Espindola1854a8e2016-10-26 12:36:56 +0000220 assert(this->Flags & llvm::ELF::SHF_ALLOC);
Rafael Espindola116d83f2016-10-19 23:13:40 +0000221 LiveOffsets.insert(Offset);
222 }
Rui Ueyamab91bf1a2016-05-23 16:55:43 +0000223
224 // Translate an offset in the input section to an offset
225 // in the output section.
Rafael Espindola6119b862017-03-06 20:23:56 +0000226 uint64_t getOffset(uint64_t Offset) const;
Rui Ueyamab91bf1a2016-05-23 16:55:43 +0000227
Rafael Espindola6eae9f22016-07-21 13:32:37 +0000228 // Splittable sections are handled as a sequence of data
229 // rather than a single large blob of data.
230 std::vector<SectionPiece> Pieces;
Rui Ueyamac8e68842016-12-06 02:19:30 +0000231
232 // Returns I'th piece's data. This function is very hot when
233 // string merging is enabled, so we want to inline.
234 LLVM_ATTRIBUTE_ALWAYS_INLINE
235 llvm::CachedHashStringRef getData(size_t I) const {
236 size_t Begin = Pieces[I].InputOff;
237 size_t End;
238 if (Pieces.size() - 1 == I)
239 End = this->Data.size();
240 else
241 End = Pieces[I + 1].InputOff;
242
243 StringRef S = {(const char *)(this->Data.data() + Begin), End - Begin};
244 return {S, Hashes[I]};
245 }
Rafael Espindola6eae9f22016-07-21 13:32:37 +0000246
247 // Returns the SectionPiece at a given input section offset.
Rafael Espindola6119b862017-03-06 20:23:56 +0000248 SectionPiece *getSectionPiece(uint64_t Offset);
249 const SectionPiece *getSectionPiece(uint64_t Offset) const;
Rafael Espindola6eae9f22016-07-21 13:32:37 +0000250
Rafael Espindoladb5e56f2017-05-31 20:17:44 +0000251 SyntheticSection *getParent() const;
Rafael Espindola9e9754b2017-02-03 13:06:18 +0000252
Rui Ueyamab91bf1a2016-05-23 16:55:43 +0000253private:
Rui Ueyamae8a077b2016-11-26 15:15:11 +0000254 void splitStrings(ArrayRef<uint8_t> A, size_t Size);
255 void splitNonStrings(ArrayRef<uint8_t> A, size_t Size);
Rui Ueyamad6bd1372016-08-03 04:39:42 +0000256
Rui Ueyama77f2a872016-11-18 05:05:43 +0000257 std::vector<uint32_t> Hashes;
258
Rafael Espindola6119b862017-03-06 20:23:56 +0000259 mutable llvm::DenseMap<uint64_t, uint64_t> OffsetMap;
Kamil Rytarowskie739e492017-05-24 18:31:48 +0000260 mutable llvm::once_flag InitOffsetMap;
Rui Ueyama77f2a872016-11-18 05:05:43 +0000261
Rafael Espindola6119b862017-03-06 20:23:56 +0000262 llvm::DenseSet<uint64_t> LiveOffsets;
Rafael Espindolac159c962015-10-19 21:00:02 +0000263};
264
Rui Ueyamae084aac2017-09-18 23:07:21 +0000265struct EhSectionPiece {
Rui Ueyama014b0f22017-09-19 23:36:48 +0000266 EhSectionPiece(size_t Off, uint32_t Size, unsigned FirstRelocation)
267 : InputOff(Off), Size(Size), FirstRelocation(FirstRelocation) {
268 assert(Off < UINT32_MAX && Size < UINT32_MAX);
269 }
Rafael Espindola113860b2016-10-20 10:55:58 +0000270
Rui Ueyama014b0f22017-09-19 23:36:48 +0000271 ArrayRef<uint8_t> data(EhInputSection *Sec);
272 uint32_t InputOff;
273 int32_t OutputOff = -1;
Rui Ueyamae084aac2017-09-18 23:07:21 +0000274 uint32_t Size;
Rui Ueyama014b0f22017-09-19 23:36:48 +0000275 uint32_t FirstRelocation;
Rafael Espindola2deeb602016-07-21 20:18:30 +0000276};
277
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000278// This corresponds to a .eh_frame section of an input file.
Rafael Espindola5c02b742017-03-06 21:17:18 +0000279class EhInputSection : public InputSectionBase {
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000280public:
Rafael Espindola5c02b742017-03-06 21:17:18 +0000281 template <class ELFT>
Rui Ueyama709fb2bb12017-07-26 22:13:32 +0000282 EhInputSection(ObjFile<ELFT> *F, const typename ELFT::Shdr *Header,
Rafael Espindola5c02b742017-03-06 21:17:18 +0000283 StringRef Name);
Rafael Espindola5616adf2017-03-08 22:36:28 +0000284 static bool classof(const SectionBase *S);
Rafael Espindola5c02b742017-03-06 21:17:18 +0000285 template <class ELFT> void split();
286 template <class ELFT, class RelTy> void split(ArrayRef<RelTy> Rels);
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000287
Rafael Espindola6eae9f22016-07-21 13:32:37 +0000288 // Splittable sections are handled as a sequence of data
289 // rather than a single large blob of data.
Rafael Espindola2deeb602016-07-21 20:18:30 +0000290 std::vector<EhSectionPiece> Pieces;
Rafael Espindoladb5e56f2017-05-31 20:17:44 +0000291
292 SyntheticSection *getParent() const;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000293};
294
Rui Ueyama014b0f22017-09-19 23:36:48 +0000295inline ArrayRef<uint8_t> EhSectionPiece::data(EhInputSection *Sec) {
296 return {Sec->Data.data() + InputOff, Size};
297}
298
Rafael Espindola798ad9a2017-02-24 13:06:59 +0000299// This is a section that is added directly to an output section
300// instead of needing special combination via a synthetic section. This
301// includes all input sections with the exceptions of SHF_MERGE and
302// .eh_frame. It also includes the synthetic sections themselves.
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000303class InputSection : public InputSectionBase {
Rafael Espindolac159c962015-10-19 21:00:02 +0000304public:
Rafael Espindolafcd208f2017-03-08 19:35:29 +0000305 InputSection(uint64_t Flags, uint32_t Type, uint32_t Alignment,
Rafael Espindolac404d502017-02-23 02:32:18 +0000306 ArrayRef<uint8_t> Data, StringRef Name, Kind K = Regular);
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000307 template <class ELFT>
Rui Ueyama709fb2bb12017-07-26 22:13:32 +0000308 InputSection(ObjFile<ELFT> *F, const typename ELFT::Shdr *Header,
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000309 StringRef Name);
Rafael Espindolac159c962015-10-19 21:00:02 +0000310
311 // Write this section to a mmap'ed file, assuming Buf is pointing to
312 // beginning of the output section.
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000313 template <class ELFT> void writeTo(uint8_t *Buf);
Rafael Espindolac159c962015-10-19 21:00:02 +0000314
Rafael Espindoladb5e56f2017-05-31 20:17:44 +0000315 OutputSection *getParent() const;
316
Rui Ueyamaedffd912015-10-14 21:00:23 +0000317 // The offset from beginning of the output sections this section was assigned
318 // to. The writer sets a value.
Rui Ueyama55c3f892015-10-15 01:58:40 +0000319 uint64_t OutSecOff = 0;
Rui Ueyamaedffd912015-10-14 21:00:23 +0000320
Rafael Espindola5616adf2017-03-08 22:36:28 +0000321 static bool classof(const SectionBase *S);
George Rimar58941ee2016-02-25 08:23:37 +0000322
George Rimar1ec03e42017-03-21 09:13:27 +0000323 InputSectionBase *getRelocatedSection();
George Rimar58941ee2016-02-25 08:23:37 +0000324
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000325 template <class ELFT, class RelTy>
Rui Ueyama2b6fb802016-04-28 18:42:04 +0000326 void relocateNonAlloc(uint8_t *Buf, llvm::ArrayRef<RelTy> Rels);
327
Rui Ueyamabd1f0632016-11-20 02:39:59 +0000328 // Used by ICF.
Rui Ueyamafcd3fa82016-12-05 18:11:35 +0000329 uint32_t Class[2] = {0, 0};
Rui Ueyama0b289522016-02-25 18:43:51 +0000330
331 // Called by ICF to merge two input sections.
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000332 void replace(InputSection *Other);
Rui Ueyama0b289522016-02-25 18:43:51 +0000333
Rui Ueyamabd1f0632016-11-20 02:39:59 +0000334private:
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000335 template <class ELFT, class RelTy>
Rui Ueyamabd1f0632016-11-20 02:39:59 +0000336 void copyRelocations(uint8_t *Buf, llvm::ArrayRef<RelTy> Rels);
George Rimar3b189d12017-05-29 08:37:50 +0000337
Rui Ueyamaf08b38c2017-06-09 03:19:08 +0000338 template <class ELFT> void copyShtGroup(uint8_t *Buf);
Michael J. Spencer84487f12015-07-24 21:03:07 +0000339};
340
Rui Ueyama536a2672017-02-27 02:32:08 +0000341// The list of all input sections.
342extern std::vector<InputSectionBase *> InputSections;
343
George Rimard6bcde32017-08-04 10:25:29 +0000344// Builds section order for handling --symbol-ordering-file.
George Rimar696a7f92017-09-19 09:20:54 +0000345llvm::DenseMap<SectionBase *, int> buildSectionOrder();
George Rimard6bcde32017-08-04 10:25:29 +0000346
Rafael Espindolae0df00b2016-02-28 00:25:54 +0000347} // namespace elf
Rui Ueyamace039262017-01-06 10:04:08 +0000348
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000349std::string toString(const elf::InputSectionBase *);
Michael J. Spencer84487f12015-07-24 21:03:07 +0000350} // namespace lld
351
352#endif