1 //===- OutputSections.cpp -------------------------------------------------===//
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 #include "OutputSections.h"
11 #include "Config.h"
12 #include "LinkerScript.h"
13 #include "Memory.h"
14 #include "Strings.h"
15 #include "SymbolTable.h"
16 #include "SyntheticSections.h"
17 #include "Target.h"
18 #include "Threads.h"
19 #include "llvm/BinaryFormat/Dwarf.h"
20 #include "llvm/Support/Compression.h"
21 #include "llvm/Support/MD5.h"
22 #include "llvm/Support/MathExtras.h"
23 #include "llvm/Support/SHA1.h"
24 
25 using namespace llvm;
26 using namespace llvm::dwarf;
27 using namespace llvm::object;
28 using namespace llvm::support::endian;
29 using namespace llvm::ELF;
30 
31 using namespace lld;
32 using namespace lld::elf;
33 
34 uint8_t Out::First;
35 OutputSection *Out::Opd;
36 uint8_t *Out::OpdBuf;
37 PhdrEntry *Out::TlsPhdr;
38 OutputSection *Out::DebugInfo;
39 OutputSection *Out::ElfHeader;
40 OutputSection *Out::ProgramHeaders;
41 OutputSection *Out::PreinitArray;
42 OutputSection *Out::InitArray;
43 OutputSection *Out::FiniArray;
44 
45 std::vector<OutputSection *> elf::OutputSections;
46 
47 uint32_t OutputSection::getPhdrFlags() const {
48   uint32_t Ret = PF_R;
49   if (Flags & SHF_WRITE)
50     Ret |= PF_W;
51   if (Flags & SHF_EXECINSTR)
52     Ret |= PF_X;
53   return Ret;
54 }
55 
56 template <class ELFT>
57 void OutputSection::writeHeaderTo(typename ELFT::Shdr *Shdr) {
58   Shdr->sh_entsize = Entsize;
59   Shdr->sh_addralign = Alignment;
60   Shdr->sh_type = Type;
61   Shdr->sh_offset = Offset;
62   Shdr->sh_flags = Flags;
63   Shdr->sh_info = Info;
64   Shdr->sh_link = Link;
65   Shdr->sh_addr = Addr;
66   Shdr->sh_size = Size;
67   Shdr->sh_name = ShName;
68 }
69 
70 OutputSection::OutputSection(StringRef Name, uint32_t Type, uint64_t Flags)
71     : BaseCommand(OutputSectionKind),
72       SectionBase(Output, Name, Flags, /*Entsize*/ 0, /*Alignment*/ 1, Type,
73                   /*Info*/ 0,
74                   /*Link*/ 0),
75       SectionIndex(INT_MAX) {
76   Live = false;
77 }
78 
79 // We allow sections of types listed below to merged into a
80 // single progbits section. This is typically done by linker
81 // scripts. Merging nobits and progbits will force disk space
82 // to be allocated for nobits sections. Other ones don't require
83 // any special treatment on top of progbits, so there doesn't
84 // seem to be a harm in merging them.
85 static bool canMergeToProgbits(unsigned Type) {
86   return Type == SHT_NOBITS || Type == SHT_PROGBITS || Type == SHT_INIT_ARRAY ||
87          Type == SHT_PREINIT_ARRAY || Type == SHT_FINI_ARRAY ||
88          Type == SHT_NOTE;
89 }
90 
91 void OutputSection::addSection(InputSection *IS) {
92   if (!IS->Live) {
93     reportDiscarded(IS);
94     return;
95   }
96 
97   if (!Live) {
98     // If IS is the first section to be added to this section,
99     // initialize Type by IS->Type.
100     Live = true;
101     Type = IS->Type;
102   } else {
103     // Otherwise, check if new type or flags are compatible with existing ones.
104     if ((Flags & (SHF_ALLOC | SHF_TLS)) != (IS->Flags & (SHF_ALLOC | SHF_TLS)))
105       error("incompatible section flags for " + Name + "\n>>> " + toString(IS) +
106             ": 0x" + utohexstr(IS->Flags) + "\n>>> output section " + Name +
107             ": 0x" + utohexstr(Flags));
108 
109     if (Type != IS->Type) {
110       if (!canMergeToProgbits(Type) || !canMergeToProgbits(IS->Type))
111         error("section type mismatch for " + IS->Name + "\n>>> " +
112               toString(IS) + ": " +
113               getELFSectionTypeName(Config->EMachine, IS->Type) +
114               "\n>>> output section " + Name + ": " +
115               getELFSectionTypeName(Config->EMachine, Type));
116       Type = SHT_PROGBITS;
117     }
118   }
119 
120   IS->Parent = this;
121   Flags |= IS->Flags;
122   Alignment = std::max(Alignment, IS->Alignment);
123 
124   // The actual offsets will be computed by assignAddresses. For now, use
125   // crude approximation so that it is at least easy for other code to know the
126   // section order. It is also used to calculate the output section size early
127   // for compressed debug sections.
128   IS->OutSecOff = alignTo(Size, IS->Alignment);
129   this->Size = IS->OutSecOff + IS->getSize();
130 
131   // If this section contains a table of fixed-size entries, sh_entsize
132   // holds the element size. Consequently, if this contains two or more
133   // input sections, all of them must have the same sh_entsize. However,
134   // you can put different types of input sections into one output
135   // section by using linker scripts. I don't know what to do here.
136   // Probably we sholuld handle that as an error. But for now we just
137   // pick the largest sh_entsize.
138   this->Entsize = std::max(this->Entsize, IS->Entsize);
139 
140   if (!IS->Assigned) {
141     IS->Assigned = true;
142     if (Commands.empty() || !isa<InputSectionDescription>(Commands.back()))
143       Commands.push_back(make<InputSectionDescription>(""));
144     auto *ISD = cast<InputSectionDescription>(Commands.back());
145     ISD->Sections.push_back(IS);
146   }
147 }
148 
149 static SectionKey createKey(InputSectionBase *IS, StringRef OutsecName) {
150   // When control reaches here, mergeable sections have already been
151   // merged except the -r case. If that's the case, we want to combine
152   // mergeable sections by sh_entsize and sh_flags.
153   if (Config->Relocatable && (IS->Flags & SHF_MERGE)) {
154     uint64_t Flags = IS->Flags & (SHF_MERGE | SHF_STRINGS);
155     uint32_t Alignment = std::max<uint32_t>(IS->Alignment, IS->Entsize);
156     return SectionKey{OutsecName, Flags, Alignment};
157   }
158 
159   //  The ELF spec just says
160   // ----------------------------------------------------------------
161   // In the first phase, input sections that match in name, type and
162   // attribute flags should be concatenated into single sections.
163   // ----------------------------------------------------------------
164   //
165   // However, it is clear that at least some flags have to be ignored for
166   // section merging. At the very least SHF_GROUP and SHF_COMPRESSED have to be
167   // ignored. We should not have two output .text sections just because one was
168   // in a group and another was not for example.
169   //
170   // It also seems that that wording was a late addition and didn't get the
171   // necessary scrutiny.
172   //
173   // Merging sections with different flags is expected by some users. One
174   // reason is that if one file has
175   //
176   // int *const bar __attribute__((section(".foo"))) = (int *)0;
177   //
178   // gcc with -fPIC will produce a read only .foo section. But if another
179   // file has
180   //
181   // int zed;
182   // int *const bar __attribute__((section(".foo"))) = (int *)&zed;
183   //
184   // gcc with -fPIC will produce a read write section.
185   //
186   // Last but not least, when using linker script the merge rules are forced by
187   // the script. Unfortunately, linker scripts are name based. This means that
188   // expressions like *(.foo*) can refer to multiple input sections with
189   // different flags. We cannot put them in different output sections or we
190   // would produce wrong results for
191   //
192   // start = .; *(.foo.*) end = .; *(.bar)
193   //
194   // and a mapping of .foo1 and .bar1 to one section and .foo2 and .bar2 to
195   // another. The problem is that there is no way to layout those output
196   // sections such that the .foo sections are the only thing between the start
197   // and end symbols.
198   //
199   // Given the above issues, we instead merge sections by name and error on
200   // incompatible types and flags.
201   return SectionKey{OutsecName, 0, 0};
202 }
203 
204 OutputSectionFactory::OutputSectionFactory() {}
205 
206 void elf::sortByOrder(MutableArrayRef<InputSection *> In,
207                       std::function<int(InputSectionBase *S)> Order) {
208   typedef std::pair<int, InputSection *> Pair;
209   auto Comp = [](const Pair &A, const Pair &B) { return A.first < B.first; };
210 
211   std::vector<Pair> V;
212   for (InputSection *S : In)
213     V.push_back({Order(S), S});
214   std::stable_sort(V.begin(), V.end(), Comp);
215 
216   for (size_t I = 0; I < V.size(); ++I)
217     In[I] = V[I].second;
218 }
219 
220 void elf::reportDiscarded(InputSectionBase *IS) {
221   if (!Config->PrintGcSections)
222     return;
223   message("removing unused section from '" + IS->Name + "' in file '" +
224           IS->File->getName() + "'");
225 }
226 
227 static OutputSection *createSection(InputSectionBase *IS, StringRef OutsecName) {
228   OutputSection *Sec = Script->createOutputSection(OutsecName, "<internal>");
229   Sec->Type = IS->Type;
230   Sec->Flags = IS->Flags;
231   Sec->addSection(cast<InputSection>(IS));
232   return Sec;
233 }
234 
235 OutputSection *OutputSectionFactory::addInputSec(InputSectionBase *IS,
236                                                  StringRef OutsecName) {
237   if (!IS->Live) {
238     reportDiscarded(IS);
239     return nullptr;
240   }
241 
242   // Sections with SHT_GROUP or SHF_GROUP attributes reach here only when the -r
243   // option is given. A section with SHT_GROUP defines a "section group", and
244   // its members have SHF_GROUP attribute. Usually these flags have already been
245   // stripped by InputFiles.cpp as section groups are processed and uniquified.
246   // However, for the -r option, we want to pass through all section groups
247   // as-is because adding/removing members or merging them with other groups
248   // change their semantics.
249   if (IS->Type == SHT_GROUP || (IS->Flags & SHF_GROUP))
250     return createSection(IS, OutsecName);
251 
252   // Imagine .zed : { *(.foo) *(.bar) } script. Both foo and bar may have
253   // relocation sections .rela.foo and .rela.bar for example. Most tools do
254   // not allow multiple REL[A] sections for output section. Hence we
255   // should combine these relocation sections into single output.
256   // We skip synthetic sections because it can be .rela.dyn/.rela.plt or any
257   // other REL[A] sections created by linker itself.
258   if (!isa<SyntheticSection>(IS) &&
259       (IS->Type == SHT_REL || IS->Type == SHT_RELA)) {
260     auto *Sec = cast<InputSection>(IS);
261     OutputSection *Out = Sec->getRelocatedSection()->getOutputSection();
262 
263     if (Out->RelocationSection) {
264       Out->RelocationSection->addSection(Sec);
265       return nullptr;
266     }
267 
268     Out->RelocationSection = createSection(IS, OutsecName);
269     return Out->RelocationSection;
270   }
271 
272   SectionKey Key = createKey(IS, OutsecName);
273   OutputSection *&Sec = Map[Key];
274   if (Sec) {
275     Sec->addSection(cast<InputSection>(IS));
276     return nullptr;
277   }
278 
279   Sec = createSection(IS, OutsecName);
280   return Sec;
281 }
282 
283 OutputSectionFactory::~OutputSectionFactory() {}
284 
285 SectionKey DenseMapInfo<SectionKey>::getEmptyKey() {
286   return SectionKey{DenseMapInfo<StringRef>::getEmptyKey(), 0, 0};
287 }
288 
289 SectionKey DenseMapInfo<SectionKey>::getTombstoneKey() {
290   return SectionKey{DenseMapInfo<StringRef>::getTombstoneKey(), 0, 0};
291 }
292 
293 unsigned DenseMapInfo<SectionKey>::getHashValue(const SectionKey &Val) {
294   return hash_combine(Val.Name, Val.Flags, Val.Alignment);
295 }
296 
297 bool DenseMapInfo<SectionKey>::isEqual(const SectionKey &LHS,
298                                        const SectionKey &RHS) {
299   return DenseMapInfo<StringRef>::isEqual(LHS.Name, RHS.Name) &&
300          LHS.Flags == RHS.Flags && LHS.Alignment == RHS.Alignment;
301 }
302 
303 uint64_t elf::getHeaderSize() {
304   if (Config->OFormatBinary)
305     return 0;
306   return Out::ElfHeader->Size + Out::ProgramHeaders->Size;
307 }
308 
309 bool OutputSection::classof(const BaseCommand *C) {
310   return C->Kind == OutputSectionKind;
311 }
312 
313 void OutputSection::sort(std::function<int(InputSectionBase *S)> Order) {
314   assert(Commands.size() == 1);
315   sortByOrder(cast<InputSectionDescription>(Commands[0])->Sections, Order);
316 }
317 
318 // Fill [Buf, Buf + Size) with Filler.
319 // This is used for linker script "=fillexp" command.
320 static void fill(uint8_t *Buf, size_t Size, uint32_t Filler) {
321   size_t I = 0;
322   for (; I + 4 < Size; I += 4)
323     memcpy(Buf + I, &Filler, 4);
324   memcpy(Buf + I, &Filler, Size - I);
325 }
326 
327 // Compress section contents if this section contains debug info.
328 template <class ELFT> void OutputSection::maybeCompress() {
329   typedef typename ELFT::Chdr Elf_Chdr;
330 
331   // Compress only DWARF debug sections.
332   if (!Config->CompressDebugSections || (Flags & SHF_ALLOC) ||
333       !Name.startswith(".debug_"))
334     return;
335 
336   // Create a section header.
337   ZDebugHeader.resize(sizeof(Elf_Chdr));
338   auto *Hdr = reinterpret_cast<Elf_Chdr *>(ZDebugHeader.data());
339   Hdr->ch_type = ELFCOMPRESS_ZLIB;
340   Hdr->ch_size = Size;
341   Hdr->ch_addralign = Alignment;
342 
343   // Write section contents to a temporary buffer and compress it.
344   std::vector<uint8_t> Buf(Size);
345   writeTo<ELFT>(Buf.data());
346   if (Error E = zlib::compress(toStringRef(Buf), CompressedData))
347     fatal("compress failed: " + llvm::toString(std::move(E)));
348 
349   // Update section headers.
350   Size = sizeof(Elf_Chdr) + CompressedData.size();
351   Flags |= SHF_COMPRESSED;
352 }
353 
354 static void writeInt(uint8_t *Buf, uint64_t Data, uint64_t Size) {
355   if (Size == 1)
356     *Buf = Data;
357   else if (Size == 2)
358     write16(Buf, Data, Config->Endianness);
359   else if (Size == 4)
360     write32(Buf, Data, Config->Endianness);
361   else if (Size == 8)
362     write64(Buf, Data, Config->Endianness);
363   else
364     llvm_unreachable("unsupported Size argument");
365 }
366 
367 template <class ELFT> void OutputSection::writeTo(uint8_t *Buf) {
368   if (Type == SHT_NOBITS)
369     return;
370 
371   Loc = Buf;
372 
373   // If -compress-debug-section is specified and if this is a debug seciton,
374   // we've already compressed section contents. If that's the case,
375   // just write it down.
376   if (!CompressedData.empty()) {
377     memcpy(Buf, ZDebugHeader.data(), ZDebugHeader.size());
378     memcpy(Buf + ZDebugHeader.size(), CompressedData.data(),
379            CompressedData.size());
380     return;
381   }
382 
383   // Write leading padding.
384   std::vector<InputSection *> Sections;
385   for (BaseCommand *Cmd : Commands)
386     if (auto *ISD = dyn_cast<InputSectionDescription>(Cmd))
387       for (InputSection *IS : ISD->Sections)
388         if (IS->Live)
389           Sections.push_back(IS);
390   uint32_t Filler = getFiller();
391   if (Filler)
392     fill(Buf, Sections.empty() ? Size : Sections[0]->OutSecOff, Filler);
393 
394   parallelForEachN(0, Sections.size(), [=](size_t I) {
395     InputSection *IS = Sections[I];
396     IS->writeTo<ELFT>(Buf);
397 
398     // Fill gaps between sections.
399     if (Filler) {
400       uint8_t *Start = Buf + IS->OutSecOff + IS->getSize();
401       uint8_t *End;
402       if (I + 1 == Sections.size())
403         End = Buf + Size;
404       else
405         End = Buf + Sections[I + 1]->OutSecOff;
406       fill(Start, End - Start, Filler);
407     }
408   });
409 
410   // Linker scripts may have BYTE()-family commands with which you
411   // can write arbitrary bytes to the output. Process them if any.
412   for (BaseCommand *Base : Commands)
413     if (auto *Data = dyn_cast<BytesDataCommand>(Base))
414       writeInt(Buf + Data->Offset, Data->Expression().getValue(), Data->Size);
415 }
416 
417 static bool compareByFilePosition(InputSection *A, InputSection *B) {
418   // Synthetic doesn't have link order dependecy, stable_sort will keep it last
419   if (A->kind() == InputSectionBase::Synthetic ||
420       B->kind() == InputSectionBase::Synthetic)
421     return false;
422   InputSection *LA = A->getLinkOrderDep();
423   InputSection *LB = B->getLinkOrderDep();
424   OutputSection *AOut = LA->getParent();
425   OutputSection *BOut = LB->getParent();
426   if (AOut != BOut)
427     return AOut->SectionIndex < BOut->SectionIndex;
428   return LA->OutSecOff < LB->OutSecOff;
429 }
430 
431 template <class ELFT>
432 static void finalizeShtGroup(OutputSection *OS,
433                              ArrayRef<InputSection *> Sections) {
434   assert(Config->Relocatable && Sections.size() == 1);
435 
436   // sh_link field for SHT_GROUP sections should contain the section index of
437   // the symbol table.
438   OS->Link = InX::SymTab->getParent()->SectionIndex;
439 
440   // sh_info then contain index of an entry in symbol table section which
441   // provides signature of the section group.
442   ObjFile<ELFT> *Obj = Sections[0]->getFile<ELFT>();
443   ArrayRef<SymbolBody *> Symbols = Obj->getSymbols();
444   OS->Info = InX::SymTab->getSymbolIndex(Symbols[Sections[0]->Info]);
445 }
446 
447 template <class ELFT> void OutputSection::finalize() {
448   // Link order may be distributed across several InputSectionDescriptions
449   // but sort must consider them all at once.
450   std::vector<InputSection **> ScriptSections;
451   std::vector<InputSection *> Sections;
452   for (BaseCommand *Base : Commands) {
453     if (auto *ISD = dyn_cast<InputSectionDescription>(Base)) {
454       for (InputSection *&IS : ISD->Sections) {
455         ScriptSections.push_back(&IS);
456         Sections.push_back(IS);
457       }
458     }
459   }
460 
461   if (Flags & SHF_LINK_ORDER) {
462     std::stable_sort(Sections.begin(), Sections.end(), compareByFilePosition);
463     for (int I = 0, N = Sections.size(); I < N; ++I)
464       *ScriptSections[I] = Sections[I];
465 
466     // We must preserve the link order dependency of sections with the
467     // SHF_LINK_ORDER flag. The dependency is indicated by the sh_link field. We
468     // need to translate the InputSection sh_link to the OutputSection sh_link,
469     // all InputSections in the OutputSection have the same dependency.
470     if (auto *D = Sections.front()->getLinkOrderDep())
471       Link = D->getParent()->SectionIndex;
472   }
473 
474   if (Type == SHT_GROUP) {
475     finalizeShtGroup<ELFT>(this, Sections);
476     return;
477   }
478 
479   if (!Config->CopyRelocs || (Type != SHT_RELA && Type != SHT_REL))
480     return;
481 
482   InputSection *First = Sections[0];
483   if (isa<SyntheticSection>(First))
484     return;
485 
486   Link = InX::SymTab->getParent()->SectionIndex;
487   // sh_info for SHT_REL[A] sections should contain the section header index of
488   // the section to which the relocation applies.
489   InputSectionBase *S = First->getRelocatedSection();
490   Info = S->getOutputSection()->SectionIndex;
491   Flags |= SHF_INFO_LINK;
492 }
493 
494 // Returns true if S matches /Filename.?\.o$/.
495 static bool isCrtBeginEnd(StringRef S, StringRef Filename) {
496   if (!S.endswith(".o"))
497     return false;
498   S = S.drop_back(2);
499   if (S.endswith(Filename))
500     return true;
501   return !S.empty() && S.drop_back().endswith(Filename);
502 }
503 
504 static bool isCrtbegin(StringRef S) { return isCrtBeginEnd(S, "crtbegin"); }
505 static bool isCrtend(StringRef S) { return isCrtBeginEnd(S, "crtend"); }
506 
507 // .ctors and .dtors are sorted by this priority from highest to lowest.
508 //
509 //  1. The section was contained in crtbegin (crtbegin contains
510 //     some sentinel value in its .ctors and .dtors so that the runtime
511 //     can find the beginning of the sections.)
512 //
513 //  2. The section has an optional priority value in the form of ".ctors.N"
514 //     or ".dtors.N" where N is a number. Unlike .{init,fini}_array,
515 //     they are compared as string rather than number.
516 //
517 //  3. The section is just ".ctors" or ".dtors".
518 //
519 //  4. The section was contained in crtend, which contains an end marker.
520 //
521 // In an ideal world, we don't need this function because .init_array and
522 // .ctors are duplicate features (and .init_array is newer.) However, there
523 // are too many real-world use cases of .ctors, so we had no choice to
524 // support that with this rather ad-hoc semantics.
525 static bool compCtors(const InputSection *A, const InputSection *B) {
526   bool BeginA = isCrtbegin(A->File->getName());
527   bool BeginB = isCrtbegin(B->File->getName());
528   if (BeginA != BeginB)
529     return BeginA;
530   bool EndA = isCrtend(A->File->getName());
531   bool EndB = isCrtend(B->File->getName());
532   if (EndA != EndB)
533     return EndB;
534   StringRef X = A->Name;
535   StringRef Y = B->Name;
536   assert(X.startswith(".ctors") || X.startswith(".dtors"));
537   assert(Y.startswith(".ctors") || Y.startswith(".dtors"));
538   X = X.substr(6);
539   Y = Y.substr(6);
540   if (X.empty() && Y.empty())
541     return false;
542   return X < Y;
543 }
544 
545 // Sorts input sections by the special rules for .ctors and .dtors.
546 // Unfortunately, the rules are different from the one for .{init,fini}_array.
547 // Read the comment above.
548 void OutputSection::sortCtorsDtors() {
549   assert(Commands.size() == 1);
550   auto *ISD = cast<InputSectionDescription>(Commands[0]);
551   std::stable_sort(ISD->Sections.begin(), ISD->Sections.end(), compCtors);
552 }
553 
554 // If an input string is in the form of "foo.N" where N is a number,
555 // return N. Otherwise, returns 65536, which is one greater than the
556 // lowest priority.
557 int elf::getPriority(StringRef S) {
558   size_t Pos = S.rfind('.');
559   if (Pos == StringRef::npos)
560     return 65536;
561   int V;
562   if (!to_integer(S.substr(Pos + 1), V, 10))
563     return 65536;
564   return V;
565 }
566 
567 // Sorts input sections by section name suffixes, so that .foo.N comes
568 // before .foo.M if N < M. Used to sort .{init,fini}_array.N sections.
569 // We want to keep the original order if the priorities are the same
570 // because the compiler keeps the original initialization order in a
571 // translation unit and we need to respect that.
572 // For more detail, read the section of the GCC's manual about init_priority.
573 void OutputSection::sortInitFini() {
574   // Sort sections by priority.
575   sort([](InputSectionBase *S) { return getPriority(S->Name); });
576 }
577 
578 uint32_t OutputSection::getFiller() {
579   if (Filler)
580     return *Filler;
581   if (Flags & SHF_EXECINSTR)
582     return Target->TrapInstr;
583   return 0;
584 }
585 
586 template void OutputSection::writeHeaderTo<ELF32LE>(ELF32LE::Shdr *Shdr);
587 template void OutputSection::writeHeaderTo<ELF32BE>(ELF32BE::Shdr *Shdr);
588 template void OutputSection::writeHeaderTo<ELF64LE>(ELF64LE::Shdr *Shdr);
589 template void OutputSection::writeHeaderTo<ELF64BE>(ELF64BE::Shdr *Shdr);
590 
591 template void OutputSection::writeTo<ELF32LE>(uint8_t *Buf);
592 template void OutputSection::writeTo<ELF32BE>(uint8_t *Buf);
593 template void OutputSection::writeTo<ELF64LE>(uint8_t *Buf);
594 template void OutputSection::writeTo<ELF64BE>(uint8_t *Buf);
595 
596 template void OutputSection::maybeCompress<ELF32LE>();
597 template void OutputSection::maybeCompress<ELF32BE>();
598 template void OutputSection::maybeCompress<ELF64LE>();
599 template void OutputSection::maybeCompress<ELF64BE>();
600 
601 template void OutputSection::finalize<ELF32LE>();
602 template void OutputSection::finalize<ELF32BE>();
603 template void OutputSection::finalize<ELF64LE>();
604 template void OutputSection::finalize<ELF64BE>();
605