1 //===-- lib/MC/XCOFFObjectWriter.cpp - XCOFF file writer ------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file implements XCOFF object file writer information.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/BinaryFormat/XCOFF.h"
14 #include "llvm/MC/MCAsmLayout.h"
15 #include "llvm/MC/MCAssembler.h"
16 #include "llvm/MC/MCObjectWriter.h"
17 #include "llvm/MC/MCSectionXCOFF.h"
18 #include "llvm/MC/MCSymbolXCOFF.h"
19 #include "llvm/MC/MCValue.h"
20 #include "llvm/MC/MCXCOFFObjectWriter.h"
21 #include "llvm/MC/StringTableBuilder.h"
22 #include "llvm/Support/Error.h"
23 #include "llvm/Support/MathExtras.h"
29 // An XCOFF object file has a limited set of predefined sections. The most
30 // important ones for us (right now) are:
31 // .text --> contains program code and read-only data.
32 // .data --> contains initialized data, function descriptors, and the TOC.
33 // .bss --> contains uninitialized data.
34 // Each of these sections is composed of 'Control Sections'. A Control Section
35 // is more commonly referred to as a csect. A csect is an indivisible unit of
36 // code or data, and acts as a container for symbols. A csect is mapped
37 // into a section based on its storage-mapping class, with the exception of
38 // XMC_RW which gets mapped to either .data or .bss based on whether it's
39 // explicitly initialized or not.
41 // We don't represent the sections in the MC layer as there is nothing
42 // interesting about them at at that level: they carry information that is
43 // only relevant to the ObjectWriter, so we materialize them in this class.
46 constexpr unsigned DefaultSectionAlign = 4;
47 constexpr int16_t MaxSectionIndex = INT16_MAX;
49 // Packs the csect's alignment and type into a byte.
50 uint8_t getEncodedType(const MCSectionXCOFF *);
52 // Wrapper around an MCSymbolXCOFF.
54 const MCSymbolXCOFF *const MCSym;
55 uint32_t SymbolTableIndex;
57 XCOFF::StorageClass getStorageClass() const {
58 return MCSym->getStorageClass();
60 StringRef getName() const { return MCSym->getName(); }
61 Symbol(const MCSymbolXCOFF *MCSym) : MCSym(MCSym), SymbolTableIndex(-1) {}
64 // Wrapper for an MCSectionXCOFF.
65 struct ControlSection {
66 const MCSectionXCOFF *const MCCsect;
67 uint32_t SymbolTableIndex;
71 SmallVector<Symbol, 1> Syms;
72 StringRef getName() const { return MCCsect->getSectionName(); }
73 ControlSection(const MCSectionXCOFF *MCSec)
74 : MCCsect(MCSec), SymbolTableIndex(-1), Address(-1), Size(0) {}
77 // Type to be used for a container representing a set of csects with
78 // (approximately) the same storage mapping class. For example all the csects
79 // with a storage mapping class of `xmc_pr` will get placed into the same
81 using CsectGroup = std::deque<ControlSection>;
83 using CsectGroups = std::deque<CsectGroup *>;
85 // Represents the data related to a section excluding the csects that make up
86 // the raw data of the section. The csects are stored separately as not all
87 // sections contain csects, and some sections contain csects which are better
88 // stored separately, e.g. the .data section containing read-write, descriptor,
89 // TOCBase and TOC-entry csects.
91 char Name[XCOFF::NameSize];
92 // The physical/virtual address of the section. For an object file
93 // these values are equivalent.
96 uint32_t FileOffsetToData;
97 uint32_t FileOffsetToRelocations;
98 uint32_t RelocationCount;
103 // Virtual sections do not need storage allocated in the object file.
104 const bool IsVirtual;
106 // XCOFF has special section numbers for symbols:
107 // -2 Specifies N_DEBUG, a special symbolic debugging symbol.
108 // -1 Specifies N_ABS, an absolute symbol. The symbol has a value but is not
110 // 0 Specifies N_UNDEF, an undefined external symbol.
111 // Therefore, we choose -3 (N_DEBUG - 1) to represent a section index that
112 // hasn't been initialized.
113 static constexpr int16_t UninitializedIndex =
114 XCOFF::ReservedSectionNum::N_DEBUG - 1;
121 FileOffsetToData = 0;
122 FileOffsetToRelocations = 0;
124 Index = UninitializedIndex;
125 // Clear any csects we have stored.
126 for (auto *Group : Groups)
130 Section(const char *N, XCOFF::SectionTypeFlags Flags, bool IsVirtual,
132 : Address(0), Size(0), FileOffsetToData(0), FileOffsetToRelocations(0),
133 RelocationCount(0), Flags(Flags), Index(UninitializedIndex),
134 IsVirtual(IsVirtual), Groups(Groups) {
135 strncpy(Name, N, XCOFF::NameSize);
139 class XCOFFObjectWriter : public MCObjectWriter {
141 uint32_t SymbolTableEntryCount = 0;
142 uint32_t SymbolTableOffset = 0;
143 uint16_t SectionCount = 0;
145 support::endian::Writer W;
146 std::unique_ptr<MCXCOFFObjectTargetWriter> TargetObjectWriter;
147 StringTableBuilder Strings;
149 // CsectGroups. These store the csects which make up different parts of
150 // the sections. Should have one for each set of csects that get mapped into
151 // the same section and get handled in a 'similar' way.
152 CsectGroup UndefinedCsects;
153 CsectGroup ProgramCodeCsects;
154 CsectGroup ReadOnlyCsects;
155 CsectGroup DataCsects;
156 CsectGroup FuncDSCsects;
157 CsectGroup TOCCsects;
158 CsectGroup BSSCsects;
160 // The Predefined sections.
165 // All the XCOFF sections, in the order they will appear in the section header
167 std::array<Section *const, 3> Sections{{&Text, &Data, &BSS}};
169 CsectGroup &getCsectGroup(const MCSectionXCOFF *MCSec);
171 virtual void reset() override;
173 void executePostLayoutBinding(MCAssembler &, const MCAsmLayout &) override;
175 void recordRelocation(MCAssembler &, const MCAsmLayout &, const MCFragment *,
176 const MCFixup &, MCValue, uint64_t &) override;
178 uint64_t writeObject(MCAssembler &, const MCAsmLayout &) override;
180 static bool nameShouldBeInStringTable(const StringRef &);
181 void writeSymbolName(const StringRef &);
182 void writeSymbolTableEntryForCsectMemberLabel(const Symbol &,
183 const ControlSection &, int16_t,
185 void writeSymbolTableEntryForControlSection(const ControlSection &, int16_t,
186 XCOFF::StorageClass);
187 void writeFileHeader();
188 void writeSectionHeaderTable();
189 void writeSections(const MCAssembler &Asm, const MCAsmLayout &Layout);
190 void writeSymbolTable(const MCAsmLayout &Layout);
192 // Called after all the csects and symbols have been processed by
193 // `executePostLayoutBinding`, this function handles building up the majority
194 // of the structures in the object file representation. Namely:
195 // *) Calculates physical/virtual addresses, raw-pointer offsets, and section
197 // *) Assigns symbol table indices.
198 // *) Builds up the section header table by adding any non-empty sections to
200 void assignAddressesAndIndices(const MCAsmLayout &);
203 needsAuxiliaryHeader() const { /* TODO aux header support not implemented. */
207 // Returns the size of the auxiliary header to be written to the object file.
208 size_t auxiliaryHeaderSize() const {
209 assert(!needsAuxiliaryHeader() &&
210 "Auxiliary header support not implemented.");
215 XCOFFObjectWriter(std::unique_ptr<MCXCOFFObjectTargetWriter> MOTW,
216 raw_pwrite_stream &OS);
219 XCOFFObjectWriter::XCOFFObjectWriter(
220 std::unique_ptr<MCXCOFFObjectTargetWriter> MOTW, raw_pwrite_stream &OS)
221 : W(OS, support::big), TargetObjectWriter(std::move(MOTW)),
222 Strings(StringTableBuilder::XCOFF),
223 Text(".text", XCOFF::STYP_TEXT, /* IsVirtual */ false,
224 CsectGroups{&ProgramCodeCsects, &ReadOnlyCsects}),
225 Data(".data", XCOFF::STYP_DATA, /* IsVirtual */ false,
226 CsectGroups{&DataCsects, &FuncDSCsects, &TOCCsects}),
227 BSS(".bss", XCOFF::STYP_BSS, /* IsVirtual */ true,
228 CsectGroups{&BSSCsects}) {}
230 void XCOFFObjectWriter::reset() {
231 UndefinedCsects.clear();
233 // Reset any sections we have written to, and empty the section header table.
234 for (auto *Sec : Sections)
237 // Reset the symbol table and string table.
238 SymbolTableEntryCount = 0;
239 SymbolTableOffset = 0;
243 MCObjectWriter::reset();
246 CsectGroup &XCOFFObjectWriter::getCsectGroup(const MCSectionXCOFF *MCSec) {
247 switch (MCSec->getMappingClass()) {
249 assert(XCOFF::XTY_SD == MCSec->getCSectType() &&
250 "Only an initialized csect can contain program code.");
251 return ProgramCodeCsects;
253 assert(XCOFF::XTY_SD == MCSec->getCSectType() &&
254 "Only an initialized csect can contain read only data.");
255 return ReadOnlyCsects;
257 if (XCOFF::XTY_CM == MCSec->getCSectType())
260 if (XCOFF::XTY_SD == MCSec->getCSectType())
263 report_fatal_error("Unhandled mapping of read-write csect to section.");
267 assert(XCOFF::XTY_CM == MCSec->getCSectType() &&
268 "Mapping invalid csect. CSECT with bss storage class must be "
272 assert(XCOFF::XTY_SD == MCSec->getCSectType() &&
273 "Only an initialized csect can contain TOC-base.");
274 assert(TOCCsects.empty() &&
275 "We should have only one TOC-base, and it should be the first csect "
276 "in this CsectGroup.");
279 assert(XCOFF::XTY_SD == MCSec->getCSectType() &&
280 "Only an initialized csect can contain TC entry.");
281 assert(!TOCCsects.empty() &&
282 "We should at least have a TOC-base in this CsectGroup.");
285 report_fatal_error("Unhandled mapping of csect to section.");
289 void XCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
290 const MCAsmLayout &Layout) {
291 if (TargetObjectWriter->is64Bit())
292 report_fatal_error("64-bit XCOFF object files are not supported yet.");
294 // Maps the MC Section representation to its corresponding ControlSection
295 // wrapper. Needed for finding the ControlSection to insert an MCSymbol into
296 // from its containing MCSectionXCOFF.
297 DenseMap<const MCSectionXCOFF *, ControlSection *> WrapperMap;
299 for (const auto &S : Asm) {
300 const auto *MCSec = cast<const MCSectionXCOFF>(&S);
301 assert(WrapperMap.find(MCSec) == WrapperMap.end() &&
302 "Cannot add a csect twice.");
303 assert(XCOFF::XTY_ER != MCSec->getCSectType() &&
304 "An undefined csect should not get registered.");
306 // If the name does not fit in the storage provided in the symbol table
307 // entry, add it to the string table.
308 if (nameShouldBeInStringTable(MCSec->getSectionName()))
309 Strings.add(MCSec->getSectionName());
311 CsectGroup &Group = getCsectGroup(MCSec);
312 Group.emplace_back(MCSec);
313 WrapperMap[MCSec] = &Group.back();
316 for (const MCSymbol &S : Asm.symbols()) {
317 // Nothing to do for temporary symbols.
321 const MCSymbolXCOFF *XSym = cast<MCSymbolXCOFF>(&S);
322 const MCSectionXCOFF *ContainingCsect = XSym->getContainingCsect();
324 // Handle undefined symbol.
325 if (ContainingCsect->getCSectType() == XCOFF::XTY_ER) {
326 UndefinedCsects.emplace_back(ContainingCsect);
330 // If the symbol is the csect itself, we don't need to put the symbol
331 // into csect's Syms.
332 if (XSym == ContainingCsect->getQualNameSymbol())
335 assert(WrapperMap.find(ContainingCsect) != WrapperMap.end() &&
336 "Expected containing csect to exist in map");
338 // Lookup the containing csect and add the symbol to it.
339 WrapperMap[ContainingCsect]->Syms.emplace_back(XSym);
341 // If the name does not fit in the storage provided in the symbol table
342 // entry, add it to the string table.
343 if (nameShouldBeInStringTable(XSym->getName()))
344 Strings.add(XSym->getName());
348 assignAddressesAndIndices(Layout);
351 void XCOFFObjectWriter::recordRelocation(MCAssembler &, const MCAsmLayout &,
352 const MCFragment *, const MCFixup &,
353 MCValue, uint64_t &) {
354 // TODO: recordRelocation is not yet implemented.
357 void XCOFFObjectWriter::writeSections(const MCAssembler &Asm,
358 const MCAsmLayout &Layout) {
359 uint32_t CurrentAddressLocation = 0;
360 for (const auto *Section : Sections) {
361 // Nothing to write for this Section.
362 if (Section->Index == Section::UninitializedIndex || Section->IsVirtual)
365 assert(CurrentAddressLocation == Section->Address &&
366 "Sections should be written consecutively.");
367 for (const auto *Group : Section->Groups) {
368 for (const auto &Csect : *Group) {
369 if (uint32_t PaddingSize = Csect.Address - CurrentAddressLocation)
370 W.OS.write_zeros(PaddingSize);
372 Asm.writeSectionData(W.OS, Csect.MCCsect, Layout);
373 CurrentAddressLocation = Csect.Address + Csect.Size;
377 // The size of the tail padding in a section is the end virtual address of
378 // the current section minus the the end virtual address of the last csect
380 if (uint32_t PaddingSize =
381 Section->Address + Section->Size - CurrentAddressLocation) {
382 W.OS.write_zeros(PaddingSize);
383 CurrentAddressLocation += PaddingSize;
388 uint64_t XCOFFObjectWriter::writeObject(MCAssembler &Asm,
389 const MCAsmLayout &Layout) {
390 // We always emit a timestamp of 0 for reproducibility, so ensure incremental
391 // linking is not enabled, in case, like with Windows COFF, such a timestamp
392 // is incompatible with incremental linking of XCOFF.
393 if (Asm.isIncrementalLinkerCompatible())
394 report_fatal_error("Incremental linking not supported for XCOFF.");
396 if (TargetObjectWriter->is64Bit())
397 report_fatal_error("64-bit XCOFF object files are not supported yet.");
399 uint64_t StartOffset = W.OS.tell();
402 writeSectionHeaderTable();
403 writeSections(Asm, Layout);
404 // TODO writeRelocations();
406 writeSymbolTable(Layout);
407 // Write the string table.
410 return W.OS.tell() - StartOffset;
413 bool XCOFFObjectWriter::nameShouldBeInStringTable(const StringRef &SymbolName) {
414 return SymbolName.size() > XCOFF::NameSize;
417 void XCOFFObjectWriter::writeSymbolName(const StringRef &SymbolName) {
418 if (nameShouldBeInStringTable(SymbolName)) {
420 W.write<uint32_t>(Strings.getOffset(SymbolName));
422 char Name[XCOFF::NameSize+1];
423 std::strncpy(Name, SymbolName.data(), XCOFF::NameSize);
424 ArrayRef<char> NameRef(Name, XCOFF::NameSize);
429 void XCOFFObjectWriter::writeSymbolTableEntryForCsectMemberLabel(
430 const Symbol &SymbolRef, const ControlSection &CSectionRef,
431 int16_t SectionIndex, uint64_t SymbolOffset) {
432 // Name or Zeros and string table offset
433 writeSymbolName(SymbolRef.getName());
434 assert(SymbolOffset <= UINT32_MAX - CSectionRef.Address &&
435 "Symbol address overflows.");
436 W.write<uint32_t>(CSectionRef.Address + SymbolOffset);
437 W.write<int16_t>(SectionIndex);
438 // Basic/Derived type. See the description of the n_type field for symbol
439 // table entries for a detailed description. Since we don't yet support
440 // visibility, and all other bits are either optionally set or reserved, this
442 // TODO FIXME How to assert a symbol's visibilty is default?
443 // TODO Set the function indicator (bit 10, 0x0020) for functions
444 // when debugging is enabled.
445 W.write<uint16_t>(0);
446 W.write<uint8_t>(SymbolRef.getStorageClass());
447 // Always 1 aux entry for now.
450 // Now output the auxiliary entry.
451 W.write<uint32_t>(CSectionRef.SymbolTableIndex);
452 // Parameter typecheck hash. Not supported.
453 W.write<uint32_t>(0);
454 // Typecheck section number. Not supported.
455 W.write<uint16_t>(0);
456 // Symbol type: Label
457 W.write<uint8_t>(XCOFF::XTY_LD);
458 // Storage mapping class.
459 W.write<uint8_t>(CSectionRef.MCCsect->getMappingClass());
460 // Reserved (x_stab).
461 W.write<uint32_t>(0);
462 // Reserved (x_snstab).
463 W.write<uint16_t>(0);
466 void XCOFFObjectWriter::writeSymbolTableEntryForControlSection(
467 const ControlSection &CSectionRef, int16_t SectionIndex,
468 XCOFF::StorageClass StorageClass) {
469 // n_name, n_zeros, n_offset
470 writeSymbolName(CSectionRef.getName());
472 W.write<uint32_t>(CSectionRef.Address);
474 W.write<int16_t>(SectionIndex);
475 // Basic/Derived type. See the description of the n_type field for symbol
476 // table entries for a detailed description. Since we don't yet support
477 // visibility, and all other bits are either optionally set or reserved, this
479 // TODO FIXME How to assert a symbol's visibilty is default?
480 // TODO Set the function indicator (bit 10, 0x0020) for functions
481 // when debugging is enabled.
482 W.write<uint16_t>(0);
484 W.write<uint8_t>(StorageClass);
485 // Always 1 aux entry for now.
488 // Now output the auxiliary entry.
489 W.write<uint32_t>(CSectionRef.Size);
490 // Parameter typecheck hash. Not supported.
491 W.write<uint32_t>(0);
492 // Typecheck section number. Not supported.
493 W.write<uint16_t>(0);
495 W.write<uint8_t>(getEncodedType(CSectionRef.MCCsect));
496 // Storage mapping class.
497 W.write<uint8_t>(CSectionRef.MCCsect->getMappingClass());
498 // Reserved (x_stab).
499 W.write<uint32_t>(0);
500 // Reserved (x_snstab).
501 W.write<uint16_t>(0);
504 void XCOFFObjectWriter::writeFileHeader() {
506 W.write<uint16_t>(0x01df);
507 // Number of sections.
508 W.write<uint16_t>(SectionCount);
509 // Timestamp field. For reproducible output we write a 0, which represents no
512 // Byte Offset to the start of the symbol table.
513 W.write<uint32_t>(SymbolTableOffset);
514 // Number of entries in the symbol table.
515 W.write<int32_t>(SymbolTableEntryCount);
516 // Size of the optional header.
517 W.write<uint16_t>(0);
519 W.write<uint16_t>(0);
522 void XCOFFObjectWriter::writeSectionHeaderTable() {
523 for (const auto *Sec : Sections) {
524 // Nothing to write for this Section.
525 if (Sec->Index == Section::UninitializedIndex)
529 ArrayRef<char> NameRef(Sec->Name, XCOFF::NameSize);
532 // Write the Physical Address and Virtual Address. In an object file these
534 W.write<uint32_t>(Sec->Address);
535 W.write<uint32_t>(Sec->Address);
537 W.write<uint32_t>(Sec->Size);
538 W.write<uint32_t>(Sec->FileOffsetToData);
540 // Relocation pointer and Lineno pointer. Not supported yet.
541 W.write<uint32_t>(0);
542 W.write<uint32_t>(0);
544 // Relocation and line-number counts. Not supported yet.
545 W.write<uint16_t>(0);
546 W.write<uint16_t>(0);
548 W.write<int32_t>(Sec->Flags);
552 void XCOFFObjectWriter::writeSymbolTable(const MCAsmLayout &Layout) {
553 for (const auto &Csect : UndefinedCsects) {
554 writeSymbolTableEntryForControlSection(
555 Csect, XCOFF::ReservedSectionNum::N_UNDEF, Csect.MCCsect->getStorageClass());
558 for (const auto *Section : Sections) {
559 // Nothing to write for this Section.
560 if (Section->Index == Section::UninitializedIndex)
563 for (const auto *Group : Section->Groups) {
567 const int16_t SectionIndex = Section->Index;
568 for (const auto &Csect : *Group) {
569 // Write out the control section first and then each symbol in it.
570 writeSymbolTableEntryForControlSection(
571 Csect, SectionIndex, Csect.MCCsect->getStorageClass());
573 for (const auto &Sym : Csect.Syms)
574 writeSymbolTableEntryForCsectMemberLabel(
575 Sym, Csect, SectionIndex, Layout.getSymbolOffset(*(Sym.MCSym)));
581 void XCOFFObjectWriter::assignAddressesAndIndices(const MCAsmLayout &Layout) {
582 // The first symbol table entry is for the file name. We are not emitting it
583 // yet, so start at index 0.
584 uint32_t SymbolTableIndex = 0;
586 // Calculate indices for undefined symbols.
587 for (auto &Csect : UndefinedCsects) {
590 Csect.SymbolTableIndex = SymbolTableIndex;
591 // 1 main and 1 auxiliary symbol table entry for each contained symbol.
592 SymbolTableIndex += 2;
595 // The address corrresponds to the address of sections and symbols in the
596 // object file. We place the shared address 0 immediately after the
597 // section header table.
598 uint32_t Address = 0;
599 // Section indices are 1-based in XCOFF.
600 int32_t SectionIndex = 1;
602 for (auto *Section : Sections) {
604 llvm::all_of(Section->Groups,
605 [](const CsectGroup *Group) { return Group->empty(); });
609 if (SectionIndex > MaxSectionIndex)
610 report_fatal_error("Section index overflow!");
611 Section->Index = SectionIndex++;
614 bool SectionAddressSet = false;
615 for (auto *Group : Section->Groups) {
619 for (auto &Csect : *Group) {
620 const MCSectionXCOFF *MCSec = Csect.MCCsect;
621 Csect.Address = alignTo(Address, MCSec->getAlignment());
622 Csect.Size = Layout.getSectionAddressSize(MCSec);
623 Address = Csect.Address + Csect.Size;
624 Csect.SymbolTableIndex = SymbolTableIndex;
625 // 1 main and 1 auxiliary symbol table entry for the csect.
626 SymbolTableIndex += 2;
628 for (auto &Sym : Csect.Syms) {
629 Sym.SymbolTableIndex = SymbolTableIndex;
630 // 1 main and 1 auxiliary symbol table entry for each contained
632 SymbolTableIndex += 2;
636 if (!SectionAddressSet) {
637 Section->Address = Group->front().Address;
638 SectionAddressSet = true;
642 // Make sure the address of the next section aligned to
643 // DefaultSectionAlign.
644 Address = alignTo(Address, DefaultSectionAlign);
645 Section->Size = Address - Section->Address;
648 SymbolTableEntryCount = SymbolTableIndex;
650 // Calculate the RawPointer value for each section.
651 uint64_t RawPointer = sizeof(XCOFF::FileHeader32) + auxiliaryHeaderSize() +
652 SectionCount * sizeof(XCOFF::SectionHeader32);
653 for (auto *Sec : Sections) {
654 if (Sec->Index == Section::UninitializedIndex || Sec->IsVirtual)
657 Sec->FileOffsetToData = RawPointer;
658 RawPointer += Sec->Size;
661 // TODO Add in Relocation storage to the RawPointer Calculation.
662 // TODO What to align the SymbolTable to?
663 // TODO Error check that the number of symbol table entries fits in 32-bits
665 if (SymbolTableEntryCount)
666 SymbolTableOffset = RawPointer;
669 // Takes the log base 2 of the alignment and shifts the result into the 5 most
670 // significant bits of a byte, then or's in the csect type into the least
671 // significant 3 bits.
672 uint8_t getEncodedType(const MCSectionXCOFF *Sec) {
673 unsigned Align = Sec->getAlignment();
674 assert(isPowerOf2_32(Align) && "Alignment must be a power of 2.");
675 unsigned Log2Align = Log2_32(Align);
676 // Result is a number in the range [0, 31] which fits in the 5 least
677 // significant bits. Shift this value into the 5 most significant bits, and
678 // bitwise-or in the csect type.
679 uint8_t EncodedAlign = Log2Align << 3;
680 return EncodedAlign | Sec->getCSectType();
683 } // end anonymous namespace
685 std::unique_ptr<MCObjectWriter>
686 llvm::createXCOFFObjectWriter(std::unique_ptr<MCXCOFFObjectTargetWriter> MOTW,
687 raw_pwrite_stream &OS) {
688 return std::make_unique<XCOFFObjectWriter>(std::move(MOTW), OS);