54#define DEBUG_TYPE "WinCOFFObjectWriter"
58constexpr int OffsetLabelIntervalBits = 20;
62enum AuxiliaryType { ATWeakExternal, ATFile, ATSectionDefinition };
80 COFFSymbol *
Other =
nullptr;
81 COFFSection *Section =
nullptr;
85 COFFSymbol(
StringRef Name) : Name(Name) {}
89 int64_t getIndex()
const {
return Index; }
90 void setIndex(
int Value) {
98struct COFFRelocation {
100 COFFSymbol *Symb =
nullptr;
102 COFFRelocation() =
default;
107using relocations = std::vector<COFFRelocation>;
116 COFFSymbol *Symbol =
nullptr;
117 relocations Relocations;
119 COFFSection(
StringRef Name) : Name(std::string(Name)) {}
124class WinCOFFObjectWriter;
127 WinCOFFObjectWriter &OWriter;
130 using symbols = std::vector<std::unique_ptr<COFFSymbol>>;
131 using sections = std::vector<std::unique_ptr<COFFSection>>;
145 section_map SectionMap;
146 symbol_map SymbolMap;
148 symbol_list WeakDefaults;
151 bool UseOffsetLabels =
false;
172 COFFSymbol *GetOrCreateCOFFSymbol(
const MCSymbol *Symbol);
177 COFFSymbol *getLinkedSymbol(
const MCSymbol &Symbol);
181 void SetSymbolName(COFFSymbol &S);
182 void SetSectionName(COFFSection &S);
184 bool IsPhysicalSection(COFFSection *S);
188 void WriteSymbol(
const COFFSymbol &S);
190 void writeSectionHeaders();
195 const COFFSection &Sec);
198 void setWeakDefaultNames();
199 void assignSectionNumbers();
204 friend class WinCOFFWriter;
206 std::unique_ptr<MCWinCOFFObjectTargetWriter> TargetObjectWriter;
207 std::unique_ptr<WinCOFFWriter> ObjWriter, DwoWriter;
210 WinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
212 : TargetObjectWriter(std::move(MOTW)),
213 ObjWriter(std::make_unique<WinCOFFWriter>(*
this,
OS,
214 WinCOFFWriter::AllSections)) {
216 WinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
218 : TargetObjectWriter(std::move(MOTW)),
219 ObjWriter(std::make_unique<WinCOFFWriter>(*
this,
OS,
220 WinCOFFWriter::NonDwoOnly)),
221 DwoWriter(std::make_unique<WinCOFFWriter>(*
this, DwoOS,
222 WinCOFFWriter::DwoOnly)) {}
225 void reset()
override;
231 bool IsPCRel)
const override;
258WinCOFFWriter::WinCOFFWriter(WinCOFFObjectWriter &OWriter,
261 Header.Machine = OWriter.TargetObjectWriter->getMachine();
270 Symbols.push_back(std::make_unique<COFFSymbol>(
Name));
271 return Symbols.back().get();
274COFFSymbol *WinCOFFWriter::GetOrCreateCOFFSymbol(
const MCSymbol *Symbol) {
282 Sections.emplace_back(std::make_unique<COFFSection>(
Name));
283 return Sections.back().get();
334 COFFSymbol *COMDATSymbol = GetOrCreateCOFFSymbol(S);
335 if (COMDATSymbol->Section)
337 COMDATSymbol->Section =
Section;
344 Symbol->Aux[0].AuxType = ATSectionDefinition;
355 if (UseOffsetLabels && !MCSec.
empty()) {
365 Section->OffsetSymbols.push_back(Label);
372 if (Symbol.isCommon() && Symbol.isExternal())
373 return Symbol.getCommonSize();
382COFFSymbol *WinCOFFWriter::getLinkedSymbol(
const MCSymbol &Symbol) {
387 dyn_cast<MCSymbolRefExpr>(
Symbol.getVariableValue());
393 return GetOrCreateCOFFSymbol(&Aliasee);
403 COFFSection *Sec =
nullptr;
406 MCSec = cast<MCSectionCOFF>(
Base->getFragment()->getParent());
407 Sec = SectionMap[MCSec];
410 if (Mode == NonDwoOnly && MCSec &&
isDwoSection(*MCSec))
413 COFFSymbol *
Sym = GetOrCreateCOFFSymbol(&MCSym);
414 COFFSymbol *
Local =
nullptr;
415 if (cast<MCSymbolCOFF>(MCSym).getWeakExternalCharacteristics()) {
417 Sym->Section =
nullptr;
419 COFFSymbol *WeakDefault = getLinkedSymbol(MCSym);
421 std::string WeakName = (
".weak." + MCSym.
getName() +
".default").str();
422 WeakDefault = createSymbol(WeakName);
426 WeakDefault->Section = Sec;
427 WeakDefaults.insert(WeakDefault);
431 Sym->Other = WeakDefault;
435 memset(&
Sym->Aux[0], 0,
sizeof(
Sym->Aux[0]));
436 Sym->Aux[0].AuxType = ATWeakExternal;
437 Sym->Aux[0].Aux.WeakExternal.TagIndex = 0;
438 Sym->Aux[0].Aux.WeakExternal.Characteristics =
439 cast<MCSymbolCOFF>(MCSym).getWeakExternalCharacteristics();
451 const MCSymbolCOFF &SymbolCOFF = cast<MCSymbolCOFF>(MCSym);
468void WinCOFFWriter::SetSectionName(COFFSection &S) {
470 std::memcpy(S.Header.Name, S.Name.c_str(), S.Name.size());
474 uint64_t StringTableEntry = Strings.getOffset(S.Name);
479void WinCOFFWriter::SetSymbolName(COFFSymbol &S) {
481 S.set_name_offset(Strings.getOffset(S.Name));
483 std::memcpy(S.Data.Name, S.Name.c_str(), S.Name.size());
486bool WinCOFFWriter::IsPhysicalSection(COFFSection *S) {
494void WinCOFFWriter::WriteFileHeader(
const COFF::header &Header) {
506 W.write<
uint32_t>(Header.NumberOfSections);
507 W.write<
uint32_t>(Header.PointerToSymbolTable);
508 W.write<
uint32_t>(Header.NumberOfSymbols);
511 W.write<
uint16_t>(
static_cast<int16_t
>(Header.NumberOfSections));
513 W.write<
uint32_t>(Header.PointerToSymbolTable);
514 W.write<
uint32_t>(Header.NumberOfSymbols);
515 W.write<
uint16_t>(Header.SizeOfOptionalHeader);
516 W.write<
uint16_t>(Header.Characteristics);
520void WinCOFFWriter::WriteSymbol(
const COFFSymbol &S) {
526 W.write<
uint16_t>(
static_cast<int16_t
>(S.Data.SectionNumber));
528 W.OS <<
char(S.Data.StorageClass);
529 W.OS <<
char(S.Data.NumberOfAuxSymbols);
530 WriteAuxiliarySymbols(S.Aux);
533void WinCOFFWriter::WriteAuxiliarySymbols(
535 for (
const AuxSymbol &i : S) {
538 W.write<
uint32_t>(i.Aux.WeakExternal.TagIndex);
539 W.write<
uint32_t>(i.Aux.WeakExternal.Characteristics);
540 W.OS.write_zeros(
sizeof(i.Aux.WeakExternal.unused));
545 W.OS.write(
reinterpret_cast<const char *
>(&i.Aux),
548 case ATSectionDefinition:
549 W.write<
uint32_t>(i.Aux.SectionDefinition.Length);
550 W.write<
uint16_t>(i.Aux.SectionDefinition.NumberOfRelocations);
551 W.write<
uint16_t>(i.Aux.SectionDefinition.NumberOfLinenumbers);
552 W.write<
uint32_t>(i.Aux.SectionDefinition.CheckSum);
553 W.write<
uint16_t>(
static_cast<int16_t
>(i.Aux.SectionDefinition.Number));
554 W.OS <<
char(i.Aux.SectionDefinition.Selection);
555 W.OS.write_zeros(
sizeof(i.Aux.SectionDefinition.unused));
557 static_cast<int16_t
>(i.Aux.SectionDefinition.Number >> 16));
566void WinCOFFWriter::writeSectionHeaders() {
570 std::vector<COFFSection *> Arr;
571 for (
auto &Section : Sections)
573 llvm::sort(Arr, [](
const COFFSection *
A,
const COFFSection *
B) {
574 return A->Number <
B->Number;
577 for (
auto &Section : Arr) {
582 if (
Section->Relocations.size() >= 0xffff)
613 Asm.writeSectionData(VecOS, &MCSec, Layout);
626 const COFFSection &Sec) {
627 if (Sec.Number == -1)
631 if (Sec.Header.PointerToRawData != 0) {
632 assert(
W.OS.tell() == Sec.Header.PointerToRawData &&
633 "Section::PointerToRawData is insane!");
635 uint32_t CRC = writeSectionContents(Asm, Layout, *Sec.MCSection);
639 assert(AuxSyms.
size() == 1 && AuxSyms[0].AuxType == ATSectionDefinition);
640 AuxSymbol &SecDef = AuxSyms[0];
641 SecDef.Aux.SectionDefinition.CheckSum = CRC;
645 if (Sec.Relocations.empty()) {
646 assert(Sec.Header.PointerToRelocations == 0 &&
647 "Section::PointerToRelocations is insane!");
651 assert(
W.OS.tell() == Sec.Header.PointerToRelocations &&
652 "Section::PointerToRelocations is insane!");
654 if (Sec.Relocations.size() >= 0xffff) {
658 R.VirtualAddress = Sec.Relocations.size() + 1;
659 R.SymbolTableIndex = 0;
664 for (
const auto &Relocation : Sec.Relocations)
665 WriteRelocation(Relocation.Data);
669void WinCOFFWriter::createFileSymbols(
MCAssembler &Asm) {
670 for (
const std::pair<std::string, size_t> &It :
Asm.getFileNames()) {
672 const std::string &
Name = It.first;
674 unsigned Count = (
Name.size() + SymbolSize - 1) / SymbolSize;
676 COFFSymbol *
File = createSymbol(
".file");
679 File->Aux.resize(Count);
683 for (
auto &Aux :
File->Aux) {
684 Aux.AuxType = ATFile;
686 if (
Length > SymbolSize) {
687 memcpy(&Aux.Aux,
Name.c_str() +
Offset, SymbolSize);
691 memset((
char *)&Aux.Aux +
Length, 0, SymbolSize -
Length);
700void WinCOFFWriter::setWeakDefaultNames() {
701 if (WeakDefaults.empty())
711 COFFSymbol *Unique =
nullptr;
712 for (
bool AllowComdat : {
false,
true}) {
713 for (
auto &
Sym : Symbols) {
715 if (WeakDefaults.count(
Sym.get()))
723 if (!AllowComdat &&
Sym->Section &&
735 for (
auto *
Sym : WeakDefaults) {
736 Sym->Name.append(
".");
737 Sym->Name.append(Unique->Name);
742 return Section.Symbol->Aux[0].Aux.SectionDefinition.Selection ==
746void WinCOFFWriter::assignSectionNumbers() {
750 Section.Symbol->Data.SectionNumber =
I;
751 Section.Symbol->Aux[0].Aux.SectionDefinition.Number =
I;
758 for (
const std::unique_ptr<COFFSection> &Section : Sections)
761 for (
const std::unique_ptr<COFFSection> &Section : Sections)
767void WinCOFFWriter::assignFileOffsets(
MCAssembler &Asm,
774 for (
const auto &Section : Asm) {
775 COFFSection *Sec = SectionMap[&
Section];
777 if (!Sec || Sec->Number == -1)
782 if (IsPhysicalSection(Sec)) {
783 Sec->Header.PointerToRawData =
Offset;
784 Offset += Sec->Header.SizeOfRawData;
787 if (!Sec->Relocations.empty()) {
788 bool RelocationsOverflow = Sec->Relocations.size() >= 0xffff;
790 if (RelocationsOverflow) {
793 Sec->Header.NumberOfRelocations = 0xffff;
795 Sec->Header.NumberOfRelocations = Sec->Relocations.size();
797 Sec->Header.PointerToRelocations =
Offset;
799 if (RelocationsOverflow) {
806 for (
auto &Relocation : Sec->Relocations) {
807 assert(Relocation.Symb->getIndex() != -1);
808 Relocation.Data.SymbolTableIndex = Relocation.Symb->getIndex();
812 assert(Sec->Symbol->Aux.size() == 1 &&
813 "Section's symbol must have one aux!");
814 AuxSymbol &Aux = Sec->Symbol->Aux[0];
815 assert(Aux.AuxType == ATSectionDefinition &&
816 "Section's symbol's aux symbol must be a Section Definition!");
817 Aux.Aux.SectionDefinition.Length = Sec->Header.SizeOfRawData;
818 Aux.Aux.SectionDefinition.NumberOfRelocations =
819 Sec->Header.NumberOfRelocations;
820 Aux.Aux.SectionDefinition.NumberOfLinenumbers =
821 Sec->Header.NumberOfLineNumbers;
824 Header.PointerToSymbolTable =
Offset;
827void WinCOFFWriter::reset() {
828 memset(&Header, 0,
sizeof(Header));
829 Header.Machine = OWriter.TargetObjectWriter->getMachine();
835 WeakDefaults.clear();
838void WinCOFFWriter::executePostLayoutBinding(
MCAssembler &Asm,
842 for (
const auto &Section : Asm) {
846 defineSection(
static_cast<const MCSectionCOFF &
>(Section), Layout);
852 if (!
Symbol.isTemporary() ||
854 DefineSymbol(Symbol, Asm, Layout);
857void WinCOFFWriter::recordRelocation(
MCAssembler &Asm,
862 assert(
Target.getSymA() &&
"Relocation must reference a symbol!");
865 if (!
A.isRegistered()) {
866 Asm.getContext().reportError(
Fixup.getLoc(),
Twine(
"symbol '") +
868 "' can not be undefined");
871 if (
A.isTemporary() &&
A.isUndefined()) {
872 Asm.getContext().reportError(
Fixup.getLoc(),
Twine(
"assembler label '") +
874 "' can not be undefined");
881 assert(SectionMap.contains(MCSec) &&
882 "Section must already have been defined in executePostLayoutBinding!");
884 COFFSection *Sec = SectionMap[MCSec];
889 if (!
B->getFragment()) {
890 Asm.getContext().reportError(
892 Twine(
"symbol '") +
B->getName() +
893 "' can not be undefined in a subtraction expression");
901 int64_t OffsetOfRelocation =
904 FixedValue = (OffsetOfRelocation - OffsetOfB) +
Target.getConstant();
906 FixedValue =
Target.getConstant();
909 COFFRelocation Reloc;
911 Reloc.Data.SymbolTableIndex = 0;
918 SectionMap.contains(TargetSection) &&
919 "Section must already have been defined in executePostLayoutBinding!");
920 COFFSection *
Section = SectionMap[TargetSection];
927 if (UseOffsetLabels && !
Section->OffsetSymbols.empty()) {
928 uint64_t LabelIndex = FixedValue >> OffsetLabelIntervalBits;
929 if (LabelIndex > 0) {
930 if (LabelIndex <= Section->OffsetSymbols.size())
931 Reloc.Symb =
Section->OffsetSymbols[LabelIndex - 1];
933 Reloc.Symb =
Section->OffsetSymbols.back();
934 FixedValue -= Reloc.Symb->Data.Value;
940 "Symbol must already have been defined in executePostLayoutBinding!");
944 ++Reloc.Symb->Relocations;
946 Reloc.Data.VirtualAddress +=
Fixup.getOffset();
947 Reloc.Data.Type = OWriter.TargetObjectWriter->getRelocType(
963 switch (Reloc.Data.Type) {
995 FixedValue = FixedValue + 4;
1004 if (OWriter.TargetObjectWriter->recordRelocation(
Fixup))
1005 Sec->Relocations.push_back(Reloc);
1009 std::time_t Now = time(
nullptr);
1010 if (Now < 0 || !isUInt<32>(Now))
1019 if (Sections.size() > INT32_MAX)
1021 "PE COFF object files can't have more than 2147483647 sections");
1024 Header.NumberOfSections = Sections.size();
1025 Header.NumberOfSymbols = 0;
1027 setWeakDefaultNames();
1028 assignSectionNumbers();
1029 if (Mode != DwoOnly)
1030 createFileSymbols(Asm);
1032 for (
auto &Symbol : Symbols) {
1036 Symbol->setIndex(Header.NumberOfSymbols++);
1039 Header.NumberOfSymbols +=
Symbol->Data.NumberOfAuxSymbols;
1043 for (
const auto &S : Sections)
1045 Strings.add(S->
Name);
1046 for (
const auto &S : Symbols)
1048 Strings.add(S->
Name);
1052 for (
const auto &S : Sections)
1054 for (
auto &S : Symbols)
1058 for (
auto &Symbol : Symbols) {
1061 assert(
Symbol->Aux.size() == 1 &&
"Symbol must contain one aux symbol!");
1063 "Symbol's aux symbol must be a Weak External!");
1064 Symbol->Aux[0].Aux.WeakExternal.TagIndex =
Symbol->Other->getIndex();
1069 for (
auto &Section : Sections) {
1070 if (
Section->Symbol->Aux[0].Aux.SectionDefinition.Selection !=
1081 Asm.getContext().reportError(
1083 Twine(
" associative with sectionless symbol ") +
1088 const auto *AssocMCSec = cast<MCSectionCOFF>(&AssocMCSym->
getSection());
1089 assert(SectionMap.count(AssocMCSec));
1090 COFFSection *AssocSec = SectionMap[AssocMCSec];
1093 if (AssocSec->Number == -1)
1096 Section->Symbol->Aux[0].Aux.SectionDefinition.Number = AssocSec->Number;
1100 if (Mode != DwoOnly && OWriter.getEmitAddrsigSection()) {
1101 auto *Sec =
Asm.getContext().getCOFFSection(
1103 auto *Frag = cast<MCDataFragment>(Sec->curFragList()->Head);
1105 for (
const MCSymbol *S : OWriter.AddrsigSyms) {
1114 assert(SectionMap.contains(TargetSection) &&
1115 "Section must already have been defined in "
1116 "executePostLayoutBinding!");
1122 if (Mode != DwoOnly && !
Asm.CGProfile.empty()) {
1123 auto *Sec =
Asm.getContext().getCOFFSection(
1125 auto *Frag = cast<MCDataFragment>(Sec->curFragList()->Head);
1136 assignFileOffsets(Asm, Layout);
1140 if (
Asm.isIncrementalLinkerCompatible()) {
1141 Header.TimeDateStamp =
getTime();
1144 Header.TimeDateStamp = 0;
1148 WriteFileHeader(Header);
1149 writeSectionHeaders();
1152 sections::iterator
I = Sections.begin();
1153 sections::iterator
IE = Sections.end();
1156 for (;
I !=
IE && J != JE; ++
I, ++J) {
1157 while (J != JE && ((Mode == NonDwoOnly &&
isDwoSection(*J)) ||
1160 assert(J != JE && (**I).MCSection == &*J &&
"Wrong bound MCSection");
1165 for (std::unique_ptr<COFFSection> &Sec : Sections)
1166 writeSection(Asm, Layout, *Sec);
1168 assert(
W.OS.tell() == Header.PointerToSymbolTable &&
1169 "Header::PointerToSymbolTable is insane!");
1172 for (
auto &Symbol : Symbols)
1173 if (
Symbol->getIndex() != -1)
1174 WriteSymbol(*Symbol);
1177 Strings.write(
W.OS);
1179 return W.OS.tell() - StartOffset;
1188void WinCOFFObjectWriter::reset() {
1195bool WinCOFFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
1197 bool InSet,
bool IsPCRel)
const {
1211void WinCOFFObjectWriter::executePostLayoutBinding(
MCAssembler &Asm,
1213 ObjWriter->executePostLayoutBinding(Asm, Layout);
1215 DwoWriter->executePostLayoutBinding(Asm, Layout);
1218void WinCOFFObjectWriter::recordRelocation(
MCAssembler &Asm,
1224 "No relocation in Dwo sections");
1225 ObjWriter->recordRelocation(Asm, Layout, Fragment,
Fixup,
Target, FixedValue);
1230 uint64_t TotalSize = ObjWriter->writeObject(Asm, Layout);
1232 TotalSize += DwoWriter->writeObject(Asm, Layout);
1240void MCWinCOFFObjectTargetWriter::anchor() {}
1247 return std::make_unique<WinCOFFObjectWriter>(std::move(MOTW),
OS);
1253 return std::make_unique<WinCOFFObjectWriter>(std::move(MOTW),
OS, DwoOS);
bbsections Prepares for basic block sections
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
COFFYAML::AuxSymbolType AuxType
COFF::MachineTypes Machine
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
std::optional< std::vector< StOtherPiece > > Other
std::pair< uint64_t, uint64_t > Interval
PowerPC TLS Dynamic Call Fixup
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the SmallVector class.
static uint32_t getAlignment(const MCSectionCOFF &Sec)
static bool isAssociative(const COFFSection &Section)
static uint64_t getSymbolValue(const MCSymbol &Symbol, const MCAsmLayout &Layout)
static bool isDwoSection(const MCSection &Sec)
static std::time_t getTime()
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Implements a dense probed hash-table based set.
Encapsulates the layout of an assembly file at a particular point in time.
const MCSymbol * getBaseSymbol(const MCSymbol &Symbol) const
If this symbol is equivalent to A + Constant, return A.
uint64_t getSectionAddressSize(const MCSection *Sec) const
Get the address space size of the given section, as it effects layout.
bool getSymbolOffset(const MCSymbol &S, uint64_t &Val) const
Get the offset of the given symbol, as computed in the current layout.
uint64_t getFragmentOffset(const MCFragment *F) const
Get the offset of the given fragment inside its containing section.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
MCSection * getParent() const
Defines the object file and target independent interfaces used by the assembler backend to write nati...
virtual uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout)=0
Write the object file and returns the number of bytes written.
virtual void executePostLayoutBinding(MCAssembler &Asm, const MCAsmLayout &Layout)=0
Perform any late binding of symbols (for example, to assign symbol indices for use when generating re...
virtual void reset()
lifetime management
virtual bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbol &A, const MCSymbol &B, bool InSet) const
virtual void recordRelocation(MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue)=0
Record a relocation entry.
This represents a section on Windows.
MCSymbol * getCOMDATSymbol() const
unsigned getCharacteristics() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
StringRef getName() const
MCSymbol * getBeginSymbol()
uint16_t getClass() const
Represent a reference to a symbol from inside an expression.
const MCSymbol & getSymbol() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute).
StringRef getName() const
getName - Get the symbol name.
bool isVariable() const
isVariable - Check if this is a variable symbol.
bool isRegistered() const
void setIndex(uint32_t Value) const
Set the (implementation defined) index.
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
uint32_t getIndex() const
Get the (implementation defined) index.
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
MCFragment * getFragment(bool SetUsed=true) const
This represents an "assembler immediate".
MCWinCOFFObjectTargetWriter(unsigned Machine_)
Represents a location in source code.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
Utility for building string tables with deduplicated suffixes.
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
An abstract base class for streams implementations that also support a pwrite operation.
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_FILE_MACHINE_UNKNOWN
@ IMAGE_FILE_MACHINE_AMD64
@ IMAGE_FILE_MACHINE_I386
@ IMAGE_FILE_MACHINE_ARMNT
@ IMAGE_SCN_ALIGN_64BYTES
@ IMAGE_SCN_ALIGN_128BYTES
@ IMAGE_SCN_ALIGN_256BYTES
@ IMAGE_SCN_ALIGN_1024BYTES
@ IMAGE_SCN_ALIGN_512BYTES
@ IMAGE_SCN_CNT_UNINITIALIZED_DATA
@ IMAGE_SCN_ALIGN_4096BYTES
@ IMAGE_SCN_ALIGN_8192BYTES
@ IMAGE_SCN_LNK_NRELOC_OVFL
@ IMAGE_SCN_ALIGN_16BYTES
@ IMAGE_SCN_ALIGN_32BYTES
@ IMAGE_SCN_ALIGN_2048BYTES
bool isAnyArm64(T Machine)
@ IMAGE_SYM_CLASS_EXTERNAL
External symbol.
@ IMAGE_SYM_CLASS_LABEL
Label.
@ IMAGE_SYM_CLASS_FILE
File name.
@ IMAGE_SYM_CLASS_NULL
No symbol.
@ IMAGE_SYM_CLASS_WEAK_EXTERNAL
Duplicate tag.
@ IMAGE_SYM_CLASS_STATIC
Static.
bool encodeSectionName(char *Out, uint64_t Offset)
Encode section name based on string table offset.
@ IMAGE_COMDAT_SELECT_ASSOCIATIVE
@ IMAGE_REL_ARM_BRANCH20T
@ IMAGE_REL_ARM_BRANCH24T
const int32_t MaxNumberOfSections16
static const char BigObjMagic[]
@ IMAGE_SYM_DTYPE_FUNCTION
A function that returns a base type.
@ SCT_COMPLEX_TYPE_SHIFT
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
void write32le(void *P, uint32_t V)
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
This is an optimization pass for GlobalISel generic memory operations.
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.
void sort(IteratorTy Start, IteratorTy End)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
std::unique_ptr< MCObjectWriter > createWinCOFFDwoObjectWriter(std::unique_ptr< MCWinCOFFObjectTargetWriter > MOTW, raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS)
@ FK_SecRel_2
A two-byte section relative fixup.
std::unique_ptr< MCObjectWriter > createWinCOFFObjectWriter(std::unique_ptr< MCWinCOFFObjectTargetWriter > MOTW, raw_pwrite_stream &OS)
Construct a new Win COFF writer instance.
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
uint64_t value() const
This is a hole in the type system and should not be abused.
uint32_t PointerToRelocations
uint16_t NumberOfLineNumbers
uint32_t PointerToRawData
uint16_t NumberOfRelocations
uint32_t PointerToLineNumbers
const MCSymbolRefExpr * From
const MCSymbolRefExpr * To
An iterator type that allows iterating over the pointees via some other iterator.
Adapter to write values to a stream in a particular byte order.