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;
175 COFFSymbol *GetOrCreateCOFFSymbol(
const MCSymbol *Symbol);
180 COFFSymbol *getLinkedSymbol(
const MCSymbol &Symbol);
184 void SetSymbolName(COFFSymbol &S);
185 void SetSectionName(COFFSection &S);
187 bool IsPhysicalSection(COFFSection *S);
191 void WriteSymbol(
const COFFSymbol &S);
193 void writeSectionHeaders();
198 const COFFSection &Sec);
201 void setWeakDefaultNames();
202 void assignSectionNumbers();
207 friend class WinCOFFWriter;
209 std::unique_ptr<MCWinCOFFObjectTargetWriter> TargetObjectWriter;
210 std::unique_ptr<WinCOFFWriter> ObjWriter, DwoWriter;
213 WinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
215 : TargetObjectWriter(std::move(MOTW)),
216 ObjWriter(std::make_unique<WinCOFFWriter>(*
this,
OS,
217 WinCOFFWriter::AllSections)) {
219 WinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,
221 : TargetObjectWriter(std::move(MOTW)),
222 ObjWriter(std::make_unique<WinCOFFWriter>(*
this,
OS,
223 WinCOFFWriter::NonDwoOnly)),
224 DwoWriter(std::make_unique<WinCOFFWriter>(*
this, DwoOS,
225 WinCOFFWriter::DwoOnly)) {}
228 void reset()
override;
234 bool IsPCRel)
const override;
261WinCOFFWriter::WinCOFFWriter(WinCOFFObjectWriter &OWriter,
264 Header.Machine = OWriter.TargetObjectWriter->getMachine();
273 Symbols.push_back(std::make_unique<COFFSymbol>(
Name));
274 return Symbols.back().get();
277COFFSymbol *WinCOFFWriter::GetOrCreateCOFFSymbol(
const MCSymbol *Symbol) {
285 Sections.emplace_back(std::make_unique<COFFSection>(
Name));
286 return Sections.back().get();
336 COFFSymbol *COMDATSymbol = GetOrCreateCOFFSymbol(S);
337 if (COMDATSymbol->Section)
339 COMDATSymbol->Section =
Section;
346 Symbol->Aux[0].AuxType = ATSectionDefinition;
367 Section->OffsetSymbols.push_back(Label);
374 if (Symbol.isCommon() && Symbol.isExternal())
375 return Symbol.getCommonSize();
384COFFSymbol *WinCOFFWriter::getLinkedSymbol(
const MCSymbol &Symbol) {
389 dyn_cast<MCSymbolRefExpr>(
Symbol.getVariableValue());
395 return GetOrCreateCOFFSymbol(&Aliasee);
404 COFFSymbol *
Sym = GetOrCreateCOFFSymbol(&MCSym);
406 COFFSection *Sec =
nullptr;
408 Sec = SectionMap[
Base->getFragment()->getParent()];
409 if (
Sym->Section &&
Sym->Section != Sec)
413 COFFSymbol *
Local =
nullptr;
414 if (cast<MCSymbolCOFF>(MCSym).getWeakExternalCharacteristics()) {
416 Sym->Section =
nullptr;
418 COFFSymbol *WeakDefault = getLinkedSymbol(MCSym);
420 std::string WeakName = (
".weak." + MCSym.
getName() +
".default").str();
421 WeakDefault = createSymbol(WeakName);
425 WeakDefault->Section = Sec;
426 WeakDefaults.insert(WeakDefault);
430 Sym->Other = WeakDefault;
434 memset(&
Sym->Aux[0], 0,
sizeof(
Sym->Aux[0]));
435 Sym->Aux[0].AuxType = ATWeakExternal;
436 Sym->Aux[0].Aux.WeakExternal.TagIndex = 0;
437 Sym->Aux[0].Aux.WeakExternal.Characteristics =
438 cast<MCSymbolCOFF>(MCSym).getWeakExternalCharacteristics();
450 const MCSymbolCOFF &SymbolCOFF = cast<MCSymbolCOFF>(MCSym);
467void WinCOFFWriter::SetSectionName(COFFSection &S) {
469 std::memcpy(S.Header.Name, S.Name.c_str(), S.Name.size());
473 uint64_t StringTableEntry = Strings.getOffset(S.Name);
478void WinCOFFWriter::SetSymbolName(COFFSymbol &S) {
480 S.set_name_offset(Strings.getOffset(S.Name));
482 std::memcpy(S.Data.Name, S.Name.c_str(), S.Name.size());
485bool WinCOFFWriter::IsPhysicalSection(COFFSection *S) {
493void WinCOFFWriter::WriteFileHeader(
const COFF::header &Header) {
505 W.write<
uint32_t>(Header.NumberOfSections);
506 W.write<
uint32_t>(Header.PointerToSymbolTable);
507 W.write<
uint32_t>(Header.NumberOfSymbols);
510 W.write<
uint16_t>(
static_cast<int16_t
>(Header.NumberOfSections));
512 W.write<
uint32_t>(Header.PointerToSymbolTable);
513 W.write<
uint32_t>(Header.NumberOfSymbols);
514 W.write<
uint16_t>(Header.SizeOfOptionalHeader);
515 W.write<
uint16_t>(Header.Characteristics);
519void WinCOFFWriter::WriteSymbol(
const COFFSymbol &S) {
525 W.write<
uint16_t>(
static_cast<int16_t
>(S.Data.SectionNumber));
527 W.OS <<
char(S.Data.StorageClass);
528 W.OS <<
char(S.Data.NumberOfAuxSymbols);
529 WriteAuxiliarySymbols(S.Aux);
532void WinCOFFWriter::WriteAuxiliarySymbols(
534 for (
const AuxSymbol &i : S) {
537 W.write<
uint32_t>(i.Aux.WeakExternal.TagIndex);
538 W.write<
uint32_t>(i.Aux.WeakExternal.Characteristics);
539 W.OS.write_zeros(
sizeof(i.Aux.WeakExternal.unused));
544 W.OS.write(
reinterpret_cast<const char *
>(&i.Aux),
547 case ATSectionDefinition:
548 W.write<
uint32_t>(i.Aux.SectionDefinition.Length);
549 W.write<
uint16_t>(i.Aux.SectionDefinition.NumberOfRelocations);
550 W.write<
uint16_t>(i.Aux.SectionDefinition.NumberOfLinenumbers);
551 W.write<
uint32_t>(i.Aux.SectionDefinition.CheckSum);
552 W.write<
uint16_t>(
static_cast<int16_t
>(i.Aux.SectionDefinition.Number));
553 W.OS <<
char(i.Aux.SectionDefinition.Selection);
554 W.OS.write_zeros(
sizeof(i.Aux.SectionDefinition.unused));
556 static_cast<int16_t
>(i.Aux.SectionDefinition.Number >> 16));
565void WinCOFFWriter::writeSectionHeaders() {
569 std::vector<COFFSection *> Arr;
570 for (
auto &Section : Sections)
572 llvm::sort(Arr, [](
const COFFSection *
A,
const COFFSection *
B) {
573 return A->Number <
B->Number;
576 for (
auto &Section : Arr) {
581 if (
Section->Relocations.size() >= 0xffff)
612 Asm.writeSectionData(VecOS, &MCSec, Layout);
625 const COFFSection &Sec) {
626 if (Sec.Number == -1)
630 if (Sec.Header.PointerToRawData != 0) {
631 assert(
W.OS.tell() == Sec.Header.PointerToRawData &&
632 "Section::PointerToRawData is insane!");
634 uint32_t CRC = writeSectionContents(Asm, Layout, *Sec.MCSection);
638 assert(AuxSyms.
size() == 1 && AuxSyms[0].AuxType == ATSectionDefinition);
639 AuxSymbol &SecDef = AuxSyms[0];
640 SecDef.Aux.SectionDefinition.CheckSum = CRC;
644 if (Sec.Relocations.empty()) {
645 assert(Sec.Header.PointerToRelocations == 0 &&
646 "Section::PointerToRelocations is insane!");
650 assert(
W.OS.tell() == Sec.Header.PointerToRelocations &&
651 "Section::PointerToRelocations is insane!");
653 if (Sec.Relocations.size() >= 0xffff) {
657 R.VirtualAddress = Sec.Relocations.size() + 1;
658 R.SymbolTableIndex = 0;
663 for (
const auto &Relocation : Sec.Relocations)
664 WriteRelocation(Relocation.Data);
668void WinCOFFWriter::createFileSymbols(
MCAssembler &Asm) {
669 for (
const std::pair<std::string, size_t> &It :
Asm.getFileNames()) {
671 const std::string &
Name = It.first;
673 unsigned Count = (
Name.size() + SymbolSize - 1) / SymbolSize;
675 COFFSymbol *
File = createSymbol(
".file");
678 File->Aux.resize(Count);
682 for (
auto &Aux :
File->Aux) {
683 Aux.AuxType = ATFile;
685 if (
Length > SymbolSize) {
686 memcpy(&Aux.Aux,
Name.c_str() +
Offset, SymbolSize);
690 memset((
char *)&Aux.Aux +
Length, 0, SymbolSize -
Length);
699void WinCOFFWriter::setWeakDefaultNames() {
700 if (WeakDefaults.empty())
710 COFFSymbol *Unique =
nullptr;
711 for (
bool AllowComdat : {
false,
true}) {
712 for (
auto &
Sym : Symbols) {
714 if (WeakDefaults.count(
Sym.get()))
722 if (!AllowComdat &&
Sym->Section &&
734 for (
auto *
Sym : WeakDefaults) {
735 Sym->Name.append(
".");
736 Sym->Name.append(Unique->Name);
741 return Section.Symbol->Aux[0].Aux.SectionDefinition.Selection ==
745void WinCOFFWriter::assignSectionNumbers() {
749 Section.Symbol->Data.SectionNumber =
I;
750 Section.Symbol->Aux[0].Aux.SectionDefinition.Number =
I;
757 for (
const std::unique_ptr<COFFSection> &Section : Sections)
760 for (
const std::unique_ptr<COFFSection> &Section : Sections)
766void WinCOFFWriter::assignFileOffsets(
MCAssembler &Asm,
773 for (
const auto &Section : Asm) {
774 COFFSection *Sec = SectionMap[&
Section];
776 if (!Sec || Sec->Number == -1)
781 if (IsPhysicalSection(Sec)) {
782 Sec->Header.PointerToRawData =
Offset;
783 Offset += Sec->Header.SizeOfRawData;
786 if (!Sec->Relocations.empty()) {
787 bool RelocationsOverflow = Sec->Relocations.size() >= 0xffff;
789 if (RelocationsOverflow) {
792 Sec->Header.NumberOfRelocations = 0xffff;
794 Sec->Header.NumberOfRelocations = Sec->Relocations.size();
796 Sec->Header.PointerToRelocations =
Offset;
798 if (RelocationsOverflow) {
805 for (
auto &Relocation : Sec->Relocations) {
806 assert(Relocation.Symb->getIndex() != -1);
807 Relocation.Data.SymbolTableIndex = Relocation.Symb->getIndex();
811 assert(Sec->Symbol->Aux.size() == 1 &&
812 "Section's symbol must have one aux!");
813 AuxSymbol &Aux = Sec->Symbol->Aux[0];
814 assert(Aux.AuxType == ATSectionDefinition &&
815 "Section's symbol's aux symbol must be a Section Definition!");
816 Aux.Aux.SectionDefinition.Length = Sec->Header.SizeOfRawData;
817 Aux.Aux.SectionDefinition.NumberOfRelocations =
818 Sec->Header.NumberOfRelocations;
819 Aux.Aux.SectionDefinition.NumberOfLinenumbers =
820 Sec->Header.NumberOfLineNumbers;
823 Header.PointerToSymbolTable =
Offset;
826void WinCOFFWriter::reset() {
827 memset(&Header, 0,
sizeof(Header));
828 Header.Machine = OWriter.TargetObjectWriter->getMachine();
834 WeakDefaults.clear();
837void WinCOFFWriter::executePostLayoutBinding(
MCAssembler &Asm,
841 for (
const auto &Section : Asm) {
845 defineSection(
static_cast<const MCSectionCOFF &
>(Section), Layout);
851 if (!
Symbol.isTemporary() ||
853 DefineSymbol(Symbol, Asm, Layout);
856void WinCOFFWriter::recordRelocation(
MCAssembler &Asm,
861 assert(
Target.getSymA() &&
"Relocation must reference a symbol!");
864 if (!
A.isRegistered()) {
865 Asm.getContext().reportError(
Fixup.getLoc(),
Twine(
"symbol '") +
867 "' can not be undefined");
870 if (
A.isTemporary() &&
A.isUndefined()) {
871 Asm.getContext().reportError(
Fixup.getLoc(),
Twine(
"assembler label '") +
873 "' can not be undefined");
880 assert(SectionMap.contains(MCSec) &&
881 "Section must already have been defined in executePostLayoutBinding!");
883 COFFSection *Sec = SectionMap[MCSec];
888 if (!
B->getFragment()) {
889 Asm.getContext().reportError(
891 Twine(
"symbol '") +
B->getName() +
892 "' can not be undefined in a subtraction expression");
900 int64_t OffsetOfRelocation =
903 FixedValue = (OffsetOfRelocation - OffsetOfB) +
Target.getConstant();
905 FixedValue =
Target.getConstant();
908 COFFRelocation Reloc;
910 Reloc.Data.SymbolTableIndex = 0;
917 SectionMap.contains(TargetSection) &&
918 "Section must already have been defined in executePostLayoutBinding!");
919 COFFSection *
Section = SectionMap[TargetSection];
926 if (UseOffsetLabels && !
Section->OffsetSymbols.empty()) {
927 uint64_t LabelIndex = FixedValue >> OffsetLabelIntervalBits;
928 if (LabelIndex > 0) {
929 if (LabelIndex <= Section->OffsetSymbols.size())
930 Reloc.Symb =
Section->OffsetSymbols[LabelIndex - 1];
932 Reloc.Symb =
Section->OffsetSymbols.back();
933 FixedValue -= Reloc.Symb->Data.Value;
939 "Symbol must already have been defined in executePostLayoutBinding!");
943 ++Reloc.Symb->Relocations;
945 Reloc.Data.VirtualAddress +=
Fixup.getOffset();
946 Reloc.Data.Type = OWriter.TargetObjectWriter->getRelocType(
962 switch (Reloc.Data.Type) {
994 FixedValue = FixedValue + 4;
1003 if (OWriter.TargetObjectWriter->recordRelocation(
Fixup))
1004 Sec->Relocations.push_back(Reloc);
1008 std::time_t Now = time(
nullptr);
1009 if (Now < 0 || !isUInt<32>(Now))
1018 if (Sections.size() > INT32_MAX)
1020 "PE COFF object files can't have more than 2147483647 sections");
1023 Header.NumberOfSections = Sections.size();
1024 Header.NumberOfSymbols = 0;
1026 setWeakDefaultNames();
1027 assignSectionNumbers();
1028 if (Mode != DwoOnly)
1029 createFileSymbols(Asm);
1031 for (
auto &Symbol : Symbols) {
1035 Symbol->setIndex(Header.NumberOfSymbols++);
1038 Header.NumberOfSymbols +=
Symbol->Data.NumberOfAuxSymbols;
1042 for (
const auto &S : Sections)
1044 Strings.add(S->
Name);
1045 for (
const auto &S : Symbols)
1047 Strings.add(S->
Name);
1051 for (
const auto &S : Sections)
1053 for (
auto &S : Symbols)
1057 for (
auto &Symbol : Symbols) {
1060 assert(
Symbol->Aux.size() == 1 &&
"Symbol must contain one aux symbol!");
1062 "Symbol's aux symbol must be a Weak External!");
1063 Symbol->Aux[0].Aux.WeakExternal.TagIndex =
Symbol->Other->getIndex();
1068 for (
auto &Section : Sections) {
1069 if (
Section->Symbol->Aux[0].Aux.SectionDefinition.Selection !=
1080 Asm.getContext().reportError(
1082 Twine(
" associative with sectionless symbol ") +
1087 const auto *AssocMCSec = cast<MCSectionCOFF>(&AssocMCSym->
getSection());
1088 assert(SectionMap.count(AssocMCSec));
1089 COFFSection *AssocSec = SectionMap[AssocMCSec];
1092 if (AssocSec->Number == -1)
1095 Section->Symbol->Aux[0].Aux.SectionDefinition.Number = AssocSec->Number;
1099 if (Mode != DwoOnly && OWriter.EmitAddrsigSection) {
1101 Frag->setLayoutOrder(0);
1103 for (
const MCSymbol *S : OWriter.AddrsigSyms) {
1112 assert(SectionMap.contains(TargetSection) &&
1113 "Section must already have been defined in "
1114 "executePostLayoutBinding!");
1120 if (Mode != DwoOnly && CGProfileSection) {
1122 Frag->setLayoutOrder(0);
1133 assignFileOffsets(Asm, Layout);
1137 if (
Asm.isIncrementalLinkerCompatible()) {
1138 Header.TimeDateStamp =
getTime();
1141 Header.TimeDateStamp = 0;
1145 WriteFileHeader(Header);
1146 writeSectionHeaders();
1149 sections::iterator
I = Sections.begin();
1150 sections::iterator
IE = Sections.end();
1153 for (;
I !=
IE && J != JE; ++
I, ++J) {
1154 while (J != JE && ((Mode == NonDwoOnly &&
isDwoSection(*J)) ||
1157 assert(J != JE && (**I).MCSection == &*J &&
"Wrong bound MCSection");
1162 for (std::unique_ptr<COFFSection> &Sec : Sections)
1163 writeSection(Asm, Layout, *Sec);
1165 assert(
W.OS.tell() == Header.PointerToSymbolTable &&
1166 "Header::PointerToSymbolTable is insane!");
1169 for (
auto &Symbol : Symbols)
1170 if (
Symbol->getIndex() != -1)
1171 WriteSymbol(*Symbol);
1174 Strings.write(
W.OS);
1176 return W.OS.tell() - StartOffset;
1185void WinCOFFObjectWriter::reset() {
1192bool WinCOFFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
1194 bool InSet,
bool IsPCRel)
const {
1208void WinCOFFObjectWriter::executePostLayoutBinding(
MCAssembler &Asm,
1210 if (EmitAddrsigSection) {
1211 ObjWriter->AddrsigSection =
Asm.getContext().getCOFFSection(
1214 Asm.registerSection(*ObjWriter->AddrsigSection);
1217 if (!
Asm.CGProfile.empty()) {
1218 ObjWriter->CGProfileSection =
Asm.getContext().getCOFFSection(
1221 Asm.registerSection(*ObjWriter->CGProfileSection);
1224 ObjWriter->executePostLayoutBinding(Asm, Layout);
1226 DwoWriter->executePostLayoutBinding(Asm, Layout);
1229void WinCOFFObjectWriter::recordRelocation(
MCAssembler &Asm,
1235 "No relocation in Dwo sections");
1236 ObjWriter->recordRelocation(Asm, Layout, Fragment,
Fixup,
Target, FixedValue);
1241 uint64_t TotalSize = ObjWriter->writeObject(Asm, Layout);
1243 TotalSize += DwoWriter->writeObject(Asm, Layout);
1248 : Machine(Machine_) {}
1251void MCWinCOFFObjectTargetWriter::anchor() {}
1258 return std::make_unique<WinCOFFObjectWriter>(std::move(MOTW),
OS);
1264 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")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
COFFYAML::AuxSymbolType AuxType
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
std::optional< std::vector< StOtherPiece > > Other
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.
Interval Class - An Interval is a set of nodes defined such that every node in the interval has all o...
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.
Fragment for data and encoded instructions.
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.
MCSection::FragmentListType & getFragmentList()
StringRef getName() const
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.
static SectionKind getMetadata()
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 endswith(StringRef Suffix) const
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_ARM64
@ 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
@ 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.