53#define DEBUG_TYPE "WinCOFFObjectWriter"
57constexpr int OffsetLabelIntervalBits = 20;
61enum AuxiliaryType { ATWeakExternal, ATFile, ATSectionDefinition };
79 COFFSymbol *
Other =
nullptr;
80 COFFSection *Section =
nullptr;
84 COFFSymbol(
StringRef Name) : Name(Name) {}
88 int64_t getIndex()
const {
return Index; }
89 void setIndex(
int Value) {
97struct COFFRelocation {
99 COFFSymbol *Symb =
nullptr;
101 COFFRelocation() =
default;
106using relocations = std::vector<COFFRelocation>;
115 COFFSymbol *Symbol =
nullptr;
116 relocations Relocations;
118 COFFSection(
StringRef Name) : Name(std::string(Name)) {}
123class WinCOFFObjectWriter;
126 WinCOFFObjectWriter &OWriter;
129 using symbols = std::vector<std::unique_ptr<COFFSymbol>>;
130 using sections = std::vector<std::unique_ptr<COFFSection>>;
144 section_map SectionMap;
145 symbol_map SymbolMap;
147 symbol_list WeakDefaults;
150 bool UseOffsetLabels =
false;
171 COFFSymbol *GetOrCreateCOFFSymbol(
const MCSymbol *Symbol);
176 COFFSymbol *getLinkedSymbol(
const MCSymbol &Symbol);
179 void SetSymbolName(COFFSymbol &S);
180 void SetSectionName(COFFSection &S);
182 bool IsPhysicalSection(COFFSection *S);
186 void WriteSymbol(
const COFFSymbol &S);
188 void writeSectionHeaders();
191 void writeSection(
MCAssembler &Asm,
const COFFSection &Sec);
194 void setWeakDefaultNames();
195 void assignSectionNumbers();
200 friend class WinCOFFWriter;
202 std::unique_ptr<MCWinCOFFObjectTargetWriter> TargetObjectWriter;
203 std::unique_ptr<WinCOFFWriter> ObjWriter, DwoWriter;
206 WinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
208 : TargetObjectWriter(std::move(MOTW)),
209 ObjWriter(std::make_unique<WinCOFFWriter>(*
this,
OS,
210 WinCOFFWriter::AllSections)) {
212 WinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
214 : TargetObjectWriter(std::move(MOTW)),
215 ObjWriter(std::make_unique<WinCOFFWriter>(*
this,
OS,
216 WinCOFFWriter::NonDwoOnly)),
217 DwoWriter(std::make_unique<WinCOFFWriter>(*
this, DwoOS,
218 WinCOFFWriter::DwoOnly)) {}
221 void reset()
override;
226 bool IsPCRel)
const override;
253WinCOFFWriter::WinCOFFWriter(WinCOFFObjectWriter &OWriter,
256 Header.Machine = OWriter.TargetObjectWriter->getMachine();
265 Symbols.push_back(std::make_unique<COFFSymbol>(
Name));
266 return Symbols.back().get();
269COFFSymbol *WinCOFFWriter::GetOrCreateCOFFSymbol(
const MCSymbol *Symbol) {
277 Sections.emplace_back(std::make_unique<COFFSection>(
Name));
278 return Sections.back().get();
317void WinCOFFWriter::defineSection(
const MCAssembler &Asm,
329 COFFSymbol *COMDATSymbol = GetOrCreateCOFFSymbol(S);
330 if (COMDATSymbol->Section)
332 COMDATSymbol->Section =
Section;
339 Symbol->Aux[0].AuxType = ATSectionDefinition;
350 if (UseOffsetLabels && !MCSec.
empty()) {
360 Section->OffsetSymbols.push_back(Label);
366 if (Symbol.isCommon() && Symbol.isExternal())
367 return Symbol.getCommonSize();
370 if (!Asm.getSymbolOffset(Symbol, Res))
376COFFSymbol *WinCOFFWriter::getLinkedSymbol(
const MCSymbol &Symbol) {
381 dyn_cast<MCSymbolRefExpr>(
Symbol.getVariableValue());
387 return GetOrCreateCOFFSymbol(&Aliasee);
394void WinCOFFWriter::defineSymbol(
const MCAssembler &Asm,
397 COFFSection *Sec =
nullptr;
400 MCSec = cast<MCSectionCOFF>(
Base->getFragment()->getParent());
401 Sec = SectionMap[MCSec];
404 if (Mode == NonDwoOnly && MCSec &&
isDwoSection(*MCSec))
407 COFFSymbol *
Sym = GetOrCreateCOFFSymbol(&MCSym);
408 COFFSymbol *
Local =
nullptr;
409 if (cast<MCSymbolCOFF>(MCSym).getWeakExternalCharacteristics()) {
411 Sym->Section =
nullptr;
413 COFFSymbol *WeakDefault = getLinkedSymbol(MCSym);
415 std::string WeakName = (
".weak." + MCSym.
getName() +
".default").str();
416 WeakDefault = createSymbol(WeakName);
420 WeakDefault->Section = Sec;
421 WeakDefaults.insert(WeakDefault);
425 Sym->Other = WeakDefault;
429 memset(&
Sym->Aux[0], 0,
sizeof(
Sym->Aux[0]));
430 Sym->Aux[0].AuxType = ATWeakExternal;
431 Sym->Aux[0].Aux.WeakExternal.TagIndex = 0;
432 Sym->Aux[0].Aux.WeakExternal.Characteristics =
433 cast<MCSymbolCOFF>(MCSym).getWeakExternalCharacteristics();
445 const MCSymbolCOFF &SymbolCOFF = cast<MCSymbolCOFF>(MCSym);
462void WinCOFFWriter::SetSectionName(COFFSection &S) {
464 std::memcpy(S.Header.Name, S.Name.c_str(), S.Name.size());
468 uint64_t StringTableEntry = Strings.getOffset(S.Name);
473void WinCOFFWriter::SetSymbolName(COFFSymbol &S) {
475 S.set_name_offset(Strings.getOffset(S.Name));
477 std::memcpy(S.Data.Name, S.Name.c_str(), S.Name.size());
480bool WinCOFFWriter::IsPhysicalSection(COFFSection *S) {
488void WinCOFFWriter::WriteFileHeader(
const COFF::header &Header) {
500 W.write<
uint32_t>(Header.NumberOfSections);
501 W.write<
uint32_t>(Header.PointerToSymbolTable);
502 W.write<
uint32_t>(Header.NumberOfSymbols);
505 W.write<
uint16_t>(
static_cast<int16_t
>(Header.NumberOfSections));
507 W.write<
uint32_t>(Header.PointerToSymbolTable);
508 W.write<
uint32_t>(Header.NumberOfSymbols);
509 W.write<
uint16_t>(Header.SizeOfOptionalHeader);
510 W.write<
uint16_t>(Header.Characteristics);
514void WinCOFFWriter::WriteSymbol(
const COFFSymbol &S) {
520 W.write<
uint16_t>(
static_cast<int16_t
>(S.Data.SectionNumber));
522 W.OS <<
char(S.Data.StorageClass);
523 W.OS <<
char(S.Data.NumberOfAuxSymbols);
524 WriteAuxiliarySymbols(S.Aux);
527void WinCOFFWriter::WriteAuxiliarySymbols(
529 for (
const AuxSymbol &i : S) {
532 W.write<
uint32_t>(i.Aux.WeakExternal.TagIndex);
533 W.write<
uint32_t>(i.Aux.WeakExternal.Characteristics);
534 W.OS.write_zeros(
sizeof(i.Aux.WeakExternal.unused));
539 W.OS.write(
reinterpret_cast<const char *
>(&i.Aux),
542 case ATSectionDefinition:
543 W.write<
uint32_t>(i.Aux.SectionDefinition.Length);
544 W.write<
uint16_t>(i.Aux.SectionDefinition.NumberOfRelocations);
545 W.write<
uint16_t>(i.Aux.SectionDefinition.NumberOfLinenumbers);
546 W.write<
uint32_t>(i.Aux.SectionDefinition.CheckSum);
547 W.write<
uint16_t>(
static_cast<int16_t
>(i.Aux.SectionDefinition.Number));
548 W.OS <<
char(i.Aux.SectionDefinition.Selection);
549 W.OS.write_zeros(
sizeof(i.Aux.SectionDefinition.unused));
551 static_cast<int16_t
>(i.Aux.SectionDefinition.Number >> 16));
560void WinCOFFWriter::writeSectionHeaders() {
564 std::vector<COFFSection *> Arr;
565 for (
auto &Section : Sections)
567 llvm::sort(Arr, [](
const COFFSection *
A,
const COFFSection *
B) {
568 return A->Number <
B->Number;
571 for (
auto &Section : Arr) {
576 if (
Section->Relocations.size() >= 0xffff)
606 Asm.writeSectionData(VecOS, &MCSec);
618void WinCOFFWriter::writeSection(
MCAssembler &Asm,
const COFFSection &Sec) {
619 if (Sec.Number == -1)
623 if (Sec.Header.PointerToRawData != 0) {
624 assert(
W.OS.tell() == Sec.Header.PointerToRawData &&
625 "Section::PointerToRawData is insane!");
627 uint32_t CRC = writeSectionContents(Asm, *Sec.MCSection);
631 assert(AuxSyms.
size() == 1 && AuxSyms[0].AuxType == ATSectionDefinition);
632 AuxSymbol &SecDef = AuxSyms[0];
633 SecDef.Aux.SectionDefinition.CheckSum = CRC;
637 if (Sec.Relocations.empty()) {
638 assert(Sec.Header.PointerToRelocations == 0 &&
639 "Section::PointerToRelocations is insane!");
643 assert(
W.OS.tell() == Sec.Header.PointerToRelocations &&
644 "Section::PointerToRelocations is insane!");
646 if (Sec.Relocations.size() >= 0xffff) {
650 R.VirtualAddress = Sec.Relocations.size() + 1;
651 R.SymbolTableIndex = 0;
656 for (
const auto &Relocation : Sec.Relocations)
657 WriteRelocation(Relocation.Data);
661void WinCOFFWriter::createFileSymbols(
MCAssembler &Asm) {
662 for (
const std::pair<std::string, size_t> &It :
Asm.getFileNames()) {
664 const std::string &
Name = It.first;
666 unsigned Count = (
Name.size() + SymbolSize - 1) / SymbolSize;
668 COFFSymbol *
File = createSymbol(
".file");
671 File->Aux.resize(Count);
675 for (
auto &Aux :
File->Aux) {
676 Aux.AuxType = ATFile;
678 if (
Length > SymbolSize) {
679 memcpy(&Aux.Aux,
Name.c_str() +
Offset, SymbolSize);
683 memset((
char *)&Aux.Aux +
Length, 0, SymbolSize -
Length);
692void WinCOFFWriter::setWeakDefaultNames() {
693 if (WeakDefaults.empty())
703 COFFSymbol *Unique =
nullptr;
704 for (
bool AllowComdat : {
false,
true}) {
705 for (
auto &
Sym : Symbols) {
707 if (WeakDefaults.count(
Sym.get()))
715 if (!AllowComdat &&
Sym->Section &&
727 for (
auto *
Sym : WeakDefaults) {
728 Sym->Name.append(
".");
729 Sym->Name.append(Unique->Name);
734 return Section.Symbol->Aux[0].Aux.SectionDefinition.Selection ==
738void WinCOFFWriter::assignSectionNumbers() {
742 Section.Symbol->Data.SectionNumber =
I;
743 Section.Symbol->Aux[0].Aux.SectionDefinition.Number =
I;
750 for (
const std::unique_ptr<COFFSection> &Section : Sections)
753 for (
const std::unique_ptr<COFFSection> &Section : Sections)
759void WinCOFFWriter::assignFileOffsets(
MCAssembler &Asm) {
765 for (
const auto &Section : Asm) {
766 COFFSection *Sec = SectionMap[&
Section];
768 if (!Sec || Sec->Number == -1)
771 Sec->Header.SizeOfRawData =
Asm.getSectionAddressSize(Section);
773 if (IsPhysicalSection(Sec)) {
774 Sec->Header.PointerToRawData =
Offset;
775 Offset += Sec->Header.SizeOfRawData;
778 if (!Sec->Relocations.empty()) {
779 bool RelocationsOverflow = Sec->Relocations.size() >= 0xffff;
781 if (RelocationsOverflow) {
784 Sec->Header.NumberOfRelocations = 0xffff;
786 Sec->Header.NumberOfRelocations = Sec->Relocations.size();
788 Sec->Header.PointerToRelocations =
Offset;
790 if (RelocationsOverflow) {
797 for (
auto &Relocation : Sec->Relocations) {
798 assert(Relocation.Symb->getIndex() != -1);
799 Relocation.Data.SymbolTableIndex = Relocation.Symb->getIndex();
803 assert(Sec->Symbol->Aux.size() == 1 &&
804 "Section's symbol must have one aux!");
805 AuxSymbol &Aux = Sec->Symbol->Aux[0];
806 assert(Aux.AuxType == ATSectionDefinition &&
807 "Section's symbol's aux symbol must be a Section Definition!");
808 Aux.Aux.SectionDefinition.Length = Sec->Header.SizeOfRawData;
809 Aux.Aux.SectionDefinition.NumberOfRelocations =
810 Sec->Header.NumberOfRelocations;
811 Aux.Aux.SectionDefinition.NumberOfLinenumbers =
812 Sec->Header.NumberOfLineNumbers;
815 Header.PointerToSymbolTable =
Offset;
818void WinCOFFWriter::reset() {
819 memset(&Header, 0,
sizeof(Header));
820 Header.Machine = OWriter.TargetObjectWriter->getMachine();
826 WeakDefaults.clear();
829void WinCOFFWriter::executePostLayoutBinding(
MCAssembler &Asm) {
832 for (
const auto &Section : Asm) {
836 defineSection(Asm,
static_cast<const MCSectionCOFF &
>(Section));
842 if (!
Symbol.isTemporary() ||
844 defineSymbol(Asm, Symbol);
847void WinCOFFWriter::recordRelocation(
MCAssembler &Asm,
851 assert(
Target.getSymA() &&
"Relocation must reference a symbol!");
854 if (!
A.isRegistered()) {
855 Asm.getContext().reportError(
Fixup.getLoc(),
Twine(
"symbol '") +
857 "' can not be undefined");
860 if (
A.isTemporary() &&
A.isUndefined()) {
861 Asm.getContext().reportError(
Fixup.getLoc(),
Twine(
"assembler label '") +
863 "' can not be undefined");
870 assert(SectionMap.contains(MCSec) &&
871 "Section must already have been defined in executePostLayoutBinding!");
873 COFFSection *Sec = SectionMap[MCSec];
878 if (!
B->getFragment()) {
879 Asm.getContext().reportError(
881 Twine(
"symbol '") +
B->getName() +
882 "' can not be undefined in a subtraction expression");
887 int64_t OffsetOfB =
Asm.getSymbolOffset(*
B);
890 int64_t OffsetOfRelocation =
891 Asm.getFragmentOffset(*Fragment) +
Fixup.getOffset();
893 FixedValue = (OffsetOfRelocation - OffsetOfB) +
Target.getConstant();
895 FixedValue =
Target.getConstant();
898 COFFRelocation Reloc;
900 Reloc.Data.SymbolTableIndex = 0;
901 Reloc.Data.VirtualAddress =
Asm.getFragmentOffset(*Fragment);
907 SectionMap.contains(TargetSection) &&
908 "Section must already have been defined in executePostLayoutBinding!");
909 COFFSection *
Section = SectionMap[TargetSection];
911 FixedValue +=
Asm.getSymbolOffset(
A);
916 if (UseOffsetLabels && !
Section->OffsetSymbols.empty()) {
917 uint64_t LabelIndex = FixedValue >> OffsetLabelIntervalBits;
918 if (LabelIndex > 0) {
919 if (LabelIndex <= Section->OffsetSymbols.size())
920 Reloc.Symb =
Section->OffsetSymbols[LabelIndex - 1];
922 Reloc.Symb =
Section->OffsetSymbols.back();
923 FixedValue -= Reloc.Symb->Data.Value;
929 "Symbol must already have been defined in executePostLayoutBinding!");
933 ++Reloc.Symb->Relocations;
935 Reloc.Data.VirtualAddress +=
Fixup.getOffset();
936 Reloc.Data.Type = OWriter.TargetObjectWriter->getRelocType(
952 switch (Reloc.Data.Type) {
984 FixedValue = FixedValue + 4;
993 if (OWriter.TargetObjectWriter->recordRelocation(
Fixup))
994 Sec->Relocations.push_back(Reloc);
998 std::time_t Now = time(
nullptr);
999 if (Now < 0 || !isUInt<32>(Now))
1007 if (Sections.size() > INT32_MAX)
1009 "PE COFF object files can't have more than 2147483647 sections");
1012 Header.NumberOfSections = Sections.size();
1013 Header.NumberOfSymbols = 0;
1015 setWeakDefaultNames();
1016 assignSectionNumbers();
1017 if (Mode != DwoOnly)
1018 createFileSymbols(Asm);
1020 for (
auto &Symbol : Symbols) {
1024 Symbol->setIndex(Header.NumberOfSymbols++);
1027 Header.NumberOfSymbols +=
Symbol->Data.NumberOfAuxSymbols;
1031 for (
const auto &S : Sections)
1033 Strings.add(S->
Name);
1034 for (
const auto &S : Symbols)
1036 Strings.add(S->
Name);
1040 for (
const auto &S : Sections)
1042 for (
auto &S : Symbols)
1046 for (
auto &Symbol : Symbols) {
1049 assert(
Symbol->Aux.size() == 1 &&
"Symbol must contain one aux symbol!");
1051 "Symbol's aux symbol must be a Weak External!");
1052 Symbol->Aux[0].Aux.WeakExternal.TagIndex =
Symbol->Other->getIndex();
1057 for (
auto &Section : Sections) {
1058 if (
Section->Symbol->Aux[0].Aux.SectionDefinition.Selection !=
1069 Asm.getContext().reportError(
1071 Twine(
" associative with sectionless symbol ") +
1076 const auto *AssocMCSec = cast<MCSectionCOFF>(&AssocMCSym->
getSection());
1077 assert(SectionMap.count(AssocMCSec));
1078 COFFSection *AssocSec = SectionMap[AssocMCSec];
1081 if (AssocSec->Number == -1)
1084 Section->Symbol->Aux[0].Aux.SectionDefinition.Number = AssocSec->Number;
1088 if (Mode != DwoOnly && OWriter.getEmitAddrsigSection()) {
1089 auto *Sec =
Asm.getContext().getCOFFSection(
1091 auto *Frag = cast<MCDataFragment>(Sec->curFragList()->Head);
1093 for (
const MCSymbol *S : OWriter.AddrsigSyms) {
1102 assert(SectionMap.contains(TargetSection) &&
1103 "Section must already have been defined in "
1104 "executePostLayoutBinding!");
1110 if (Mode != DwoOnly && !
Asm.CGProfile.empty()) {
1111 auto *Sec =
Asm.getContext().getCOFFSection(
1113 auto *Frag = cast<MCDataFragment>(Sec->curFragList()->Head);
1124 assignFileOffsets(Asm);
1128 if (
Asm.isIncrementalLinkerCompatible()) {
1129 Header.TimeDateStamp =
getTime();
1132 Header.TimeDateStamp = 0;
1136 WriteFileHeader(Header);
1137 writeSectionHeaders();
1140 sections::iterator
I = Sections.begin();
1141 sections::iterator
IE = Sections.end();
1142 auto J =
Asm.begin();
1143 auto JE =
Asm.end();
1144 for (;
I !=
IE && J != JE; ++
I, ++J) {
1145 while (J != JE && ((Mode == NonDwoOnly &&
isDwoSection(*J)) ||
1148 assert(J != JE && (**I).MCSection == &*J &&
"Wrong bound MCSection");
1153 for (std::unique_ptr<COFFSection> &Sec : Sections)
1154 writeSection(Asm, *Sec);
1156 assert(
W.OS.tell() == Header.PointerToSymbolTable &&
1157 "Header::PointerToSymbolTable is insane!");
1160 for (
auto &Symbol : Symbols)
1161 if (
Symbol->getIndex() != -1)
1162 WriteSymbol(*Symbol);
1165 Strings.write(
W.OS);
1167 return W.OS.tell() - StartOffset;
1176void WinCOFFObjectWriter::reset() {
1183bool WinCOFFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
1185 bool InSet,
bool IsPCRel)
const {
1198void WinCOFFObjectWriter::executePostLayoutBinding(
MCAssembler &Asm) {
1199 ObjWriter->executePostLayoutBinding(Asm);
1201 DwoWriter->executePostLayoutBinding(Asm);
1204void WinCOFFObjectWriter::recordRelocation(
MCAssembler &Asm,
1209 "No relocation in Dwo sections");
1210 ObjWriter->recordRelocation(Asm, Fragment,
Fixup,
Target, FixedValue);
1214 uint64_t TotalSize = ObjWriter->writeObject(Asm);
1216 TotalSize += DwoWriter->writeObject(Asm);
1224void MCWinCOFFObjectTargetWriter::anchor() {}
1231 return std::make_unique<WinCOFFObjectWriter>(std::move(MOTW),
OS);
1237 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 uint64_t getSymbolValue(const MCSymbol &Symbol, const MCAssembler &Asm)
static uint32_t getAlignment(const MCSectionCOFF &Sec)
static bool isAssociative(const COFFSection &Section)
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.
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 bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const
virtual void executePostLayoutBinding(MCAssembler &Asm)
Perform any late binding of symbols (for example, to assign symbol indices for use when generating re...
virtual void reset()
lifetime management
virtual uint64_t writeObject(MCAssembler &Asm)=0
Write the object file and returns the number of bytes written.
virtual void recordRelocation(MCAssembler &Asm, 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
Adapter to write values to a stream in a particular byte order.