1//===- lib/MC/MachObjectWriter.cpp - Mach-O File Writer -------------------===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 43#define DEBUG_TYPE "mc" 47 IndirectSymBase.clear();
48 IndirectSymbols.clear();
50 SectionAddress.
clear();
53 LocalSymbolData.clear();
54 ExternalSymbolData.clear();
55 UndefinedSymbolData.clear();
57 VersionInfo.Major = 0;
59 TargetVariantVersionInfo.Major = 0;
61 LinkerOptions.clear();
66// Undefined symbols are always extern. 70// References to weak definitions require external relocation entries; the 71// definition may not always be the one in the same object file. 72if (cast<MCSymbolMachO>(S).isWeakDefinition())
75// Otherwise, we can use an internal relocation. 79bool MachObjectWriter::
80MachSymbolData::operator<(
const MachSymbolData &RHS)
const{
81return Symbol->getName() <
RHS.Symbol->
getName();
95 Asm.getFragmentOffset(*Fragment);
100// If this is a variable, then recursively evaluate now. 111// Verify that any used symbols are defined. 112if (
Target.getSymA() &&
Target.getSymA()->getSymbol().isUndefined())
115if (
Target.getSymB() &&
Target.getSymB()->getSymbol().isUndefined())
128 Asm.getSymbolOffset(S);
134unsigned Next = cast<MCSectionMachO>(Sec)->getLayoutOrder() + 1;
135if (Next >= SectionOrder.
size())
138constMCSection &NextSec = *SectionOrder[Next];
145// Non-temporary labels should always be visible to the linker. 146if (!Symbol.isTemporary())
149if (Symbol.isUsedInReloc())
156// Linker visible symbols define atoms. 160// Absolute and undefined symbols have no defining atom. 164// Non-linker visible symbols in sections which can't be atomized have no 170// Otherwise, return the atom for the containing fragment. 175unsigned NumLoadCommands,
176unsigned LoadCommandsSize,
177bool SubsectionsViaSymbols) {
183// struct mach_header (28 bytes) or 184// struct mach_header_64 (32 bytes) 193uint32_t Cpusubtype = TargetObjectWriter->getCPUSubtype();
195// Promote arm64e subtypes to always be ptrauth-ABI-versioned, at version 0. 196// We never need to emit unversioned binaries. 197// And we don't support arbitrary ABI versions (or the kernel flag) yet. 201/*PtrAuthABIVersion=*/0,
/*PtrAuthKernelABIVersion=*/false);
222/// writeSegmentLoadCommand - Write a segment load command. 224/// \param NumSections The number of sections in this segment. 225/// \param SectionDataSize The total size of the sections. 230// struct segment_command (56 bytes) or 231// struct segment_command_64 (72 bytes) 236unsigned SegmentLoadCommandSize =
244 writeWithPadding(
Name, 16);
270unsigned NumRelocations) {
271uint64_t SectionSize = Asm.getSectionAddressSize(Sec);
274// The offset is unused for virtual sections. 275if (Section.isVirtualSection()) {
276assert(Asm.getSectionFileSize(Sec) == 0 &&
"Invalid file size!");
280// struct section (68 bytes) or 281// struct section_64 (80 bytes) 286 writeWithPadding(Section.getName(), 16);
287 writeWithPadding(Section.getSegmentName(), 16);
295assert(isUInt<32>(FileOffset) &&
"Cannot encode offset of section");
299assert((!NumRelocations || isUInt<32>(RelocationsStart)) &&
300"Cannot encode offset of relocations");
317// struct symtab_command (24 bytes) 340// struct dysymtab_command (80 bytes) 369MachObjectWriter::MachSymbolData *
370MachObjectWriter::findSymbolData(
constMCSymbol &
Sym) {
371for (
auto *SymbolData :
372 {&LocalSymbolData, &ExternalSymbolData, &UndefinedSymbolData})
373for (MachSymbolData &Entry : *SymbolData)
374if (Entry.Symbol == &
Sym)
384constauto *
Ref = dyn_cast<MCSymbolRefExpr>(
Value);
387 S = &
Ref->getSymbol();
394constauto &
Data = cast<MCSymbolMachO>(*Symbol);
396uint8_t SectionIndex = MSD.SectionIndex;
399bool IsAlias = Symbol != AliasedSymbol;
402 MachSymbolData *AliaseeInfo;
404 AliaseeInfo = findSymbolData(*AliasedSymbol);
406 SectionIndex = AliaseeInfo->SectionIndex;
407 Symbol = AliasedSymbol;
408// FIXME: Should this update Data as well? 411// Set the N_TYPE bits. See <mach-o/nlist.h>. 413// FIXME: Are the prebound or indirect fields possible here? 414if (IsAlias && Symbol->isUndefined())
416elseif (Symbol->isUndefined())
418elseif (Symbol->isAbsolute())
423// FIXME: Set STAB bits. 425if (
Data.isPrivateExtern())
429if (
Data.isExternal() || (!IsAlias && Symbol->isUndefined()))
432// Compute the symbol address. 433if (IsAlias && Symbol->isUndefined())
434Address = AliaseeInfo->StringIndex;
435elseif (Symbol->isDefined())
437elseif (Symbol->isCommon()) {
438// Common symbols are encoded with the size in the address 439// field, and their alignment in the flags. 440Address = Symbol->getCommonSize();
443// struct nlist (12 bytes) 449// The Mach-O streamer uses the lowest 16-bits of the flags for the 'desc' 451bool EncodeAsAltEntry =
452 IsAlias && cast<MCSymbolMachO>(OrigSymbol).isAltEntry();
453W.
write<
uint16_t>(cast<MCSymbolMachO>(Symbol)->getEncodedFlags(EncodeAsAltEntry));
478for (
const std::string &Option :
Options)
479Size += Option.size() + 1;
484const std::vector<std::string> &
Options)
494for (
const std::string &Option :
Options) {
495// Write each string, including the null byte. 496W.
OS << Option <<
'\0';
497 BytesWritten += Option.size() + 1;
500// Pad to a multiple of the pointer size. 508// Target is (LHS - RHS + cst). 509// We don't support the form where LHS is null: -RHS + cst 520 Asm.getContext().reportError(
Fixup.getLoc(),
521"unsupported relocation expression");
525 TargetObjectWriter->recordRelocation(
this, Asm, Fragment,
Fixup,
Target,
530// This is the point where 'as' creates actual symbols for indirect symbols 531// (in the following two passes). It would be easier for us to do this sooner 532// when we see the attribute, but that makes getting the order in the symbol 533// table much more complicated than it is worth. 535// FIXME: Revisit this when the dust settles. 537// Report errors for use of .indirect_symbol not in a symbol pointer section 539for (IndirectSymbolData &ISD : IndirectSymbols) {
548"' not in a symbol pointer or stub section");
552// Bind non-lazy symbol pointers first. 553for (
auto [IndirectIndex, ISD] :
enumerate(IndirectSymbols)) {
554constauto &Section = cast<MCSectionMachO>(*ISD.Section);
560// Initialize the section indirect symbol base, if necessary. 561 IndirectSymBase.insert(std::make_pair(ISD.Section, IndirectIndex));
563 Asm.registerSymbol(*ISD.Symbol);
566// Then lazy symbol pointers and symbol stubs. 567for (
auto [IndirectIndex, ISD] :
enumerate(IndirectSymbols)) {
568constauto &Section = cast<MCSectionMachO>(*ISD.Section);
574// Initialize the section indirect symbol base, if necessary. 575 IndirectSymBase.insert(std::make_pair(ISD.Section, IndirectIndex));
577// Set the symbol type to undefined lazy, but only on construction. 579// FIXME: Do not hardcode. 580if (Asm.registerSymbol(*ISD.Symbol))
581 cast<MCSymbolMachO>(ISD.Symbol)->setReferenceTypeUndefinedLazy(
true);
585/// computeSymbolTable - Compute the symbol table data 587MCAssembler &Asm, std::vector<MachSymbolData> &LocalSymbolData,
588 std::vector<MachSymbolData> &ExternalSymbolData,
589 std::vector<MachSymbolData> &UndefinedSymbolData) {
590// Build section lookup table. 594 SectionIndexMap[&Sec] = Index++;
595assert(Index <= 256 &&
"Too many sections!");
597// Build the string table. 598for (
constMCSymbol &Symbol : Asm.symbols()) {
606// Build the symbol arrays but only for non-local symbols. 608// The particular order that we collect and then sort the symbols is chosen to 609// match 'as'. Even though it doesn't matter for correctness, this is 610// important for letting us diff .o files. 611for (
constMCSymbol &Symbol : Asm.symbols()) {
612// Ignore non-linker visible symbols. 616if (!Symbol.isExternal() && !Symbol.isUndefined())
620 MSD.Symbol = &Symbol;
621 MSD.StringIndex =
StringTable.getOffset(Symbol.getName());
623if (Symbol.isUndefined()) {
624 MSD.SectionIndex = 0;
625 UndefinedSymbolData.push_back(MSD);
626 }
elseif (Symbol.isAbsolute()) {
627 MSD.SectionIndex = 0;
628 ExternalSymbolData.push_back(MSD);
630 MSD.SectionIndex = SectionIndexMap.
lookup(&Symbol.getSection());
631assert(MSD.SectionIndex &&
"Invalid section index!");
632 ExternalSymbolData.push_back(MSD);
636// Now add the data for local symbols. 637for (
constMCSymbol &Symbol : Asm.symbols()) {
638// Ignore non-linker visible symbols. 642if (Symbol.isExternal() || Symbol.isUndefined())
646 MSD.Symbol = &Symbol;
647 MSD.StringIndex =
StringTable.getOffset(Symbol.getName());
649if (Symbol.isAbsolute()) {
650 MSD.SectionIndex = 0;
651 LocalSymbolData.push_back(MSD);
653 MSD.SectionIndex = SectionIndexMap.
lookup(&Symbol.getSection());
654assert(MSD.SectionIndex &&
"Invalid section index!");
655 LocalSymbolData.push_back(MSD);
659// External and undefined symbols are required to be in lexicographic order. 663// Set the symbol indices. 665for (
auto *SymbolData :
666 {&LocalSymbolData, &ExternalSymbolData, &UndefinedSymbolData})
667for (MachSymbolData &Entry : *SymbolData)
668 Entry.Symbol->setIndex(Index++);
671for (RelAndSymbol &Rel : Relocations[&Section]) {
675// Set the Index and the IsExtern bit. 676unsigned Index = Rel.Sym->getIndex();
679 Rel.MRE.r_word1 = (Rel.MRE.r_word1 & (~0U << 24)) | Index | (1 << 27);
681 Rel.MRE.r_word1 = (Rel.MRE.r_word1 & 0xff) | Index << 8 | (1 << 4);
687// Assign layout order indices to sections. 689// Compute the section layout order. Virtual sections must go last. 691if (!Sec.isVirtualSection()) {
693 cast<MCSectionMachO>(Sec).setLayoutOrder(i++);
697if (Sec.isVirtualSection()) {
699 cast<MCSectionMachO>(Sec).setLayoutOrder(i++);
704for (
constMCSection *Sec : SectionOrder) {
705 StartAddress =
alignTo(StartAddress, Sec->getAlign());
706 SectionAddress[Sec] = StartAddress;
707 StartAddress += Asm.getSectionAddressSize(*Sec);
709// Explicitly pad the section to match the alignment requirements of the 710// following one. This is for 'gas' compatibility, it shouldn't 711 /// strictly be necessary. 719// Create symbol data for any indirect symbols. 725bool InSet,
bool IsPCRel)
const{
729// The effective address is 730// addr(atom(A)) + offset(A) 731// - addr(atom(B)) - offset(B) 732// and the offsets are not relocatable, so the fixup is fully resolved when 733// addr(atom(A)) - addr(atom(B)) == 0. 739// The simple (Darwin, except on x86_64) way of dealing with this was to 740// assume that any reference to a temporary symbol *must* be a temporary 741// symbol in the same atom, unless the sections differ. Therefore, any PCrel 742// relocation to a temporary symbol (in the same section) is fully 743// resolved. This also works in conjunction with absolutized .set, which 744// requires the compiler to use .set to absolutize the differences between 745// symbols which the compiler knows to be assembly time constants, so we 746// don't need to worry about considering symbol differences fully resolved. 748// If the file isn't using sub-sections-via-symbols, we can make the 749// same assumptions about any symbol that we normally make about 752bool hasReliableSymbolDifference =
isX86_64();
753if (!hasReliableSymbolDifference) {
762// If they are not in the same section, we can't compute the diff. 766// If the atoms are the same, they are guaranteed to have the same address. 782 Asm.getContext().getObjectFileInfo()->getAddrSigSection();
783unsigned Log2Size =
is64Bit() ? 3 : 2;
785if (!S->isRegistered())
796auto NumBytesWritten = [&] {
returnW.
OS.
tell() - StartOffset; };
800// Compute symbol table information and bind symbol indices. 802 UndefinedSymbolData);
805MCSection *CGProfileSection = Asm.getContext().getMachOSection(
807auto &Frag = cast<MCDataFragment>(*CGProfileSection->
begin());
808 Frag.getContents().clear();
811uint32_t FromIndex = CGPE.From->getSymbol().getIndex();
812uint32_t ToIndex = CGPE.To->getSymbol().getIndex();
819unsigned NumSections = Asm.end() - Asm.begin();
821// The section data starts after the header, the segment load command (and 822// section headers) and the symbol table. 823unsigned NumLoadCommands = 1;
828// Add the deployment target version info load command size, if used. 829if (VersionInfo.Major != 0) {
831if (VersionInfo.EmitBuildVersion)
837// Add the target variant version info load command size, if used. 838if (TargetVariantVersionInfo.Major != 0) {
840assert(TargetVariantVersionInfo.EmitBuildVersion &&
841"target variant should use build version");
845// Add the data-in-code load command size, if used. 846unsigned NumDataRegions = DataRegions.size();
852// Add the loh load command size, if used. 860// Add the symbol table load command sizes, if used. 861unsigned NumSymbols = LocalSymbolData.size() + ExternalSymbolData.size() +
862 UndefinedSymbolData.size();
864 NumLoadCommands += 2;
869// Add the linker option load commands sizes. 870for (
constauto &Option : LinkerOptions) {
875// Compute the total size of the section data, as well as its file size and vm 885uint64_t FileSize = Asm.getSectionFileSize(Sec);
890if (Sec.isVirtualSection())
893 SectionDataSize = std::max(SectionDataSize,
Address +
Size);
894 SectionDataFileSize = std::max(SectionDataFileSize,
Address + FileSize);
897// The section data is padded to pointer size bytes. 899// FIXME: Is this machine dependent? 900unsigned SectionDataPadding =
902 SectionDataFileSize += SectionDataPadding;
904// Write the prolog, starting with the header and load command... 910 SectionDataSize, Prot, Prot);
912// ... and then the section headers. 913uint64_t RelocTableEnd = SectionDataStart + SectionDataFileSize;
915constauto &Sec = cast<MCSectionMachO>(Section);
916 std::vector<RelAndSymbol> &Relocs = Relocations[&Sec];
917unsigned NumRelocs = Relocs.size();
919unsigned Flags = Sec.getTypeAndAttributes();
920if (Sec.hasInstructions())
922if (!cast<MCSectionMachO>(Sec).isVirtualSection() &&
923 !isUInt<32>(SectionStart)) {
924 Asm.getContext().reportError(
925SMLoc(),
"cannot encode offset of section; object file too large");
926return NumBytesWritten();
928if (NumRelocs && !isUInt<32>(RelocTableEnd)) {
929 Asm.getContext().reportError(
931"cannot encode offset of relocations; object file too large");
932return NumBytesWritten();
935 RelocTableEnd, NumRelocs);
939// Write out the deployment target information, if it's available. 940auto EmitDeploymentTargetVersion =
943assert(!V.empty() &&
"empty version");
944unsignedUpdate = V.getSubminor().value_or(0);
945unsignedMinor = V.getMinor().value_or(0);
946assert(
Update < 256 &&
"unencodable update target version");
947assert(
Minor < 256 &&
"unencodable minor target version");
948assert(V.getMajor() < 65536 &&
"unencodable major target version");
952 VersionInfo.Major, VersionInfo.Minor, VersionInfo.Update));
954 ? EncodeVersion(VersionInfo.SDKVersion)
956if (VersionInfo.EmitBuildVersion) {
957// FIXME: Currently empty tools. Add clang version in the future. 973if (VersionInfo.Major != 0)
974 EmitDeploymentTargetVersion(VersionInfo);
975if (TargetVariantVersionInfo.Major != 0)
976 EmitDeploymentTargetVersion(TargetVariantVersionInfo);
978// Write the data-in-code load command, if used. 979uint64_t DataInCodeTableEnd = RelocTableEnd + NumDataRegions * 8;
981uint64_t DataRegionsOffset = RelocTableEnd;
982uint64_t DataRegionsSize = NumDataRegions * 8;
987// Write the loh load command, if used. 988uint64_t LOHTableEnd = DataInCodeTableEnd + LOHSize;
991 DataInCodeTableEnd, LOHSize);
993// Write the symbol table load command, if used. 995unsigned FirstLocalSymbol = 0;
996unsigned NumLocalSymbols = LocalSymbolData.size();
997unsigned FirstExternalSymbol = FirstLocalSymbol + NumLocalSymbols;
998unsigned NumExternalSymbols = ExternalSymbolData.size();
999unsigned FirstUndefinedSymbol = FirstExternalSymbol + NumExternalSymbols;
1000unsigned NumUndefinedSymbols = UndefinedSymbolData.size();
1001unsigned NumIndirectSymbols = IndirectSymbols.size();
1002unsigned NumSymTabSymbols =
1003 NumLocalSymbols + NumExternalSymbols + NumUndefinedSymbols;
1004uint64_t IndirectSymbolSize = NumIndirectSymbols * 4;
1007// If used, the indirect symbols are written after the section data. 1008if (NumIndirectSymbols)
1009 IndirectSymbolOffset = LOHTableEnd;
1011// The symbol table is written after the indirect symbol data. 1012uint64_t SymbolTableOffset = LOHTableEnd + IndirectSymbolSize;
1014// The string table is written after symbol table. 1016 SymbolTableOffset + NumSymTabSymbols * (
is64Bit() ?
1023 FirstExternalSymbol, NumExternalSymbols,
1024 FirstUndefinedSymbol, NumUndefinedSymbols,
1025 IndirectSymbolOffset, NumIndirectSymbols);
1028// Write the linker options load commands. 1029for (
constauto &Option : LinkerOptions)
1032// Write the actual section data. 1034 Asm.writeSectionData(
W.
OS, &Sec);
1040// Write the extra padding. 1043// Write the relocation entries. 1045// Write the section relocation entries, in reverse order to match 'as' 1046// (approximately, the exact algorithm is more complicated than this). 1047 std::vector<RelAndSymbol> &Relocs = Relocations[&Sec];
1054// Write out the data-in-code region payload, if there is one. 1064 <<
" start: " << Start <<
"(" <<
Data.Start->getName()
1065 <<
")" <<
" end: " <<
End <<
"(" <<
Data.End->getName()
1066 <<
")" <<
" size: " <<
End - Start <<
"\n");
1072// Write out the loh commands, if there is one. 1077 LOHContainer.
emit(Asm, *
this);
1078// Pad to a multiple of the pointer size. 1084// Write the symbol table data, if used. 1086// Write the indirect symbol entries. 1087for (
auto &ISD : IndirectSymbols) {
1088// Indirect symbols in the non-lazy symbol pointer section have some 1093// If this symbol is defined and internal, mark it as such. 1094if (ISD.Symbol->isDefined() && !ISD.Symbol->isExternal()) {
1096if (ISD.Symbol->isAbsolute())
1106// FIXME: Check that offsets match computed ones. 1108// Write the symbol table entries. 1109for (
auto *SymbolData :
1110 {&LocalSymbolData, &ExternalSymbolData, &UndefinedSymbolData})
1111for (MachSymbolData &Entry : *SymbolData)
1114// Write the string table. 1118return NumBytesWritten();
This file defines the DenseMap class.
static unsigned ComputeLinkerOptionsLoadCommandSize(const std::vector< std::string > &Options, bool is64Bit)
static bool isFixupTargetValid(const MCValue &Target)
static MachO::LoadCommandType getLCFromMCVM(MCVersionMinType Type)
static bool isSymbolLinkerVisible(const MCSymbol &Symbol)
PowerPC TLS Dynamic Call Fixup
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool is64Bit(const char *name)
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
static bool isSectionAtomizableBySymbols(const MCSection &Section)
True if the section is atomized using the symbols in it.
Base class for the full range of assembler expressions which are needed for parsing.
bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const
Try to evaluate the expression to a relocatable value, i.e.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
const MCSymbol * getAtom() const
MCSection * getParent() const
void emit(const MCAssembler &Asm, MachObjectWriter &ObjWriter) const
Emit all Linker Optimization Hint in one big table.
uint64_t getEmitSize(const MCAssembler &Asm, const MachObjectWriter &ObjWriter) const
Get the size of the directives if emitted.
SmallVector< CGProfileEntry, 0 > CGProfile
bool SubsectionsViaSymbols
std::vector< const MCSymbol * > & getAddrsigSyms()
virtual void reset()
lifetime management
This represents a section on a Mach-O system (used by Mac OS X).
Instances of this class represent a uniqued identifier for a section in the current translation unit.
bool isVirtualSection() const
Check whether this section is "virtual", that is has no actual object file contents.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const MCExpr * getVariableValue(bool SetUsed=true) const
getVariableValue - Get the value for variable symbols.
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 isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
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".
uint64_t getPaddingSize(const MCAssembler &Asm, const MCSection *SD) const
void computeSectionAddresses(const MCAssembler &Asm)
void writeSection(const MCAssembler &Asm, const MCSection &Sec, uint64_t VMAddr, uint64_t FileOffset, unsigned Flags, uint64_t RelocationsStart, unsigned NumRelocations)
bool doesSymbolRequireExternRelocation(const MCSymbol &S)
void computeSymbolTable(MCAssembler &Asm, std::vector< MachSymbolData > &LocalSymbolData, std::vector< MachSymbolData > &ExternalSymbolData, std::vector< MachSymbolData > &UndefinedSymbolData)
Compute the symbol table data.
uint64_t getFragmentAddress(const MCAssembler &Asm, const MCFragment *Fragment) const
{ bool EmitBuildVersion VersionInfoType
void executePostLayoutBinding(MCAssembler &Asm) override
Perform any late binding of symbols (for example, to assign symbol indices for use when generating re...
uint64_t getSectionAddress(const MCSection *Sec) const
void addRelocation(const MCSymbol *RelSymbol, const MCSection *Sec, MachO::any_relocation_info &MRE)
void populateAddrSigSection(MCAssembler &Asm)
bool isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind)
support::endian::Writer W
void writeLinkerOptionsLoadCommand(const std::vector< std::string > &Options)
void recordRelocation(MCAssembler &Asm, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue) override
Record a relocation entry.
void writeNlist(MachSymbolData &MSD, const MCAssembler &Asm)
VersionTuple SDKVersion
An optional version of the SDK that was used to build the source.
bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const override
void writeDysymtabLoadCommand(uint32_t FirstLocalSymbol, uint32_t NumLocalSymbols, uint32_t FirstExternalSymbol, uint32_t NumExternalSymbols, uint32_t FirstUndefinedSymbol, uint32_t NumUndefinedSymbols, uint32_t IndirectSymbolOffset, uint32_t NumIndirectSymbols)
const MCSymbol & findAliasedSymbol(const MCSymbol &Sym) const
uint64_t getSymbolAddress(const MCSymbol &S, const MCAssembler &Asm) const
MCVersionMinType Type
Used when EmitBuildVersion==false.
void writeSegmentLoadCommand(StringRef Name, unsigned NumSections, uint64_t VMAddr, uint64_t VMSize, uint64_t SectionDataStartOffset, uint64_t SectionDataSize, uint32_t MaxProt, uint32_t InitProt)
Write a segment load command.
const MCSymbol * getAtom(const MCSymbol &S) const
void writeLinkeditLoadCommand(uint32_t Type, uint32_t DataOffset, uint32_t DataSize)
void writeHeader(MachO::HeaderFileType Type, unsigned NumLoadCommands, unsigned LoadCommandsSize, bool SubsectionsViaSymbols)
void reset() override
lifetime management
void writeSymtabLoadCommand(uint32_t SymbolOffset, uint32_t NumSymbols, uint32_t StringTableOffset, uint32_t StringTableSize)
void bindIndirectSymbols(MCAssembler &Asm)
uint64_t writeObject(MCAssembler &Asm) override
Write the object file and returns the number of bytes written.
Represents a location in source code.
static SectionKind getMetadata()
void push_back(const T &Elt)
StringRef - Represent a constant reference to a string, i.e.
A table of densely packed, null-terminated strings indexed by offset.
Target - Wrapper for Target specific information.
const char * getName() const
getName - Get the target name.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
StringRef getName() const
Return a constant reference to the value's name.
Represents a version number in the form major[.minor[.subminor[.build]]].
raw_ostream & write_zeros(unsigned NumZeros)
write_zeros - Insert 'NumZeros' nulls.
uint64_t tell() const
tell - Return the current offset with the file.
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.
@ C
The default llvm calling convention, compatible with C.
@ S_ATTR_SOME_INSTRUCTIONS
S_ATTR_SOME_INSTRUCTIONS - Section contains some machine instructions.
@ S_THREAD_LOCAL_VARIABLE_POINTERS
S_THREAD_LOCAL_VARIABLE_POINTERS - Section with pointers to thread local structures.
@ S_LAZY_SYMBOL_POINTERS
S_LAZY_SYMBOL_POINTERS - Section with lazy symbol pointers.
@ S_NON_LAZY_SYMBOL_POINTERS
S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.
@ S_SYMBOL_STUBS
S_SYMBOL_STUBS - Section with symbol stubs, byte size of stub in the Reserved2 field.
uint32_t CPU_SUBTYPE_ARM64E_WITH_PTRAUTH_VERSION(unsigned PtrAuthABIVersion, bool PtrAuthKernelABIVersion)
@ MH_SUBSECTIONS_VIA_SYMBOLS
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 enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
auto reverse(ContainerTy &&C)
void sort(IteratorTy Start, IteratorTy End)
@ MCVM_WatchOSVersionMin
.watchos_version_min
@ MCVM_OSXVersionMin
.macosx_version_min
@ MCVM_TvOSVersionMin
.tvos_version_min
@ MCVM_IOSVersionMin
.ios_version_min
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
uint64_t offsetToAlignment(uint64_t Value, Align Alignment)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
@ Ref
The access may reference the value stored in memory.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
unsigned Log2(Align A)
Returns the log2 of the alignment.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Target independent information on a fixup kind.
@ FKF_IsPCRel
Is this fixup kind PCrelative? This is used by the assembler backend to evaluate fixup values in a ta...
unsigned Flags
Flags describing additional information on this fixup kind.
void write(ArrayRef< value_type > Val)