blob: 58549c30f72a6a10892e8358c0e1caa102bd30ec [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"
Rui Ueyama3f851702017-10-02 21:00:41 +000016#include "lld/Common/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
Rui Ueyamaf52496e2017-11-03 21:21:47 +000027class Symbol;
Rafael Espindola32aca872016-10-05 18:40:00 +000028struct SectionPiece;
Rafael Espindola38c67a22016-04-15 14:41:56 +000029
Peter Collingbournee9a9e0a2017-11-06 04:35:31 +000030class Defined;
Rafael Espindola5c02b742017-03-06 21:17:18 +000031class SyntheticSection;
Rafael Espindola6119b862017-03-06 20:23:56 +000032class MergeSyntheticSection;
Rui Ueyama709fb2bb12017-07-26 22:13:32 +000033template <class ELFT> class ObjFile;
Rafael Espindola24e6f362017-02-24 15:07:30 +000034class OutputSection;
Michael J. Spencer84487f12015-07-24 21:03:07 +000035
Rafael Espindola5616adf2017-03-08 22:36:28 +000036// This is the base class of all sections that lld handles. Some are sections in
37// input files, some are sections in the produced output file and some exist
38// just as a convenience for implementing special ways of combining some
39// sections.
40class SectionBase {
Eugene Leviant97403d12016-09-01 09:55:57 +000041public:
Rafael Espindola5616adf2017-03-08 22:36:28 +000042 enum Kind { Regular, EHFrame, Merge, Synthetic, Output };
Eugene Leviant97403d12016-09-01 09:55:57 +000043
Rafael Espindola16853bb2016-09-08 12:33:41 +000044 Kind kind() const { return (Kind)SectionKind; }
Rafael Espindolac404d502017-02-23 02:32:18 +000045
46 StringRef Name;
47
Rafael Espindolaf4fb5fd2017-12-13 22:59:23 +000048 // This pointer points to the "real" instance of this instance.
49 // Usually Repl == this. However, if ICF merges two sections,
50 // Repl pointer of one section points to another section. So,
51 // if you need to get a pointer to this instance, do not use
52 // this but instead this->Repl.
53 SectionBase *Repl;
54
Rafael Espindolac404d502017-02-23 02:32:18 +000055 unsigned SectionKind : 3;
56
Rafael Espindola5616adf2017-03-08 22:36:28 +000057 // The next two bit fields are only used by InputSectionBase, but we
58 // put them here so the struct packs better.
59
Rafael Espindolac404d502017-02-23 02:32:18 +000060 // The garbage collector sets sections' Live bits.
61 // If GC is disabled, all sections are considered live by default.
Rui Ueyamae8936bc2017-10-08 01:55:29 +000062 unsigned Live : 1;
Rafael Espindolac404d502017-02-23 02:32:18 +000063
Peter Collingbourne6c55a702017-11-06 04:33:58 +000064 unsigned Bss : 1;
65
Rafael Espindola0e090522016-10-26 00:54:03 +000066 // These corresponds to the fields in Elf_Shdr.
Rui Ueyamae8936bc2017-10-08 01:55:29 +000067 uint32_t Alignment;
Rafael Espindolab4c9b812017-02-23 02:28:28 +000068 uint64_t Flags;
Rafael Espindolab4c9b812017-02-23 02:28:28 +000069 uint64_t Entsize;
Rafael Espindola0e090522016-10-26 00:54:03 +000070 uint32_t Type;
71 uint32_t Link;
72 uint32_t Info;
73
Rafael Espindola5616adf2017-03-08 22:36:28 +000074 OutputSection *getOutputSection();
75 const OutputSection *getOutputSection() const {
76 return const_cast<SectionBase *>(this)->getOutputSection();
77 }
78
79 // Translate an offset in the input section to an offset in the output
80 // section.
81 uint64_t getOffset(uint64_t Offset) const;
82
Rafael Espindola5616adf2017-03-08 22:36:28 +000083protected:
84 SectionBase(Kind SectionKind, StringRef Name, uint64_t Flags,
85 uint64_t Entsize, uint64_t Alignment, uint32_t Type,
86 uint32_t Info, uint32_t Link)
Rafael Espindolaf4fb5fd2017-12-13 22:59:23 +000087 : Name(Name), Repl(this), SectionKind(SectionKind), Live(false),
88 Bss(false), Alignment(Alignment), Flags(Flags), Entsize(Entsize),
89 Type(Type), Link(Link), Info(Info) {}
Rafael Espindola5616adf2017-03-08 22:36:28 +000090};
91
92// This corresponds to a section of an input file.
93class InputSectionBase : public SectionBase {
94public:
Rafael Espindolab4c9b812017-02-23 02:28:28 +000095 template <class ELFT>
Rafael Espindola60403272017-12-21 02:03:39 +000096 InputSectionBase(ObjFile<ELFT> &File, const typename ELFT::Shdr &Header,
Rafael Espindola042a3f22016-09-08 14:06:08 +000097 StringRef Name, Kind SectionKind);
Rafael Espindolab4c9b812017-02-23 02:28:28 +000098
99 InputSectionBase(InputFile *File, uint64_t Flags, uint32_t Type,
100 uint64_t Entsize, uint32_t Link, uint32_t Info,
Rafael Espindolafcd208f2017-03-08 19:35:29 +0000101 uint32_t Alignment, ArrayRef<uint8_t> Data, StringRef Name,
Rafael Espindola0e090522016-10-26 00:54:03 +0000102 Kind SectionKind);
Rafael Espindoladb5e56f2017-05-31 20:17:44 +0000103
Rui Ueyama124bedb2017-10-10 03:22:29 +0000104 static bool classof(const SectionBase *S) { return S->kind() != Output; }
105
106 // The file which contains this section. It's dynamic type is always
107 // ObjFile<ELFT>, but in order to avoid ELFT, we use InputFile as
108 // its static type.
109 InputFile *File;
110
111 template <class ELFT> ObjFile<ELFT> *getFile() const {
112 return cast_or_null<ObjFile<ELFT>>(File);
113 }
114
115 ArrayRef<uint8_t> Data;
116 uint64_t getOffsetInFile() const;
117
Rui Ueyamaea1398e2017-10-29 23:32:23 +0000118 // True if this section has already been placed to a linker script
119 // output section. This is needed because, in a linker script, you
120 // can refer to the same section more than once. For example, in
121 // the following linker script,
122 //
123 // .foo : { *(.text) }
124 // .bar : { *(.text) }
125 //
126 // .foo takes all .text sections, and .bar becomes empty. To achieve
127 // this, we need to memorize whether a section has been placed or
128 // not for each input section.
129 bool Assigned = false;
130
Rafael Espindoladb5e56f2017-05-31 20:17:44 +0000131 // Input sections are part of an output section. Special sections
132 // like .eh_frame and merge sections are first combined into a
133 // synthetic section that is then added to an output section. In all
134 // cases this points one level up.
135 SectionBase *Parent = nullptr;
Rui Ueyamac4aaed92015-10-22 18:49:53 +0000136
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000137 // Relocations that refer to this section.
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000138 const void *FirstRelocation = nullptr;
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000139 unsigned NumRelocations : 31;
140 unsigned AreRelocsRela : 1;
Rui Ueyama124bedb2017-10-10 03:22:29 +0000141
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000142 template <class ELFT> ArrayRef<typename ELFT::Rel> rels() const {
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000143 assert(!AreRelocsRela);
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000144 return llvm::makeArrayRef(
145 static_cast<const typename ELFT::Rel *>(FirstRelocation),
146 NumRelocations);
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000147 }
Rui Ueyama124bedb2017-10-10 03:22:29 +0000148
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000149 template <class ELFT> ArrayRef<typename ELFT::Rela> relas() const {
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000150 assert(AreRelocsRela);
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000151 return llvm::makeArrayRef(
152 static_cast<const typename ELFT::Rela *>(FirstRelocation),
153 NumRelocations);
Rafael Espindola9f0c4bb2016-11-10 14:53:24 +0000154 }
155
George Rimar647c1682017-02-17 19:34:05 +0000156 // InputSections that are dependent on us (reverse dependency for GC)
Rui Ueyama05433432017-10-11 04:01:13 +0000157 llvm::TinyPtrVector<InputSection *> DependentSections;
George Rimar647c1682017-02-17 19:34:05 +0000158
Rafael Espindola1a541122016-11-08 14:47:16 +0000159 // Returns the size of this section (even if this is a common or BSS.)
Rafael Espindola76b6bd32017-03-08 15:44:30 +0000160 size_t getSize() const;
Rafael Espindola1a541122016-11-08 14:47:16 +0000161
Rafael Espindolab47c6e52017-05-31 19:09:52 +0000162 InputSection *getLinkOrderDep() const;
Rafael Espindoladb9bf4d2015-11-11 16:50:37 +0000163
Rui Ueyamaf987fe72017-10-10 03:40:57 +0000164 // Compilers emit zlib-compressed debug sections if the -gz option
165 // is given. This function checks if this section is compressed, and
166 // if so, decompress in memory.
Rui Ueyamaac114d22018-02-12 21:56:14 +0000167 void maybeDecompress();
George Rimar602fbee2016-06-24 11:18:44 +0000168
Rui Ueyamada06bfb2016-11-25 18:51:53 +0000169 // Returns a source location string. Used to construct an error message.
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000170 template <class ELFT> std::string getLocation(uint64_t Offset);
Rui Ueyamaf52496e2017-11-03 21:21:47 +0000171 std::string getSrcMsg(const Symbol &Sym, uint64_t Offset);
Rui Ueyamad6b7a392017-10-27 03:13:54 +0000172 std::string getObjMsg(uint64_t Offset);
Rui Ueyamada06bfb2016-11-25 18:51:53 +0000173
Rui Ueyamaf987fe72017-10-10 03:40:57 +0000174 // Each section knows how to relocate itself. These functions apply
175 // relocations, assuming that Buf points to this section's copy in
176 // the mmap'ed output buffer.
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000177 template <class ELFT> void relocate(uint8_t *Buf, uint8_t *BufEnd);
Rafael Espindolaa6465bb2017-05-18 16:45:36 +0000178 void relocateAlloc(uint8_t *Buf, uint8_t *BufEnd);
Rafael Espindolac404d502017-02-23 02:32:18 +0000179
Rui Ueyamaf987fe72017-10-10 03:40:57 +0000180 // The native ELF reloc data type is not very convenient to handle.
181 // So we convert ELF reloc records to our own records in Relocations.cpp.
182 // This vector contains such "cooked" relocations.
Rafael Espindolac404d502017-02-23 02:32:18 +0000183 std::vector<Relocation> Relocations;
184
185 template <typename T> llvm::ArrayRef<T> getDataAs() const {
186 size_t S = Data.size();
187 assert(S % sizeof(T) == 0);
188 return llvm::makeArrayRef<T>((const T *)Data.data(), S / sizeof(T));
189 }
Rui Ueyama314a0052017-08-17 00:27:55 +0000190
191private:
Rui Ueyamaac114d22018-02-12 21:56:14 +0000192 // A pointer that owns decompressed data if a section is compressed by zlib.
Rui Ueyama314a0052017-08-17 00:27:55 +0000193 // Since the feature is not used often, this is usually a nullptr.
Rui Ueyamaac114d22018-02-12 21:56:14 +0000194 std::unique_ptr<char[]> DecompressBuf;
Rafael Espindolac159c962015-10-19 21:00:02 +0000195};
196
Rui Ueyama3ea87272016-05-22 00:13:04 +0000197// SectionPiece represents a piece of splittable section contents.
Rafael Espindola113860b2016-10-20 10:55:58 +0000198// We allocate a lot of these and binary search on them. This means that they
199// have to be as compact as possible, which is why we don't store the size (can
Rui Ueyamad5135b72017-10-24 21:44:43 +0000200// be found by looking at the next one).
Rui Ueyama3ea87272016-05-22 00:13:04 +0000201struct SectionPiece {
Rui Ueyama95bf5092017-10-21 23:20:13 +0000202 SectionPiece(size_t Off, uint32_t Hash, bool Live)
203 : InputOff(Off), Hash(Hash), OutputOff(-1),
204 Live(Live || !Config->GcSections) {}
Rui Ueyama34dc99e2016-05-22 01:15:32 +0000205
Rui Ueyama95bf5092017-10-21 23:20:13 +0000206 uint32_t InputOff;
207 uint32_t Hash;
Konstantin Zhuravlyov70abb6e2017-10-23 19:31:31 +0000208 int64_t OutputOff : 63;
Rui Ueyama95bf5092017-10-21 23:20:13 +0000209 uint64_t Live : 1;
Rui Ueyama3ea87272016-05-22 00:13:04 +0000210};
Rui Ueyama95bf5092017-10-21 23:20:13 +0000211
212static_assert(sizeof(SectionPiece) == 16, "SectionPiece is too big");
Rui Ueyama3ea87272016-05-22 00:13:04 +0000213
Rafael Espindolac159c962015-10-19 21:00:02 +0000214// This corresponds to a SHF_MERGE section of an input file.
Rafael Espindola6119b862017-03-06 20:23:56 +0000215class MergeInputSection : public InputSectionBase {
Rafael Espindolac159c962015-10-19 21:00:02 +0000216public:
Rafael Espindola6119b862017-03-06 20:23:56 +0000217 template <class ELFT>
Rafael Espindola60403272017-12-21 02:03:39 +0000218 MergeInputSection(ObjFile<ELFT> &F, const typename ELFT::Shdr &Header,
Rafael Espindola042a3f22016-09-08 14:06:08 +0000219 StringRef Name);
Rafael Espindola5c73c492017-12-21 01:21:59 +0000220 MergeInputSection(uint64_t Flags, uint32_t Type, uint64_t Entsize,
221 ArrayRef<uint8_t> Data, StringRef Name);
222
Rui Ueyama43ca7162017-10-01 23:46:31 +0000223 static bool classof(const SectionBase *S) { return S->kind() == Merge; }
Rui Ueyamab91bf1a2016-05-23 16:55:43 +0000224 void splitIntoPieces();
225
226 // Mark the piece at a given offset live. Used by GC.
Rafael Espindola6119b862017-03-06 20:23:56 +0000227 void markLiveAt(uint64_t Offset) {
George Rimarf4ca4a62017-10-24 08:26:32 +0000228 if (this->Flags & llvm::ELF::SHF_ALLOC)
229 LiveOffsets.insert(Offset);
Rafael Espindola116d83f2016-10-19 23:13:40 +0000230 }
Rui Ueyamab91bf1a2016-05-23 16:55:43 +0000231
232 // Translate an offset in the input section to an offset
233 // in the output section.
Rafael Espindola6119b862017-03-06 20:23:56 +0000234 uint64_t getOffset(uint64_t Offset) const;
Rui Ueyamab91bf1a2016-05-23 16:55:43 +0000235
Rafael Espindola6eae9f22016-07-21 13:32:37 +0000236 // Splittable sections are handled as a sequence of data
237 // rather than a single large blob of data.
238 std::vector<SectionPiece> Pieces;
Rui Ueyamac8e68842016-12-06 02:19:30 +0000239
240 // Returns I'th piece's data. This function is very hot when
241 // string merging is enabled, so we want to inline.
242 LLVM_ATTRIBUTE_ALWAYS_INLINE
243 llvm::CachedHashStringRef getData(size_t I) const {
244 size_t Begin = Pieces[I].InputOff;
Rui Ueyama95bf5092017-10-21 23:20:13 +0000245 size_t End =
246 (Pieces.size() - 1 == I) ? Data.size() : Pieces[I + 1].InputOff;
247 return {toStringRef(Data.slice(Begin, End - Begin)), Pieces[I].Hash};
Rui Ueyamac8e68842016-12-06 02:19:30 +0000248 }
Rafael Espindola6eae9f22016-07-21 13:32:37 +0000249
250 // Returns the SectionPiece at a given input section offset.
Rafael Espindola6119b862017-03-06 20:23:56 +0000251 SectionPiece *getSectionPiece(uint64_t Offset);
252 const SectionPiece *getSectionPiece(uint64_t Offset) const;
Rafael Espindola6eae9f22016-07-21 13:32:37 +0000253
Rafael Espindoladb5e56f2017-05-31 20:17:44 +0000254 SyntheticSection *getParent() const;
Rafael Espindola9e9754b2017-02-03 13:06:18 +0000255
Rui Ueyamab91bf1a2016-05-23 16:55:43 +0000256private:
Rui Ueyamae8a077b2016-11-26 15:15:11 +0000257 void splitStrings(ArrayRef<uint8_t> A, size_t Size);
258 void splitNonStrings(ArrayRef<uint8_t> A, size_t Size);
Rui Ueyamad6bd1372016-08-03 04:39:42 +0000259
Rui Ueyama95c142e2017-10-31 19:14:06 +0000260 mutable llvm::DenseMap<uint32_t, uint32_t> OffsetMap;
261 mutable llvm::once_flag InitOffsetMap;
262
Rafael Espindola6119b862017-03-06 20:23:56 +0000263 llvm::DenseSet<uint64_t> LiveOffsets;
Rafael Espindolac159c962015-10-19 21:00:02 +0000264};
265
Rui Ueyamae084aac2017-09-18 23:07:21 +0000266struct EhSectionPiece {
NAKAMURA Takumi169dbde2017-09-20 08:03:18 +0000267 EhSectionPiece(size_t Off, InputSectionBase *Sec, uint32_t Size,
268 unsigned FirstRelocation)
269 : InputOff(Off), Sec(Sec), Size(Size), FirstRelocation(FirstRelocation) {}
Rafael Espindola113860b2016-10-20 10:55:58 +0000270
NAKAMURA Takumi169dbde2017-09-20 08:03:18 +0000271 ArrayRef<uint8_t> data() { return {Sec->Data.data() + this->InputOff, Size}; }
272
273 size_t InputOff;
274 ssize_t OutputOff = -1;
275 InputSectionBase *Sec;
Rui Ueyamae084aac2017-09-18 23:07:21 +0000276 uint32_t Size;
NAKAMURA Takumi169dbde2017-09-20 08:03:18 +0000277 unsigned FirstRelocation;
Rafael Espindola2deeb602016-07-21 20:18:30 +0000278};
279
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000280// This corresponds to a .eh_frame section of an input file.
Rafael Espindola5c02b742017-03-06 21:17:18 +0000281class EhInputSection : public InputSectionBase {
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000282public:
Rafael Espindola5c02b742017-03-06 21:17:18 +0000283 template <class ELFT>
Rafael Espindola60403272017-12-21 02:03:39 +0000284 EhInputSection(ObjFile<ELFT> &F, const typename ELFT::Shdr &Header,
Rafael Espindola5c02b742017-03-06 21:17:18 +0000285 StringRef Name);
Rui Ueyama43ca7162017-10-01 23:46:31 +0000286 static bool classof(const SectionBase *S) { return S->kind() == EHFrame; }
Rafael Espindola5c02b742017-03-06 21:17:18 +0000287 template <class ELFT> void split();
288 template <class ELFT, class RelTy> void split(ArrayRef<RelTy> Rels);
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000289
Rafael Espindola6eae9f22016-07-21 13:32:37 +0000290 // Splittable sections are handled as a sequence of data
291 // rather than a single large blob of data.
Rafael Espindola2deeb602016-07-21 20:18:30 +0000292 std::vector<EhSectionPiece> Pieces;
Rafael Espindoladb5e56f2017-05-31 20:17:44 +0000293
294 SyntheticSection *getParent() const;
Rafael Espindola0c6a4f12015-11-11 19:54:14 +0000295};
296
Rafael Espindola798ad9a2017-02-24 13:06:59 +0000297// This is a section that is added directly to an output section
298// instead of needing special combination via a synthetic section. This
299// includes all input sections with the exceptions of SHF_MERGE and
300// .eh_frame. It also includes the synthetic sections themselves.
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000301class InputSection : public InputSectionBase {
Rafael Espindolac159c962015-10-19 21:00:02 +0000302public:
Rafael Espindolace3b52c2017-12-21 02:11:51 +0000303 InputSection(InputFile *F, uint64_t Flags, uint32_t Type, uint32_t Alignment,
Rafael Espindolac404d502017-02-23 02:32:18 +0000304 ArrayRef<uint8_t> Data, StringRef Name, Kind K = Regular);
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000305 template <class ELFT>
Rafael Espindola60403272017-12-21 02:03:39 +0000306 InputSection(ObjFile<ELFT> &F, const typename ELFT::Shdr &Header,
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000307 StringRef Name);
Rafael Espindolac159c962015-10-19 21:00:02 +0000308
309 // Write this section to a mmap'ed file, assuming Buf is pointing to
310 // beginning of the output section.
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000311 template <class ELFT> void writeTo(uint8_t *Buf);
Rafael Espindolac159c962015-10-19 21:00:02 +0000312
Rafael Espindoladb5e56f2017-05-31 20:17:44 +0000313 OutputSection *getParent() const;
314
James Henderson8d0efdd2017-12-12 11:51:13 +0000315 // This variable has two usages. Initially, it represents an index in the
316 // OutputSection's InputSection list, and is used when ordering SHF_LINK_ORDER
317 // sections. After assignAddresses is called, it represents the offset from
318 // the beginning of the output section this section was assigned to.
Rafael Espindola10bcc1c2017-12-12 17:37:01 +0000319 uint64_t OutSecOff = 0;
320
321 static bool classof(const SectionBase *S);
322
323 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
Rafael Espindolab01cd862017-12-13 01:39:35 +0000334 static InputSection Discarded;
335
Rui Ueyamabd1f0632016-11-20 02:39:59 +0000336private:
Rafael Espindola774ea7d2017-02-23 16:49:07 +0000337 template <class ELFT, class RelTy>
Rui Ueyamabd1f0632016-11-20 02:39:59 +0000338 void copyRelocations(uint8_t *Buf, llvm::ArrayRef<RelTy> Rels);
George Rimar3b189d12017-05-29 08:37:50 +0000339
Rui Ueyamaf08b38c2017-06-09 03:19:08 +0000340 template <class ELFT> void copyShtGroup(uint8_t *Buf);
Michael J. Spencer84487f12015-07-24 21:03:07 +0000341};
342
Rui Ueyama536a2672017-02-27 02:32:08 +0000343// The list of all input sections.
344extern std::vector<InputSectionBase *> InputSections;
Rafael Espindolae0df00b2016-02-28 00:25:54 +0000345} // namespace elf
Rui Ueyamace039262017-01-06 10:04:08 +0000346
Rafael Espindolab4c9b812017-02-23 02:28:28 +0000347std::string toString(const elf::InputSectionBase *);
Michael J. Spencer84487f12015-07-24 21:03:07 +0000348} // namespace lld
349
350#endif