49constexpr unsigned DefaultSectionAlign = 4;
50constexpr int16_t MaxSectionIndex = INT16_MAX;
55struct XCOFFRelocation {
56 uint32_t SymbolTableIndex;
57 uint32_t FixupOffsetInCsect;
64 const MCSymbolXCOFF *
const MCSym;
65 uint32_t SymbolTableIndex;
68 return MCSym->getVisibilityType();
72 return MCSym->getStorageClass();
74 StringRef getSymbolTableName()
const {
return MCSym->getSymbolTableName(); }
75 Symbol(
const MCSymbolXCOFF *MCSym) : MCSym(MCSym), SymbolTableIndex(-1) {}
81 const MCSectionXCOFF *
const MCSec;
82 uint32_t SymbolTableIndex;
88 StringRef getSymbolTableName()
const {
return MCSec->getSymbolTableName(); }
90 return MCSec->getVisibilityType();
92 XCOFFSection(
const MCSectionXCOFF *MCSec)
93 : MCSec(MCSec), SymbolTableIndex(-1), Address(-1), Size(0) {}
100using CsectGroup = std::deque<XCOFFSection>;
101using CsectGroups = std::deque<CsectGroup *>;
115 uint64_t FileOffsetToData;
116 uint64_t FileOffsetToRelocations;
117 uint32_t RelocationCount;
122 virtual uint64_t advanceFileOffset(
const uint64_t MaxRawDataSize,
123 const uint64_t RawPointer) {
124 FileOffsetToData = RawPointer;
125 uint64_t NewPointer = RawPointer + Size;
126 if (NewPointer > MaxRawDataSize)
138 static constexpr int16_t UninitializedIndex =
142 : Name(), Address(0), Size(0), FileOffsetToData(0),
143 FileOffsetToRelocations(0), RelocationCount(0), Flags(Flags),
144 Index(UninitializedIndex) {
146 memcpy(Name,
N.data(),
N.size());
149 virtual void reset() {
152 FileOffsetToData = 0;
153 FileOffsetToRelocations = 0;
155 Index = UninitializedIndex;
168 const bool IsVirtual;
175 : SectionEntry(
N,
Flags), IsVirtual(IsVirtual), Groups(Groups) {
177 memcpy(Name,
N.data(),
N.size());
180 void reset()
override {
181 SectionEntry::reset();
183 for (
auto *Group : Groups)
187 virtual ~CsectSectionEntry() =
default;
192 std::unique_ptr<XCOFFSection> DwarfSect;
202 uint64_t advanceFileOffset(
const uint64_t MaxRawDataSize,
203 const uint64_t RawPointer)
override {
204 FileOffsetToData = RawPointer;
205 uint64_t NewPointer = RawPointer + MemorySize;
206 assert(NewPointer <= MaxRawDataSize &&
207 "Section raw data overflowed this object file.");
211 DwarfSectionEntry(StringRef
N, int32_t Flags,
212 std::unique_ptr<XCOFFSection> Sect)
215 assert(DwarfSect->MCSec->isDwarfSect() &&
216 "This should be a DWARF section!");
218 memcpy(Name,
N.data(),
N.size());
221 DwarfSectionEntry(DwarfSectionEntry &&s) =
default;
223 virtual ~DwarfSectionEntry() =
default;
226struct ExceptionTableEntry {
228 uint64_t TrapAddress = ~0ul;
232 ExceptionTableEntry(
const MCSymbol *Trap,
unsigned Lang,
unsigned Reason)
233 : Trap(Trap), Lang(Lang), Reason(Reason) {}
236struct ExceptionInfo {
238 unsigned FunctionSize;
239 std::vector<ExceptionTableEntry> Entries;
243 std::map<const StringRef, ExceptionInfo> ExceptionTable;
244 bool isDebugEnabled =
false;
246 ExceptionSectionEntry(StringRef
N, int32_t Flags)
249 memcpy(Name,
N.data(),
N.size());
252 virtual ~ExceptionSectionEntry() =
default;
258 std::string Metadata;
262 CInfoSymInfo(std::string Name, std::string Metadata)
263 : Name(Name), Metadata(Metadata) {}
265 uint32_t paddingSize()
const {
266 return alignTo(Metadata.size(),
sizeof(uint32_t)) - Metadata.size();
270 uint32_t
size()
const {
271 return Metadata.size() + paddingSize() +
sizeof(uint32_t);
276 std::unique_ptr<CInfoSymInfo> Entry;
278 CInfoSymSectionEntry(StringRef
N, int32_t Flags) : SectionEntry(
N,
Flags) {}
279 virtual ~CInfoSymSectionEntry() =
default;
280 void addEntry(std::unique_ptr<CInfoSymInfo> NewEntry) {
281 Entry = std::move(NewEntry);
282 Entry->Offset =
sizeof(uint32_t);
283 Size += Entry->size();
285 void reset()
override {
286 SectionEntry::reset();
292 uint32_t SymbolTableEntryCount = 0;
293 uint64_t SymbolTableOffset = 0;
294 uint16_t SectionCount = 0;
295 uint32_t PaddingsBeforeDwarf = 0;
296 bool HasVisibility =
false;
298 support::endian::Writer W;
299 std::unique_ptr<MCXCOFFObjectTargetWriter> TargetObjectWriter;
300 StringTableBuilder Strings;
302 const uint64_t MaxRawDataSize =
303 TargetObjectWriter->is64Bit() ?
UINT64_MAX : UINT32_MAX;
308 DenseMap<const MCSectionXCOFF *, XCOFFSection *> SectionMap;
312 DenseMap<const MCSymbol *, uint32_t> SymbolIndexMap;
317 CsectGroup UndefinedCsects;
318 CsectGroup ProgramCodeCsects;
319 CsectGroup ReadOnlyCsects;
320 CsectGroup DataCsects;
321 CsectGroup FuncDSCsects;
322 CsectGroup TOCCsects;
323 CsectGroup BSSCsects;
324 CsectGroup TDataCsects;
325 CsectGroup TBSSCsects;
328 CsectSectionEntry Text;
329 CsectSectionEntry Data;
330 CsectSectionEntry BSS;
331 CsectSectionEntry TData;
332 CsectSectionEntry TBSS;
336 std::array<CsectSectionEntry *const, 5> Sections{
337 {&Text, &Data, &BSS, &TData, &TBSS}};
339 std::vector<DwarfSectionEntry> DwarfSections;
340 std::vector<SectionEntry> OverflowSections;
342 ExceptionSectionEntry ExceptionSection;
343 CInfoSymSectionEntry CInfoSymSection;
345 CsectGroup &getCsectGroup(
const MCSectionXCOFF *MCSec);
347 void reset()
override;
349 void executePostLayoutBinding()
override;
351 void recordRelocation(
const MCFragment &,
const MCFixup &, MCValue,
352 uint64_t &)
override;
354 uint64_t writeObject()
override;
356 bool is64Bit()
const {
return TargetObjectWriter->is64Bit(); }
357 bool nameShouldBeInStringTable(
const StringRef &);
358 void writeSymbolName(
const StringRef &);
359 bool auxFileSymNameShouldBeInStringTable(
const StringRef &);
360 void writeAuxFileSymName(
const StringRef &);
362 void writeSymbolEntryForCsectMemberLabel(
const Symbol &SymbolRef,
363 const XCOFFSection &CSectionRef,
364 int16_t SectionIndex,
365 uint64_t SymbolOffset);
366 void writeSymbolEntryForControlSection(
const XCOFFSection &CSectionRef,
367 int16_t SectionIndex,
369 void writeSymbolEntryForDwarfSection(
const XCOFFSection &DwarfSectionRef,
370 int16_t SectionIndex);
371 void writeFileHeader();
372 void writeAuxFileHeader();
373 void writeSectionHeader(
const SectionEntry *Sec);
374 void writeSectionHeaderTable();
375 void writeSections(
const MCAssembler &Asm);
376 void writeSectionForControlSectionEntry(
const MCAssembler &Asm,
377 const CsectSectionEntry &CsectEntry,
378 uint64_t &CurrentAddressLocation);
379 void writeSectionForDwarfSectionEntry(
const MCAssembler &Asm,
380 const DwarfSectionEntry &DwarfEntry,
381 uint64_t &CurrentAddressLocation);
383 writeSectionForExceptionSectionEntry(
const MCAssembler &Asm,
384 ExceptionSectionEntry &ExceptionEntry,
385 uint64_t &CurrentAddressLocation);
386 void writeSectionForCInfoSymSectionEntry(
const MCAssembler &Asm,
387 CInfoSymSectionEntry &CInfoSymEntry,
388 uint64_t &CurrentAddressLocation);
390 void writeSymbolAuxFileEntry(StringRef &Name, uint8_t ftype);
391 void writeSymbolAuxDwarfEntry(uint64_t LengthOfSectionPortion,
392 uint64_t NumberOfRelocEnt = 0);
393 void writeSymbolAuxCsectEntry(uint64_t SectionOrLength,
394 uint8_t SymbolAlignmentAndType,
396 void writeSymbolAuxFunctionEntry(uint32_t EntryOffset, uint32_t FunctionSize,
397 uint64_t LineNumberPointer,
399 void writeSymbolAuxExceptionEntry(uint64_t EntryOffset, uint32_t FunctionSize,
401 void writeSymbolEntry(StringRef SymbolName, uint64_t
Value,
404 void writeRelocations();
405 void writeRelocation(XCOFFRelocation Reloc,
const XCOFFSection &Section);
415 void assignAddressesAndIndices(MCAssembler &Asm);
417 void finalizeSectionInfo();
418 void finalizeRelocationInfo(SectionEntry *Sec, uint64_t RelCount);
419 void calcOffsetToRelocations(SectionEntry *Sec, uint64_t &RawPointer);
421 bool hasExceptionSection() {
422 return !ExceptionSection.ExceptionTable.empty();
424 unsigned getExceptionSectionSize();
425 unsigned getExceptionOffset(
const MCSymbol *Symbol);
427 size_t auxiliaryHeaderSize()
const {
433 XCOFFWriter(std::unique_ptr<MCXCOFFObjectTargetWriter> MOTW,
434 raw_pwrite_stream &OS);
436 void writeWord(uint64_t Word) {
440 void addExceptionEntry(
const MCSymbol *Symbol,
const MCSymbol *
Trap,
441 unsigned LanguageCode,
unsigned ReasonCode,
442 unsigned FunctionSize,
bool hasDebug)
override;
443 void addCInfoSymEntry(StringRef Name, StringRef
Metadata)
override;
446XCOFFWriter::XCOFFWriter(std::unique_ptr<MCXCOFFObjectTargetWriter> MOTW,
451 CsectGroups{&ProgramCodeCsects, &ReadOnlyCsects}),
453 CsectGroups{&DataCsects, &FuncDSCsects, &TOCCsects}),
455 CsectGroups{&BSSCsects}),
457 CsectGroups{&TDataCsects}),
459 CsectGroups{&TBSSCsects}),
463void XCOFFWriter::reset() {
465 SymbolIndexMap.
clear();
468 UndefinedCsects.clear();
470 for (
auto *Sec : Sections)
472 for (
auto &DwarfSec : DwarfSections)
474 for (
auto &OverflowSec : OverflowSections)
476 ExceptionSection.reset();
477 CInfoSymSection.reset();
480 SymbolTableEntryCount = 0;
481 SymbolTableOffset = 0;
483 PaddingsBeforeDwarf = 0;
489CsectGroup &XCOFFWriter::getCsectGroup(
const MCSectionXCOFF *MCSec) {
493 "Only an initialized csect can contain program code.");
494 return ProgramCodeCsects;
497 "Only an initialized csect can contain read only data.");
498 return ReadOnlyCsects;
511 "Mapping invalid csect. CSECT with bss storage class must be "
516 "Mapping invalid csect. CSECT with tdata storage class must be "
517 "an initialized csect.");
521 "Mapping invalid csect. CSECT with tbss storage class must be "
522 "an uninitialized csect.");
526 "Only an initialized csect can contain TOC-base.");
527 assert(TOCCsects.empty() &&
528 "We should have only one TOC-base, and it should be the first csect "
529 "in this CsectGroup.");
534 "A TOC symbol must be an initialized csect.");
535 assert(!TOCCsects.empty() &&
536 "We should at least have a TOC-base in this CsectGroup.");
541 "Symbol type incompatible with toc-data.");
542 assert(!TOCCsects.empty() &&
543 "We should at least have a TOC-base in this CsectGroup.");
550static MCSectionXCOFF *getContainingCsect(
const MCSymbolXCOFF *XSym) {
556void XCOFFWriter::executePostLayoutBinding() {
557 for (
const auto &S : *Asm) {
558 auto *MCSec =
static_cast<const MCSectionXCOFF *
>(&S);
559 assert(!SectionMap.
contains(MCSec) &&
"Cannot add a section twice.");
570 "An undefined csect should not get registered.");
571 CsectGroup &Group = getCsectGroup(MCSec);
572 Group.emplace_back(MCSec);
573 SectionMap[MCSec] = &Group.back();
576 std::unique_ptr<XCOFFSection> DwarfSec =
577 std::make_unique<XCOFFSection>(MCSec);
578 SectionMap[MCSec] = DwarfSec.get();
580 DwarfSectionEntry SecEntry(MCSec->
getName(),
582 std::move(DwarfSec));
583 DwarfSections.push_back(std::move(SecEntry));
588 for (
const MCSymbol &S :
Asm->symbols()) {
593 auto *XSym =
static_cast<const MCSymbolXCOFF *
>(&S);
594 const MCSectionXCOFF *ContainingCsect = getContainingCsect(XSym);
600 HasVisibility =
true;
604 UndefinedCsects.emplace_back(ContainingCsect);
605 SectionMap[ContainingCsect] = &UndefinedCsects.back();
621 "Expected containing csect to exist in map");
622 XCOFFSection *Csect = SectionMap[ContainingCsect];
624 assert(Csect->MCSec->
isCsect() &&
"only csect is supported now!");
625 Csect->Syms.emplace_back(XSym);
633 std::unique_ptr<CInfoSymInfo> &CISI = CInfoSymSection.Entry;
634 if (CISI && nameShouldBeInStringTable(CISI->Name))
635 Strings.
add(CISI->Name);
638 if (FileNames.empty())
639 FileNames.emplace_back(
".file", 0);
640 for (
const std::pair<std::string, size_t> &
F : FileNames) {
641 if (auxFileSymNameShouldBeInStringTable(
F.first))
642 Strings.
add(
F.first);
647 if (nameShouldBeInStringTable(
".file"))
648 Strings.
add(
".file");
649 StringRef Vers = CompilerVersion;
650 if (auxFileSymNameShouldBeInStringTable(Vers))
654 assignAddressesAndIndices(*Asm);
657void XCOFFWriter::recordRelocation(
const MCFragment &
F,
const MCFixup &
Fixup,
658 MCValue Target, uint64_t &FixedValue) {
659 auto getIndex = [
this](
const MCSymbol *Sym,
660 const MCSectionXCOFF *ContainingCsect) {
664 auto It = SymbolIndexMap.
find(Sym);
665 return It != SymbolIndexMap.
end()
670 auto getVirtualAddress =
672 const MCSectionXCOFF *ContainingSect) -> uint64_t {
674 if (ContainingSect->isDwarfSect())
675 return Asm->getSymbolOffset(*Sym);
679 return SectionMap[ContainingSect]->Address;
683 return SectionMap[ContainingSect]->Address +
Asm->getSymbolOffset(*Sym);
689 std::tie(
Type, SignAndSize) = TargetObjectWriter->getRelocTypeAndSignSize(
692 const MCSectionXCOFF *SymASec =
693 getContainingCsect(
static_cast<const MCSymbolXCOFF *
>(SymA));
695 "Expected containing csect to exist in map.");
697 assert((
Fixup.getOffset() <= MaxRawDataSize -
Asm->getFragmentOffset(
F)) &&
698 "Fragment offset + fixup offset is overflowed.");
699 uint32_t FixupOffsetInCsect =
Asm->getFragmentOffset(
F) +
Fixup.getOffset();
701 const uint32_t
Index = getIndex(SymA, SymASec);
702 if (
Type == XCOFF::RelocationType::R_POS ||
703 Type == XCOFF::RelocationType::R_TLS ||
704 Type == XCOFF::RelocationType::R_TLS_LE ||
705 Type == XCOFF::RelocationType::R_TLS_IE ||
706 Type == XCOFF::RelocationType::R_TLS_LD)
709 FixedValue = getVirtualAddress(SymA, SymASec) +
Target.getConstant();
710 else if (
Type == XCOFF::RelocationType::R_TLSM)
714 else if (
Type == XCOFF::RelocationType::R_TOC ||
715 Type == XCOFF::RelocationType::R_TOCL) {
726 int64_t TOCEntryOffset = SectionMap[SymASec]->Address -
727 TOCCsects.front().Address +
Target.getConstant();
744 if (
Type == XCOFF::RelocationType::R_TOC && !
isInt<16>(TOCEntryOffset))
747 FixedValue = TOCEntryOffset;
749 }
else if (
Type == XCOFF::RelocationType::R_RBR) {
750 auto *ParentSec =
static_cast<MCSectionXCOFF *
>(
F.getParent());
753 "Only XMC_PR csect may have the R_RBR relocation.");
757 uint64_t BRInstrAddress =
758 SectionMap[ParentSec]->Address + FixupOffsetInCsect;
761 FixedValue = getVirtualAddress(SymA, SymASec) - BRInstrAddress +
763 }
else if (
Type == XCOFF::RelocationType::R_REF) {
767 FixupOffsetInCsect = 0;
770 XCOFFRelocation Reloc = {
Index, FixupOffsetInCsect, SignAndSize,
Type};
771 auto *RelocationSec =
static_cast<MCSectionXCOFF *
>(
F.getParent());
773 "Expected containing csect to exist in map.");
774 SectionMap[RelocationSec]->Relocations.push_back(Reloc);
776 auto SymB =
static_cast<const MCSymbolXCOFF *
>(
Target.getSubSym());
782 const MCSectionXCOFF *SymBSec = getContainingCsect(SymB);
784 "Expected containing csect to exist in map.");
785 if (SymASec == SymBSec)
787 "relocation for paired relocatable term is not yet supported");
789 assert(
Type == XCOFF::RelocationType::R_POS &&
790 "SymA must be R_POS here if it's not opposite term or paired "
791 "relocatable term.");
792 const uint32_t IndexB = getIndex(SymB, SymBSec);
795 const uint8_t TypeB = XCOFF::RelocationType::R_NEG;
796 XCOFFRelocation RelocB = {IndexB, FixupOffsetInCsect, SignAndSize, TypeB};
797 SectionMap[RelocationSec]->Relocations.push_back(RelocB);
800 FixedValue -= getVirtualAddress(SymB, SymBSec);
803void XCOFFWriter::writeSections(
const MCAssembler &Asm) {
804 uint64_t CurrentAddressLocation = 0;
805 for (
const auto *Section : Sections)
806 writeSectionForControlSectionEntry(Asm, *Section, CurrentAddressLocation);
807 for (
const auto &DwarfSection : DwarfSections)
808 writeSectionForDwarfSectionEntry(Asm, DwarfSection, CurrentAddressLocation);
809 writeSectionForExceptionSectionEntry(Asm, ExceptionSection,
810 CurrentAddressLocation);
811 writeSectionForCInfoSymSectionEntry(Asm, CInfoSymSection,
812 CurrentAddressLocation);
815uint64_t XCOFFWriter::writeObject() {
820 finalizeSectionInfo();
821 uint64_t StartOffset =
W.OS.tell();
824 writeAuxFileHeader();
825 writeSectionHeaderTable();
832 return W.OS.tell() - StartOffset;
835bool XCOFFWriter::nameShouldBeInStringTable(
const StringRef &SymbolName) {
839void XCOFFWriter::writeSymbolName(
const StringRef &SymbolName) {
841 if (nameShouldBeInStringTable(SymbolName)) {
843 W.write<uint32_t>(Strings.
getOffset(SymbolName));
852void XCOFFWriter::writeSymbolEntry(StringRef SymbolName, uint64_t
Value,
855 uint8_t NumberOfAuxEntries) {
858 W.write<uint32_t>(Strings.
getOffset(SymbolName));
860 writeSymbolName(SymbolName);
863 W.write<int16_t>(SectionNumber);
866 W.write<uint8_t>(NumberOfAuxEntries);
869void XCOFFWriter::writeSymbolAuxCsectEntry(uint64_t SectionOrLength,
870 uint8_t SymbolAlignmentAndType,
872 W.write<uint32_t>(
is64Bit() ?
Lo_32(SectionOrLength) : SectionOrLength);
873 W.write<uint32_t>(0);
874 W.write<uint16_t>(0);
875 W.write<uint8_t>(SymbolAlignmentAndType);
878 W.write<uint32_t>(
Hi_32(SectionOrLength));
882 W.write<uint32_t>(0);
883 W.write<uint16_t>(0);
887bool XCOFFWriter::auxFileSymNameShouldBeInStringTable(
888 const StringRef &SymbolName) {
892void XCOFFWriter::writeAuxFileSymName(
const StringRef &SymbolName) {
894 if (auxFileSymNameShouldBeInStringTable(SymbolName)) {
896 W.write<uint32_t>(Strings.
getOffset(SymbolName));
906void XCOFFWriter::writeSymbolAuxFileEntry(StringRef &Name, uint8_t ftype) {
907 writeAuxFileSymName(Name);
908 W.write<uint8_t>(ftype);
916void XCOFFWriter::writeSymbolAuxDwarfEntry(uint64_t LengthOfSectionPortion,
917 uint64_t NumberOfRelocEnt) {
918 writeWord(LengthOfSectionPortion);
921 writeWord(NumberOfRelocEnt);
930void XCOFFWriter::writeSymbolEntryForCsectMemberLabel(
931 const Symbol &SymbolRef,
const XCOFFSection &CSectionRef,
932 int16_t SectionIndex, uint64_t SymbolOffset) {
933 assert(SymbolOffset <= MaxRawDataSize - CSectionRef.Address &&
934 "Symbol address overflowed.");
936 auto Entry = ExceptionSection.ExceptionTable.find(SymbolRef.MCSym->
getName());
937 if (Entry != ExceptionSection.ExceptionTable.end()) {
938 writeSymbolEntry(SymbolRef.getSymbolTableName(),
939 CSectionRef.Address + SymbolOffset, SectionIndex,
943 is64Bit() ? SymbolRef.getVisibilityType()
944 : SymbolRef.getVisibilityType() | 0x0020,
945 SymbolRef.getStorageClass(),
946 (
is64Bit() && ExceptionSection.isDebugEnabled) ? 3 : 2);
947 if (
is64Bit() && ExceptionSection.isDebugEnabled) {
950 writeSymbolAuxExceptionEntry(
951 ExceptionSection.FileOffsetToData +
952 getExceptionOffset(
Entry->second.FunctionSymbol),
953 Entry->second.FunctionSize,
954 SymbolIndexMap[
Entry->second.FunctionSymbol] + 4);
958 writeSymbolAuxFunctionEntry(
959 ExceptionSection.FileOffsetToData +
960 getExceptionOffset(
Entry->second.FunctionSymbol),
961 Entry->second.FunctionSize, 0,
962 (
is64Bit() && ExceptionSection.isDebugEnabled)
963 ? SymbolIndexMap[
Entry->second.FunctionSymbol] + 4
964 : SymbolIndexMap[
Entry->second.FunctionSymbol] + 3);
966 writeSymbolEntry(SymbolRef.getSymbolTableName(),
967 CSectionRef.Address + SymbolOffset, SectionIndex,
968 SymbolRef.getVisibilityType(),
969 SymbolRef.getStorageClass());
971 writeSymbolAuxCsectEntry(CSectionRef.SymbolTableIndex,
XCOFF::XTY_LD,
975void XCOFFWriter::writeSymbolEntryForDwarfSection(
976 const XCOFFSection &DwarfSectionRef, int16_t SectionIndex) {
979 writeSymbolEntry(DwarfSectionRef.getSymbolTableName(), 0,
982 writeSymbolAuxDwarfEntry(DwarfSectionRef.Size);
985void XCOFFWriter::writeSymbolEntryForControlSection(
986 const XCOFFSection &CSectionRef, int16_t SectionIndex,
988 writeSymbolEntry(CSectionRef.getSymbolTableName(), CSectionRef.Address,
989 SectionIndex, CSectionRef.getVisibilityType(),
StorageClass);
991 writeSymbolAuxCsectEntry(CSectionRef.Size, getEncodedType(CSectionRef.MCSec),
995void XCOFFWriter::writeSymbolAuxFunctionEntry(uint32_t EntryOffset,
996 uint32_t FunctionSize,
997 uint64_t LineNumberPointer,
1000 writeWord(LineNumberPointer);
1002 W.write<uint32_t>(EntryOffset);
1003 W.write<uint32_t>(FunctionSize);
1005 writeWord(LineNumberPointer);
1006 W.write<uint32_t>(EndIndex);
1008 W.OS.write_zeros(1);
1011 W.OS.write_zeros(2);
1015void XCOFFWriter::writeSymbolAuxExceptionEntry(uint64_t EntryOffset,
1016 uint32_t FunctionSize,
1017 uint32_t EndIndex) {
1018 assert(
is64Bit() &&
"Exception auxilliary entries are 64-bit only.");
1019 W.write<uint64_t>(EntryOffset);
1020 W.write<uint32_t>(FunctionSize);
1021 W.write<uint32_t>(EndIndex);
1022 W.OS.write_zeros(1);
1026void XCOFFWriter::writeFileHeader() {
1028 W.write<uint16_t>(SectionCount);
1029 W.write<int32_t>(0);
1030 writeWord(SymbolTableOffset);
1032 W.write<uint16_t>(auxiliaryHeaderSize());
1033 W.write<uint16_t>(0);
1034 W.write<int32_t>(SymbolTableEntryCount);
1036 W.write<int32_t>(SymbolTableEntryCount);
1037 W.write<uint16_t>(auxiliaryHeaderSize());
1038 W.write<uint16_t>(0);
1042void XCOFFWriter::writeAuxFileHeader() {
1043 if (!auxiliaryHeaderSize())
1045 W.write<uint16_t>(0);
1050 W.write<uint32_t>(Sections[0]->Size);
1051 W.write<uint32_t>(Sections[1]->Size);
1052 W.write<uint32_t>(Sections[2]->Size);
1053 W.write<uint32_t>(0);
1054 W.write<uint32_t>(Sections[0]->Address);
1055 W.write<uint32_t>(Sections[1]->Address);
1058void XCOFFWriter::writeSectionHeader(
const SectionEntry *Sec) {
1062 if (Sec->Index == SectionEntry::UninitializedIndex)
1071 writeWord(IsDwarf ? 0 : Sec->Address);
1073 writeWord((IsDwarf || IsOvrflo) ? 0 : Sec->Address);
1075 writeWord(Sec->Size);
1076 writeWord(Sec->FileOffsetToData);
1077 writeWord(Sec->FileOffsetToRelocations);
1081 W.write<uint32_t>(Sec->RelocationCount);
1082 W.write<uint32_t>(0);
1083 W.write<int32_t>(Sec->Flags);
1084 W.OS.write_zeros(4);
1090 W.write<uint16_t>(Sec->RelocationCount);
1092 ? Sec->RelocationCount
1094 W.write<int32_t>(Sec->Flags);
1098void XCOFFWriter::writeSectionHeaderTable() {
1099 for (
const auto *CsectSec : Sections)
1100 writeSectionHeader(CsectSec);
1101 for (
const auto &DwarfSec : DwarfSections)
1102 writeSectionHeader(&DwarfSec);
1103 for (
const auto &OverflowSec : OverflowSections)
1104 writeSectionHeader(&OverflowSec);
1105 if (hasExceptionSection())
1106 writeSectionHeader(&ExceptionSection);
1107 if (CInfoSymSection.Entry)
1108 writeSectionHeader(&CInfoSymSection);
1111void XCOFFWriter::writeRelocation(XCOFFRelocation Reloc,
1112 const XCOFFSection &Section) {
1114 writeWord(
Section.Address + Reloc.FixupOffsetInCsect);
1117 assert(
Section.MCSec->isDwarfSect() &&
"unsupport section type!");
1118 writeWord(Reloc.FixupOffsetInCsect);
1120 W.write<uint32_t>(Reloc.SymbolTableIndex);
1121 W.write<uint8_t>(Reloc.SignAndSize);
1122 W.write<uint8_t>(Reloc.Type);
1125void XCOFFWriter::writeRelocations() {
1126 for (
const auto *Section : Sections) {
1127 if (
Section->Index == SectionEntry::UninitializedIndex)
1131 for (
const auto *Group :
Section->Groups) {
1135 for (
const auto &Csect : *Group) {
1136 for (
const auto Reloc : Csect.Relocations)
1137 writeRelocation(Reloc, Csect);
1142 for (
const auto &DwarfSection : DwarfSections)
1143 for (
const auto &Reloc : DwarfSection.DwarfSect->Relocations)
1144 writeRelocation(Reloc, *DwarfSection.DwarfSect);
1147void XCOFFWriter::writeSymbolTable(MCAssembler &Asm) {
1149 StringRef Vers = CompilerVersion;
1151 for (
const std::pair<std::string, size_t> &
F : FileNames) {
1154 StringRef FileName =
F.first;
1176 int NumberOfFileAuxEntries = 1;
1178 ++NumberOfFileAuxEntries;
1179 writeSymbolEntry(
".file", 0, XCOFF::ReservedSectionNum::N_DEBUG,
1181 NumberOfFileAuxEntries);
1187 if (CInfoSymSection.Entry)
1188 writeSymbolEntry(CInfoSymSection.Entry->Name, CInfoSymSection.Entry->Offset,
1189 CInfoSymSection.Index,
1193 for (
const auto &Csect : UndefinedCsects) {
1194 writeSymbolEntryForControlSection(Csect, XCOFF::ReservedSectionNum::N_UNDEF,
1198 for (
const auto *Section : Sections) {
1199 if (
Section->Index == SectionEntry::UninitializedIndex)
1203 for (
const auto *Group :
Section->Groups) {
1207 const int16_t SectionIndex =
Section->Index;
1208 for (
const auto &Csect : *Group) {
1210 writeSymbolEntryForControlSection(Csect, SectionIndex,
1213 for (
const auto &Sym : Csect.Syms)
1214 writeSymbolEntryForCsectMemberLabel(
1215 Sym, Csect, SectionIndex,
Asm.getSymbolOffset(*(Sym.MCSym)));
1220 for (
const auto &DwarfSection : DwarfSections)
1221 writeSymbolEntryForDwarfSection(*DwarfSection.DwarfSect,
1222 DwarfSection.Index);
1225void XCOFFWriter::finalizeRelocationInfo(SectionEntry *Sec, uint64_t RelCount) {
1234 SecEntry.RelocationCount = Sec->Index;
1238 SecEntry.Address = RelCount;
1239 SecEntry.Index = ++SectionCount;
1240 OverflowSections.push_back(std::move(SecEntry));
1246 Sec->RelocationCount = RelCount;
1250void XCOFFWriter::calcOffsetToRelocations(SectionEntry *Sec,
1251 uint64_t &RawPointer) {
1252 if (!Sec->RelocationCount)
1255 Sec->FileOffsetToRelocations = RawPointer;
1256 uint64_t RelocationSizeInSec = 0;
1260 for (
auto &OverflowSec : OverflowSections) {
1261 if (OverflowSec.RelocationCount ==
static_cast<uint32_t
>(Sec->Index)) {
1262 RelocationSizeInSec =
1267 OverflowSec.FileOffsetToRelocations = Sec->FileOffsetToRelocations;
1270 assert(RelocationSizeInSec &&
"Overflow section header doesn't exist.");
1272 RelocationSizeInSec = Sec->RelocationCount *
1277 RawPointer += RelocationSizeInSec;
1278 if (RawPointer > MaxRawDataSize)
1282void XCOFFWriter::finalizeSectionInfo() {
1283 for (
auto *Section : Sections) {
1284 if (
Section->Index == SectionEntry::UninitializedIndex)
1288 uint64_t RelCount = 0;
1289 for (
const auto *Group :
Section->Groups) {
1293 for (
auto &Csect : *Group)
1294 RelCount += Csect.Relocations.size();
1296 finalizeRelocationInfo(Section, RelCount);
1299 for (
auto &DwarfSection : DwarfSections)
1300 finalizeRelocationInfo(&DwarfSection,
1301 DwarfSection.DwarfSect->Relocations.size());
1304 uint64_t RawPointer =
1309 auxiliaryHeaderSize();
1312 for (
auto *Sec : Sections) {
1313 if (Sec->Index == SectionEntry::UninitializedIndex || Sec->IsVirtual)
1316 RawPointer = Sec->advanceFileOffset(MaxRawDataSize, RawPointer);
1319 if (!DwarfSections.empty()) {
1320 RawPointer += PaddingsBeforeDwarf;
1321 for (auto &DwarfSection : DwarfSections) {
1322 RawPointer = DwarfSection.advanceFileOffset(MaxRawDataSize, RawPointer);
1326 if (hasExceptionSection())
1327 RawPointer = ExceptionSection.advanceFileOffset(MaxRawDataSize, RawPointer);
1329 if (CInfoSymSection.Entry)
1330 RawPointer = CInfoSymSection.advanceFileOffset(MaxRawDataSize, RawPointer);
1332 for (
auto *Sec : Sections) {
1333 if (Sec->Index != SectionEntry::UninitializedIndex)
1334 calcOffsetToRelocations(Sec, RawPointer);
1337 for (
auto &DwarfSec : DwarfSections)
1338 calcOffsetToRelocations(&DwarfSec, RawPointer);
1342 if (SymbolTableEntryCount)
1343 SymbolTableOffset = RawPointer;
1346void XCOFFWriter::addExceptionEntry(
const MCSymbol *Symbol,
1347 const MCSymbol *
Trap,
unsigned LanguageCode,
1348 unsigned ReasonCode,
unsigned FunctionSize,
1353 ExceptionSection.isDebugEnabled =
true;
1354 auto Entry = ExceptionSection.ExceptionTable.find(
Symbol->getName());
1355 if (Entry != ExceptionSection.ExceptionTable.end()) {
1356 Entry->second.Entries.push_back(
1357 ExceptionTableEntry(
Trap, LanguageCode, ReasonCode));
1360 ExceptionInfo NewEntry;
1361 NewEntry.FunctionSymbol =
Symbol;
1362 NewEntry.FunctionSize = FunctionSize;
1363 NewEntry.Entries.push_back(
1364 ExceptionTableEntry(
Trap, LanguageCode, ReasonCode));
1365 ExceptionSection.ExceptionTable.insert(
1366 std::pair<const StringRef, ExceptionInfo>(
Symbol->getName(), NewEntry));
1369unsigned XCOFFWriter::getExceptionSectionSize() {
1370 unsigned EntryNum = 0;
1372 for (
const auto &TableEntry : ExceptionSection.ExceptionTable)
1375 EntryNum += TableEntry.second.Entries.size() + 1;
1381unsigned XCOFFWriter::getExceptionOffset(
const MCSymbol *Symbol) {
1382 unsigned EntryNum = 0;
1383 for (
const auto &TableEntry : ExceptionSection.ExceptionTable) {
1384 if (Symbol == TableEntry.second.FunctionSymbol)
1386 EntryNum += TableEntry.second.Entries.size() + 1;
1392void XCOFFWriter::addCInfoSymEntry(StringRef Name, StringRef
Metadata) {
1393 assert(!CInfoSymSection.Entry &&
"Multiple entries are not supported");
1394 CInfoSymSection.addEntry(
1395 std::make_unique<CInfoSymInfo>(
Name.str(),
Metadata.str()));
1398void XCOFFWriter::assignAddressesAndIndices(MCAssembler &Asm) {
1401 uint32_t SymbolTableIndex =
1402 (2 + (CompilerVersion.empty() ? 0 : 1)) * FileNames.size();
1404 if (CInfoSymSection.Entry)
1408 for (
auto &Csect : UndefinedCsects) {
1411 Csect.SymbolTableIndex = SymbolTableIndex;
1414 SymbolTableIndex += 2;
1422 int32_t SectionIndex = 1;
1423 bool HasTDataSection =
false;
1425 for (
auto *Section : Sections) {
1426 const bool IsEmpty =
1428 [](
const CsectGroup *Group) { return Group->empty(); });
1432 if (SectionIndex > MaxSectionIndex)
1434 Section->Index = SectionIndex++;
1437 bool SectionAddressSet =
false;
1441 HasTDataSection =
true;
1448 for (
auto *Group :
Section->Groups) {
1452 for (
auto &Csect : *Group) {
1453 const MCSectionXCOFF *MCSec = Csect.MCSec;
1455 Csect.Size =
Asm.getSectionAddressSize(*MCSec);
1456 Address = Csect.Address + Csect.Size;
1457 Csect.SymbolTableIndex = SymbolTableIndex;
1460 SymbolTableIndex += 2;
1462 for (
auto &Sym : Csect.Syms) {
1463 bool hasExceptEntry =
false;
1465 ExceptionSection.ExceptionTable.find(Sym.MCSym->
getName());
1466 if (Entry != ExceptionSection.ExceptionTable.end()) {
1467 hasExceptEntry =
true;
1468 for (
auto &TrapEntry :
Entry->second.Entries) {
1469 TrapEntry.TrapAddress =
Asm.getSymbolOffset(*(Sym.MCSym)) +
1470 TrapEntry.Trap->getOffset();
1473 Sym.SymbolTableIndex = SymbolTableIndex;
1474 SymbolIndexMap[Sym.MCSym] = Sym.SymbolTableIndex;
1479 SymbolTableIndex += 2;
1480 if (hasExceptionSection() && hasExceptEntry) {
1481 if (
is64Bit() && ExceptionSection.isDebugEnabled)
1482 SymbolTableIndex += 2;
1484 SymbolTableIndex += 1;
1489 if (!SectionAddressSet) {
1490 Section->Address = Group->front().Address;
1491 SectionAddressSet =
true;
1506 if (!DwarfSections.empty())
1507 PaddingsBeforeDwarf =
1509 (*DwarfSections.begin()).DwarfSect->MCSec->getAlign()) -
1512 DwarfSectionEntry *LastDwarfSection =
nullptr;
1513 for (
auto &DwarfSection : DwarfSections) {
1514 assert((SectionIndex <= MaxSectionIndex) &&
"Section index overflow!");
1516 XCOFFSection &DwarfSect = *DwarfSection.DwarfSect;
1517 const MCSectionXCOFF *MCSec = DwarfSect.MCSec;
1520 DwarfSection.Index = SectionIndex++;
1524 DwarfSect.SymbolTableIndex = SymbolTableIndex;
1527 SymbolTableIndex += 2;
1533 DwarfSection.Address = DwarfSect.Address =
1538 DwarfSection.Size = DwarfSect.Size =
Asm.getSectionAddressSize(*MCSec);
1540 Address = DwarfSection.Address + DwarfSection.Size;
1542 if (LastDwarfSection)
1543 LastDwarfSection->MemorySize =
1544 DwarfSection.Address - LastDwarfSection->Address;
1545 LastDwarfSection = &DwarfSection;
1547 if (LastDwarfSection) {
1550 Address =
alignTo(LastDwarfSection->Address + LastDwarfSection->Size,
1551 DefaultSectionAlign);
1552 LastDwarfSection->MemorySize =
Address - LastDwarfSection->Address;
1554 if (hasExceptionSection()) {
1555 ExceptionSection.Index = SectionIndex++;
1557 ExceptionSection.Address = 0;
1558 ExceptionSection.Size = getExceptionSectionSize();
1559 Address += ExceptionSection.Size;
1563 if (CInfoSymSection.Entry) {
1564 CInfoSymSection.Index = SectionIndex++;
1566 CInfoSymSection.Address = 0;
1567 Address += CInfoSymSection.Size;
1571 SymbolTableEntryCount = SymbolTableIndex;
1574void XCOFFWriter::writeSectionForControlSectionEntry(
1575 const MCAssembler &Asm,
const CsectSectionEntry &CsectEntry,
1576 uint64_t &CurrentAddressLocation) {
1578 if (CsectEntry.Index == SectionEntry::UninitializedIndex)
1585 assert(((CurrentAddressLocation <= CsectEntry.Address) ||
1588 "CurrentAddressLocation should be less than or equal to section "
1589 "address if the section is not TData or TBSS.");
1591 CurrentAddressLocation = CsectEntry.Address;
1596 if (CsectEntry.IsVirtual) {
1597 CurrentAddressLocation += CsectEntry.Size;
1601 for (
const auto &Group : CsectEntry.Groups) {
1602 for (
const auto &Csect : *Group) {
1603 if (uint32_t PaddingSize = Csect.Address - CurrentAddressLocation)
1604 W.OS.write_zeros(PaddingSize);
1606 Asm.writeSectionData(
W.OS, Csect.MCSec);
1607 CurrentAddressLocation = Csect.Address + Csect.Size;
1614 if (uint64_t PaddingSize =
1615 CsectEntry.Address + CsectEntry.Size - CurrentAddressLocation) {
1616 W.OS.write_zeros(PaddingSize);
1617 CurrentAddressLocation += PaddingSize;
1621void XCOFFWriter::writeSectionForDwarfSectionEntry(
1622 const MCAssembler &Asm,
const DwarfSectionEntry &DwarfEntry,
1623 uint64_t &CurrentAddressLocation) {
1627 assert(CurrentAddressLocation <= DwarfEntry.Address &&
1628 "CurrentAddressLocation should be less than or equal to section "
1631 if (uint64_t PaddingSize = DwarfEntry.Address - CurrentAddressLocation)
1632 W.OS.write_zeros(PaddingSize);
1634 if (DwarfEntry.Size)
1635 Asm.writeSectionData(
W.OS, DwarfEntry.DwarfSect->MCSec);
1637 CurrentAddressLocation = DwarfEntry.Address + DwarfEntry.Size;
1641 uint32_t
Mod = CurrentAddressLocation % DefaultSectionAlign;
1642 uint32_t TailPaddingSize =
Mod ? DefaultSectionAlign -
Mod : 0;
1643 if (TailPaddingSize)
1644 W.OS.write_zeros(TailPaddingSize);
1646 CurrentAddressLocation += TailPaddingSize;
1649void XCOFFWriter::writeSectionForExceptionSectionEntry(
1650 const MCAssembler &Asm, ExceptionSectionEntry &ExceptionEntry,
1651 uint64_t &CurrentAddressLocation) {
1652 for (
const auto &TableEntry : ExceptionEntry.ExceptionTable) {
1655 W.write<uint32_t>(SymbolIndexMap[TableEntry.second.FunctionSymbol]);
1658 W.OS.write_zeros(4);
1660 W.OS.write_zeros(2);
1661 for (
auto &TrapEntry : TableEntry.second.Entries) {
1662 writeWord(TrapEntry.TrapAddress);
1663 W.write<uint8_t>(TrapEntry.Lang);
1664 W.write<uint8_t>(TrapEntry.Reason);
1668 CurrentAddressLocation += getExceptionSectionSize();
1671void XCOFFWriter::writeSectionForCInfoSymSectionEntry(
1672 const MCAssembler &Asm, CInfoSymSectionEntry &CInfoSymEntry,
1673 uint64_t &CurrentAddressLocation) {
1674 if (!CInfoSymSection.Entry)
1677 constexpr int WordSize =
sizeof(uint32_t);
1678 std::unique_ptr<CInfoSymInfo> &CISI = CInfoSymEntry.Entry;
1679 const std::string &
Metadata = CISI->Metadata;
1689 while (Index + WordSize <=
Metadata.size()) {
1692 W.write<uint32_t>(NextWord);
1697 if (CISI->paddingSize()) {
1698 std::array<uint8_t, WordSize> LastWord = {0};
1699 ::memcpy(LastWord.data(),
Metadata.data() + Index,
Metadata.size() - Index);
1703 CurrentAddressLocation += CISI->size();
1709uint8_t getEncodedType(
const MCSectionXCOFF *Sec) {
1714 uint8_t EncodedAlign = Log2Align << 3;
1720std::unique_ptr<MCObjectWriter>
1723 return std::make_unique<XCOFFWriter>(std::move(MOTW), OS);
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void writeSymbolTable(raw_ostream &Out, object::Archive::Kind Kind, bool Deterministic, ArrayRef< MemberData > Members, StringRef StringTable, uint64_t MembersOffset, unsigned NumSyms, uint64_t PrevMemberOffset=0, uint64_t NextMemberOffset=0, bool Is64Bit=false)
static const Function * getParent(const Value *V)
static unsigned getCPUType(const MachOObjectFile &O)
PowerPC TLS Dynamic Call Fixup
if(auto Err=PB.parsePassPipeline(MPM, Passes)) return wrap(std MPM run * Mod
static bool is64Bit(const char *name)
iterator find(const_arg_type_t< KeyT > Val)
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
virtual void reset()
lifetime management
StringRef getSymbolTableName() const
std::optional< XCOFF::DwarfSectionSubtypeFlags > getDwarfSubtypeFlags() const
XCOFF::StorageClass getStorageClass() const
XCOFF::StorageMappingClass getMappingClass() const
MCSymbolXCOFF * getQualNameSymbol() const
XCOFF::SymbolType getCSectType() const
StringRef getName() const
XCOFF::VisibilityType getVisibilityType() const
StringRef getSymbolTableName() const
MCSectionXCOFF * getRepresentedCsect() const
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
StringRef getName() const
getName - Get the symbol name.
MCFragment * getFragment() const
SectionEntry - represents a section emitted into memory by the dynamic linker.
SectionEntry(StringRef name, uint8_t *address, size_t size, size_t allocationSize, uintptr_t objAddress)
constexpr bool empty() const
empty - Check if the string is empty.
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
LLVM_ABI bool ends_with_insensitive(StringRef Suffix) const
Check if this string ends with the given Suffix, ignoring case.
Utility for building string tables with deduplicated suffixes.
LLVM_ABI size_t getOffset(CachedHashStringRef S) const
Get the offest of a string in the string table.
LLVM_ABI size_t add(CachedHashStringRef S, uint8_t Priority=0)
Add a string to the builder.
LLVM_ABI void write(raw_ostream &OS) const
LLVM_ABI void finalize()
Analyze the strings and build the final table.
An abstract base class for streams implementations that also support a pwrite operation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
C::iterator addEntry(C &Container, StringRef InstallName)
constexpr size_t RelocationSerializationSize32
LLVM_ABI XCOFF::CFileCpuId getCpuID(StringRef CPU)
constexpr size_t ExceptionSectionEntrySize64
constexpr size_t RelocationSerializationSize64
constexpr size_t ExceptionSectionEntrySize32
constexpr size_t FileHeaderSize64
constexpr size_t SectionHeaderSize64
constexpr size_t AuxFileEntNameSize
@ AUX_SECT
Identifies a SECT auxiliary entry.
@ AUX_FILE
Identifies a file auxiliary entry.
@ AUX_EXCEPT
Identifies an exception auxiliary entry.
@ AUX_FCN
Identifies a function auxiliary entry.
@ AUX_CSECT
Identifies a csect auxiliary entry.
@ TB_Fortran
Fortran language.
@ TB_CPLUSPLUS
C++ language.
VisibilityType
Values for visibility as they would appear when encoded in the high 4 bits of the 16-bit unsigned n_t...
constexpr size_t NameSize
constexpr uint16_t RelocOverflow
constexpr size_t AuxFileHeaderSizeShort
@ XFT_FN
Specifies the source-file name.
@ XFT_CV
Specifies the compiler version number.
constexpr size_t FileHeaderSize32
StorageMappingClass
Storage Mapping Class definitions.
@ XMC_TE
Symbol mapped at the end of TOC.
@ XMC_TC0
TOC Anchor for TOC Addressability.
@ XMC_DS
Descriptor csect.
@ XMC_TL
Initialized thread-local variable.
@ XMC_RO
Read Only Constant.
@ XMC_TD
Scalar data item in the TOC.
@ XMC_UL
Uninitialized thread-local variable.
@ XMC_BS
BSS class (uninitialized static internal)
@ XMC_TC
General TOC item.
constexpr size_t SectionHeaderSize32
constexpr size_t FileNamePadSize
@ XTY_CM
Common csect definition. For uninitialized storage.
@ XTY_SD
Csect definition for initialized storage.
@ XTY_LD
Label definition.
@ XTY_ER
External reference.
support::ulittle32_t Word
uint32_t read32be(const void *P)
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
LLVM_ABI Error write(MCStreamer &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue)
constexpr uint32_t Hi_32(uint64_t Value)
Return the high 32 bits of a 64 bit value.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
constexpr uint32_t Lo_32(uint64_t Value)
Return the low 32 bits of a 64 bit value.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
unsigned Log2(Align A)
Returns the log2 of the alignment.
std::unique_ptr< MCObjectWriter > createXCOFFObjectWriter(std::unique_ptr< MCXCOFFObjectTargetWriter > MOTW, raw_pwrite_stream &OS)
Implement std::hash so that hash_code can be used in STL containers.