1 //===- OutputSections.cpp -------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "OutputSections.h"
10 #include "Config.h"
11 #include "LinkerScript.h"
12 #include "SymbolTable.h"
13 #include "SyntheticSections.h"
14 #include "Target.h"
15 #include "lld/Common/Memory.h"
16 #include "lld/Common/Strings.h"
17 #include "llvm/BinaryFormat/Dwarf.h"
18 #include "llvm/Support/Compression.h"
19 #include "llvm/Support/MD5.h"
20 #include "llvm/Support/MathExtras.h"
21 #include "llvm/Support/Parallel.h"
22 #include "llvm/Support/SHA1.h"
23 #include "llvm/Support/TimeProfiler.h"
24 #include <regex>
25 #include <unordered_set>
26 
27 using namespace llvm;
28 using namespace llvm::dwarf;
29 using namespace llvm::object;
30 using namespace llvm::support::endian;
31 using namespace llvm::ELF;
32 using namespace lld;
33 using namespace lld::elf;
34 
35 uint8_t *Out::bufferStart;
36 PhdrEntry *Out::tlsPhdr;
37 OutputSection *Out::elfHeader;
38 OutputSection *Out::programHeaders;
39 OutputSection *Out::preinitArray;
40 OutputSection *Out::initArray;
41 OutputSection *Out::finiArray;
42 
43 std::vector<OutputSection *> elf::outputSections;
44 
45 uint32_t OutputSection::getPhdrFlags() const {
46   uint32_t ret = 0;
47   if (config->emachine != EM_ARM || !(flags & SHF_ARM_PURECODE))
48     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     : SectionCommand(OutputSectionKind),
72       SectionBase(Output, name, flags, /*Entsize*/ 0, /*Alignment*/ 1, type,
73                   /*Info*/ 0, /*Link*/ 0) {}
74 
75 // We allow sections of types listed below to merged into a
76 // single progbits section. This is typically done by linker
77 // scripts. Merging nobits and progbits will force disk space
78 // to be allocated for nobits sections. Other ones don't require
79 // any special treatment on top of progbits, so there doesn't
80 // seem to be a harm in merging them.
81 //
82 // NOTE: clang since rL252300 emits SHT_X86_64_UNWIND .eh_frame sections. Allow
83 // them to be merged into SHT_PROGBITS .eh_frame (GNU as .cfi_*).
84 static bool canMergeToProgbits(unsigned type) {
85   return type == SHT_NOBITS || type == SHT_PROGBITS || type == SHT_INIT_ARRAY ||
86          type == SHT_PREINIT_ARRAY || type == SHT_FINI_ARRAY ||
87          type == SHT_NOTE ||
88          (type == SHT_X86_64_UNWIND && config->emachine == EM_X86_64);
89 }
90 
91 // Record that isec will be placed in the OutputSection. isec does not become
92 // permanent until finalizeInputSections() is called. The function should not be
93 // used after finalizeInputSections() is called. If you need to add an
94 // InputSection post finalizeInputSections(), then you must do the following:
95 //
96 // 1. Find or create an InputSectionDescription to hold InputSection.
97 // 2. Add the InputSection to the InputSectionDescription::sections.
98 // 3. Call commitSection(isec).
99 void OutputSection::recordSection(InputSectionBase *isec) {
100   partition = isec->partition;
101   isec->parent = this;
102   if (commands.empty() || !isa<InputSectionDescription>(commands.back()))
103     commands.push_back(make<InputSectionDescription>(""));
104   auto *isd = cast<InputSectionDescription>(commands.back());
105   isd->sectionBases.push_back(isec);
106 }
107 
108 // Update fields (type, flags, alignment, etc) according to the InputSection
109 // isec. Also check whether the InputSection flags and type are consistent with
110 // other InputSections.
111 void OutputSection::commitSection(InputSection *isec) {
112   if (!hasInputSections) {
113     // If IS is the first section to be added to this section,
114     // initialize type, entsize and flags from isec.
115     hasInputSections = true;
116     type = isec->type;
117     entsize = isec->entsize;
118     flags = isec->flags;
119   } else {
120     // Otherwise, check if new type or flags are compatible with existing ones.
121     if ((flags ^ isec->flags) & SHF_TLS)
122       error("incompatible section flags for " + name + "\n>>> " + toString(isec) +
123             ": 0x" + utohexstr(isec->flags) + "\n>>> output section " + name +
124             ": 0x" + utohexstr(flags));
125 
126     if (type != isec->type) {
127       if (!canMergeToProgbits(type) || !canMergeToProgbits(isec->type))
128         error("section type mismatch for " + isec->name + "\n>>> " +
129               toString(isec) + ": " +
130               getELFSectionTypeName(config->emachine, isec->type) +
131               "\n>>> output section " + name + ": " +
132               getELFSectionTypeName(config->emachine, type));
133       type = SHT_PROGBITS;
134     }
135   }
136   if (noload)
137     type = SHT_NOBITS;
138 
139   isec->parent = this;
140   uint64_t andMask =
141       config->emachine == EM_ARM ? (uint64_t)SHF_ARM_PURECODE : 0;
142   uint64_t orMask = ~andMask;
143   uint64_t andFlags = (flags & isec->flags) & andMask;
144   uint64_t orFlags = (flags | isec->flags) & orMask;
145   flags = andFlags | orFlags;
146   if (nonAlloc)
147     flags &= ~(uint64_t)SHF_ALLOC;
148 
149   alignment = std::max(alignment, isec->alignment);
150 
151   // If this section contains a table of fixed-size entries, sh_entsize
152   // holds the element size. If it contains elements of different size we
153   // set sh_entsize to 0.
154   if (entsize != isec->entsize)
155     entsize = 0;
156 }
157 
158 // This function scans over the InputSectionBase list sectionBases to create
159 // InputSectionDescription::sections.
160 //
161 // It removes MergeInputSections from the input section array and adds
162 // new synthetic sections at the location of the first input section
163 // that it replaces. It then finalizes each synthetic section in order
164 // to compute an output offset for each piece of each input section.
165 void OutputSection::finalizeInputSections() {
166   std::vector<MergeSyntheticSection *> mergeSections;
167   for (SectionCommand *cmd : commands) {
168     auto *isd = dyn_cast<InputSectionDescription>(cmd);
169     if (!isd)
170       continue;
171     isd->sections.reserve(isd->sectionBases.size());
172     for (InputSectionBase *s : isd->sectionBases) {
173       MergeInputSection *ms = dyn_cast<MergeInputSection>(s);
174       if (!ms) {
175         isd->sections.push_back(cast<InputSection>(s));
176         continue;
177       }
178 
179       // We do not want to handle sections that are not alive, so just remove
180       // them instead of trying to merge.
181       if (!ms->isLive())
182         continue;
183 
184       auto i = llvm::find_if(mergeSections, [=](MergeSyntheticSection *sec) {
185         // While we could create a single synthetic section for two different
186         // values of Entsize, it is better to take Entsize into consideration.
187         //
188         // With a single synthetic section no two pieces with different Entsize
189         // could be equal, so we may as well have two sections.
190         //
191         // Using Entsize in here also allows us to propagate it to the synthetic
192         // section.
193         //
194         // SHF_STRINGS section with different alignments should not be merged.
195         return sec->flags == ms->flags && sec->entsize == ms->entsize &&
196                (sec->alignment == ms->alignment || !(sec->flags & SHF_STRINGS));
197       });
198       if (i == mergeSections.end()) {
199         MergeSyntheticSection *syn =
200             createMergeSynthetic(name, ms->type, ms->flags, ms->alignment);
201         mergeSections.push_back(syn);
202         i = std::prev(mergeSections.end());
203         syn->entsize = ms->entsize;
204         isd->sections.push_back(syn);
205       }
206       (*i)->addSection(ms);
207     }
208 
209     // sectionBases should not be used from this point onwards. Clear it to
210     // catch misuses.
211     isd->sectionBases.clear();
212 
213     // Some input sections may be removed from the list after ICF.
214     for (InputSection *s : isd->sections)
215       commitSection(s);
216   }
217   for (auto *ms : mergeSections)
218     ms->finalizeContents();
219 }
220 
221 static void sortByOrder(MutableArrayRef<InputSection *> in,
222                         llvm::function_ref<int(InputSectionBase *s)> order) {
223   std::vector<std::pair<int, InputSection *>> v;
224   for (InputSection *s : in)
225     v.push_back({order(s), s});
226   llvm::stable_sort(v, less_first());
227 
228   for (size_t i = 0; i < v.size(); ++i)
229     in[i] = v[i].second;
230 }
231 
232 uint64_t elf::getHeaderSize() {
233   if (config->oFormatBinary)
234     return 0;
235   return Out::elfHeader->size + Out::programHeaders->size;
236 }
237 
238 bool OutputSection::classof(const SectionCommand *c) {
239   return c->kind == OutputSectionKind;
240 }
241 
242 void OutputSection::sort(llvm::function_ref<int(InputSectionBase *s)> order) {
243   assert(isLive());
244   for (SectionCommand *b : commands)
245     if (auto *isd = dyn_cast<InputSectionDescription>(b))
246       sortByOrder(isd->sections, order);
247 }
248 
249 static void nopInstrFill(uint8_t *buf, size_t size) {
250   if (size == 0)
251     return;
252   unsigned i = 0;
253   if (size == 0)
254     return;
255   std::vector<std::vector<uint8_t>> nopFiller = *target->nopInstrs;
256   unsigned num = size / nopFiller.back().size();
257   for (unsigned c = 0; c < num; ++c) {
258     memcpy(buf + i, nopFiller.back().data(), nopFiller.back().size());
259     i += nopFiller.back().size();
260   }
261   unsigned remaining = size - i;
262   if (!remaining)
263     return;
264   assert(nopFiller[remaining - 1].size() == remaining);
265   memcpy(buf + i, nopFiller[remaining - 1].data(), remaining);
266 }
267 
268 // Fill [Buf, Buf + Size) with Filler.
269 // This is used for linker script "=fillexp" command.
270 static void fill(uint8_t *buf, size_t size,
271                  const std::array<uint8_t, 4> &filler) {
272   size_t i = 0;
273   for (; i + 4 < size; i += 4)
274     memcpy(buf + i, filler.data(), 4);
275   memcpy(buf + i, filler.data(), size - i);
276 }
277 
278 // Compress section contents if this section contains debug info.
279 template <class ELFT> void OutputSection::maybeCompress() {
280   using Elf_Chdr = typename ELFT::Chdr;
281 
282   // Compress only DWARF debug sections.
283   if (!config->compressDebugSections || (flags & SHF_ALLOC) ||
284       !name.startswith(".debug_"))
285     return;
286 
287   llvm::TimeTraceScope timeScope("Compress debug sections");
288 
289   // Create a section header.
290   zDebugHeader.resize(sizeof(Elf_Chdr));
291   auto *hdr = reinterpret_cast<Elf_Chdr *>(zDebugHeader.data());
292   hdr->ch_type = ELFCOMPRESS_ZLIB;
293   hdr->ch_size = size;
294   hdr->ch_addralign = alignment;
295 
296   // Write section contents to a temporary buffer and compress it.
297   std::vector<uint8_t> buf(size);
298   writeTo<ELFT>(buf.data());
299   // We chose 1 as the default compression level because it is the fastest. If
300   // -O2 is given, we use level 6 to compress debug info more by ~15%. We found
301   // that level 7 to 9 doesn't make much difference (~1% more compression) while
302   // they take significant amount of time (~2x), so level 6 seems enough.
303   if (Error e = zlib::compress(toStringRef(buf), compressedData,
304                                config->optimize >= 2 ? 6 : 1))
305     fatal("compress failed: " + llvm::toString(std::move(e)));
306 
307   // Update section headers.
308   size = sizeof(Elf_Chdr) + compressedData.size();
309   flags |= SHF_COMPRESSED;
310 }
311 
312 static void writeInt(uint8_t *buf, uint64_t data, uint64_t size) {
313   if (size == 1)
314     *buf = data;
315   else if (size == 2)
316     write16(buf, data);
317   else if (size == 4)
318     write32(buf, data);
319   else if (size == 8)
320     write64(buf, data);
321   else
322     llvm_unreachable("unsupported Size argument");
323 }
324 
325 template <class ELFT> void OutputSection::writeTo(uint8_t *buf) {
326   if (type == SHT_NOBITS)
327     return;
328 
329   // If --compress-debug-section is specified and if this is a debug section,
330   // we've already compressed section contents. If that's the case,
331   // just write it down.
332   if (!compressedData.empty()) {
333     memcpy(buf, zDebugHeader.data(), zDebugHeader.size());
334     memcpy(buf + zDebugHeader.size(), compressedData.data(),
335            compressedData.size());
336     return;
337   }
338 
339   // Write leading padding.
340   std::vector<InputSection *> sections = getInputSections(this);
341   std::array<uint8_t, 4> filler = getFiller();
342   bool nonZeroFiller = read32(filler.data()) != 0;
343   if (nonZeroFiller)
344     fill(buf, sections.empty() ? size : sections[0]->outSecOff, filler);
345 
346   parallelForEachN(0, sections.size(), [&](size_t i) {
347     InputSection *isec = sections[i];
348     isec->writeTo<ELFT>(buf);
349 
350     // Fill gaps between sections.
351     if (nonZeroFiller) {
352       uint8_t *start = buf + isec->outSecOff + isec->getSize();
353       uint8_t *end;
354       if (i + 1 == sections.size())
355         end = buf + size;
356       else
357         end = buf + sections[i + 1]->outSecOff;
358       if (isec->nopFiller) {
359         assert(target->nopInstrs);
360         nopInstrFill(start, end - start);
361       } else
362         fill(start, end - start, filler);
363     }
364   });
365 
366   // Linker scripts may have BYTE()-family commands with which you
367   // can write arbitrary bytes to the output. Process them if any.
368   for (SectionCommand *cmd : commands)
369     if (auto *data = dyn_cast<ByteCommand>(cmd))
370       writeInt(buf + data->offset, data->expression().getValue(), data->size);
371 }
372 
373 static void finalizeShtGroup(OutputSection *os,
374                              InputSection *section) {
375   assert(config->relocatable);
376 
377   // sh_link field for SHT_GROUP sections should contain the section index of
378   // the symbol table.
379   os->link = in.symTab->getParent()->sectionIndex;
380 
381   // sh_info then contain index of an entry in symbol table section which
382   // provides signature of the section group.
383   ArrayRef<Symbol *> symbols = section->file->getSymbols();
384   os->info = in.symTab->getSymbolIndex(symbols[section->info]);
385 
386   // Some group members may be combined or discarded, so we need to compute the
387   // new size. The content will be rewritten in InputSection::copyShtGroup.
388   std::unordered_set<uint32_t> seen;
389   ArrayRef<InputSectionBase *> sections = section->file->getSections();
390   for (const uint32_t &idx : section->getDataAs<uint32_t>().slice(1))
391     if (OutputSection *osec = sections[read32(&idx)]->getOutputSection())
392       seen.insert(osec->sectionIndex);
393   os->size = (1 + seen.size()) * sizeof(uint32_t);
394 }
395 
396 void OutputSection::finalize() {
397   InputSection *first = getFirstInputSection(this);
398 
399   if (flags & SHF_LINK_ORDER) {
400     // We must preserve the link order dependency of sections with the
401     // SHF_LINK_ORDER flag. The dependency is indicated by the sh_link field. We
402     // need to translate the InputSection sh_link to the OutputSection sh_link,
403     // all InputSections in the OutputSection have the same dependency.
404     if (auto *ex = dyn_cast<ARMExidxSyntheticSection>(first))
405       link = ex->getLinkOrderDep()->getParent()->sectionIndex;
406     else if (first->flags & SHF_LINK_ORDER)
407       if (auto *d = first->getLinkOrderDep())
408         link = d->getParent()->sectionIndex;
409   }
410 
411   if (type == SHT_GROUP) {
412     finalizeShtGroup(this, first);
413     return;
414   }
415 
416   if (!config->copyRelocs || (type != SHT_RELA && type != SHT_REL))
417     return;
418 
419   // Skip if 'first' is synthetic, i.e. not a section created by --emit-relocs.
420   // Normally 'type' was changed by 'first' so 'first' should be non-null.
421   // However, if the output section is .rela.dyn, 'type' can be set by the empty
422   // synthetic .rela.plt and first can be null.
423   if (!first || isa<SyntheticSection>(first))
424     return;
425 
426   link = in.symTab->getParent()->sectionIndex;
427   // sh_info for SHT_REL[A] sections should contain the section header index of
428   // the section to which the relocation applies.
429   InputSectionBase *s = first->getRelocatedSection();
430   info = s->getOutputSection()->sectionIndex;
431   flags |= SHF_INFO_LINK;
432 }
433 
434 // Returns true if S is in one of the many forms the compiler driver may pass
435 // crtbegin files.
436 //
437 // Gcc uses any of crtbegin[<empty>|S|T].o.
438 // Clang uses Gcc's plus clang_rt.crtbegin[<empty>|S|T][-<arch>|<empty>].o.
439 
440 static bool isCrtbegin(StringRef s) {
441   static std::regex re(R"((clang_rt\.)?crtbegin[ST]?(-.*)?\.o)");
442   s = sys::path::filename(s);
443   return std::regex_match(s.begin(), s.end(), re);
444 }
445 
446 static bool isCrtend(StringRef s) {
447   static std::regex re(R"((clang_rt\.)?crtend[ST]?(-.*)?\.o)");
448   s = sys::path::filename(s);
449   return std::regex_match(s.begin(), s.end(), re);
450 }
451 
452 // .ctors and .dtors are sorted by this order:
453 //
454 // 1. .ctors/.dtors in crtbegin (which contains a sentinel value -1).
455 // 2. The section is named ".ctors" or ".dtors" (priority: 65536).
456 // 3. The section has an optional priority value in the form of ".ctors.N" or
457 //    ".dtors.N" where N is a number in the form of %05u (priority: 65535-N).
458 // 4. .ctors/.dtors in crtend (which contains a sentinel value 0).
459 //
460 // For 2 and 3, the sections are sorted by priority from high to low, e.g.
461 // .ctors (65536), .ctors.00100 (65436), .ctors.00200 (65336).  In GNU ld's
462 // internal linker scripts, the sorting is by string comparison which can
463 // achieve the same goal given the optional priority values are of the same
464 // length.
465 //
466 // In an ideal world, we don't need this function because .init_array and
467 // .ctors are duplicate features (and .init_array is newer.) However, there
468 // are too many real-world use cases of .ctors, so we had no choice to
469 // support that with this rather ad-hoc semantics.
470 static bool compCtors(const InputSection *a, const InputSection *b) {
471   bool beginA = isCrtbegin(a->file->getName());
472   bool beginB = isCrtbegin(b->file->getName());
473   if (beginA != beginB)
474     return beginA;
475   bool endA = isCrtend(a->file->getName());
476   bool endB = isCrtend(b->file->getName());
477   if (endA != endB)
478     return endB;
479   return getPriority(a->name) > getPriority(b->name);
480 }
481 
482 // Sorts input sections by the special rules for .ctors and .dtors.
483 // Unfortunately, the rules are different from the one for .{init,fini}_array.
484 // Read the comment above.
485 void OutputSection::sortCtorsDtors() {
486   assert(commands.size() == 1);
487   auto *isd = cast<InputSectionDescription>(commands[0]);
488   llvm::stable_sort(isd->sections, compCtors);
489 }
490 
491 // If an input string is in the form of "foo.N" where N is a number, return N
492 // (65535-N if .ctors.N or .dtors.N). Otherwise, returns 65536, which is one
493 // greater than the lowest priority.
494 int elf::getPriority(StringRef s) {
495   size_t pos = s.rfind('.');
496   if (pos == StringRef::npos)
497     return 65536;
498   int v = 65536;
499   if (to_integer(s.substr(pos + 1), v, 10) &&
500       (pos == 6 && (s.startswith(".ctors") || s.startswith(".dtors"))))
501     v = 65535 - v;
502   return v;
503 }
504 
505 InputSection *elf::getFirstInputSection(const OutputSection *os) {
506   for (SectionCommand *cmd : os->commands)
507     if (auto *isd = dyn_cast<InputSectionDescription>(cmd))
508       if (!isd->sections.empty())
509         return isd->sections[0];
510   return nullptr;
511 }
512 
513 std::vector<InputSection *> elf::getInputSections(const OutputSection *os) {
514   std::vector<InputSection *> ret;
515   for (SectionCommand *cmd : os->commands)
516     if (auto *isd = dyn_cast<InputSectionDescription>(cmd))
517       ret.insert(ret.end(), isd->sections.begin(), isd->sections.end());
518   return ret;
519 }
520 
521 // Sorts input sections by section name suffixes, so that .foo.N comes
522 // before .foo.M if N < M. Used to sort .{init,fini}_array.N sections.
523 // We want to keep the original order if the priorities are the same
524 // because the compiler keeps the original initialization order in a
525 // translation unit and we need to respect that.
526 // For more detail, read the section of the GCC's manual about init_priority.
527 void OutputSection::sortInitFini() {
528   // Sort sections by priority.
529   sort([](InputSectionBase *s) { return getPriority(s->name); });
530 }
531 
532 std::array<uint8_t, 4> OutputSection::getFiller() {
533   if (filler)
534     return *filler;
535   if (flags & SHF_EXECINSTR)
536     return target->trapInstr;
537   return {0, 0, 0, 0};
538 }
539 
540 void OutputSection::checkDynRelAddends(const uint8_t *bufStart) {
541   assert(config->writeAddends && config->checkDynamicRelocs);
542   assert(type == SHT_REL || type == SHT_RELA);
543   std::vector<InputSection *> sections = getInputSections(this);
544   parallelForEachN(0, sections.size(), [&](size_t i) {
545     // When linking with -r or --emit-relocs we might also call this function
546     // for input .rel[a].<sec> sections which we simply pass through to the
547     // output. We skip over those and only look at the synthetic relocation
548     // sections created during linking.
549     const auto *sec = dyn_cast<RelocationBaseSection>(sections[i]);
550     if (!sec)
551       return;
552     for (const DynamicReloc &rel : sec->relocs) {
553       int64_t addend = rel.computeAddend();
554       const OutputSection *relOsec = rel.inputSec->getOutputSection();
555       assert(relOsec != nullptr && "missing output section for relocation");
556       const uint8_t *relocTarget =
557           bufStart + relOsec->offset + rel.inputSec->getOffset(rel.offsetInSec);
558       // For SHT_NOBITS the written addend is always zero.
559       int64_t writtenAddend =
560           relOsec->type == SHT_NOBITS
561               ? 0
562               : target->getImplicitAddend(relocTarget, rel.type);
563       if (addend != writtenAddend)
564         internalLinkerError(
565             getErrorLocation(relocTarget),
566             "wrote incorrect addend value 0x" + utohexstr(writtenAddend) +
567                 " instead of 0x" + utohexstr(addend) +
568                 " for dynamic relocation " + toString(rel.type) +
569                 " at offset 0x" + utohexstr(rel.getOffset()) +
570                 (rel.sym ? " against symbol " + toString(*rel.sym) : ""));
571     }
572   });
573 }
574 
575 template void OutputSection::writeHeaderTo<ELF32LE>(ELF32LE::Shdr *Shdr);
576 template void OutputSection::writeHeaderTo<ELF32BE>(ELF32BE::Shdr *Shdr);
577 template void OutputSection::writeHeaderTo<ELF64LE>(ELF64LE::Shdr *Shdr);
578 template void OutputSection::writeHeaderTo<ELF64BE>(ELF64BE::Shdr *Shdr);
579 
580 template void OutputSection::writeTo<ELF32LE>(uint8_t *Buf);
581 template void OutputSection::writeTo<ELF32BE>(uint8_t *Buf);
582 template void OutputSection::writeTo<ELF64LE>(uint8_t *Buf);
583 template void OutputSection::writeTo<ELF64BE>(uint8_t *Buf);
584 
585 template void OutputSection::maybeCompress<ELF32LE>();
586 template void OutputSection::maybeCompress<ELF32BE>();
587 template void OutputSection::maybeCompress<ELF64LE>();
588 template void OutputSection::maybeCompress<ELF64BE>();
589