LLVM 20.0.0git |
#include "llvm/MC/MCMachObjectWriter.h"
Classes | |
struct | DataRegionData |
Public Types | |
using | VersionInfoType = {bool EmitBuildVersion |
Public Attributes | |
union { | |
MCVersionMinType Type | |
Used when EmitBuildVersion==false.More... | |
MachO::PlatformType Platform | |
Used when EmitBuildVersion==true.More... | |
} | TypeOrPlatform |
unsigned | Major |
unsigned | Minor |
unsigned | Update |
VersionTuple | SDKVersion |
An optional version of the SDK that was used to build the source. | |
support::endian::Writer | W |
Additional Inherited Members | |
![]() | |
MCObjectWriter ()=default | |
![]() | |
SmallVector< std::pair< std::string, size_t >, 0 > | FileNames |
List of declared file names. | |
std::string | CompilerVersion |
std::vector<constMCSymbol * > | AddrsigSyms |
bool | EmitAddrsigSection = false |
bool | SubsectionsViaSymbols = false |
SmallVector<CGProfileEntry, 0 > | CGProfile |
Definition at line86 of fileMCMachObjectWriter.h.
usingllvm::MachObjectWriter::VersionInfoType = {bool EmitBuildVersion |
Definition at line96 of fileMCMachObjectWriter.h.
| inline |
Definition at line175 of fileMCMachObjectWriter.h.
| inline |
Definition at line325 of fileMCMachObjectWriter.h.
ReferencesP.
Referenced bypopulateAddrSigSection().
void MachObjectWriter::bindIndirectSymbols | ( | MCAssembler & | Asm | ) |
Definition at line529 of fileMachObjectWriter.cpp.
Referencesllvm::enumerate(),llvm::report_fatal_error(),llvm::MachO::S_LAZY_SYMBOL_POINTERS,llvm::MachO::S_NON_LAZY_SYMBOL_POINTERS,llvm::MachO::S_SYMBOL_STUBS, andllvm::MachO::S_THREAD_LOCAL_VARIABLE_POINTERS.
Referenced byexecutePostLayoutBinding().
void MachObjectWriter::computeSectionAddresses | ( | constMCAssembler & | Asm | ) |
strictly be necessary.
Definition at line686 of fileMachObjectWriter.cpp.
Referencesllvm::alignTo(),getPaddingSize(), andllvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced byexecutePostLayoutBinding().
void MachObjectWriter::computeSymbolTable | ( | MCAssembler & | Asm, |
std::vector< MachSymbolData > & | LocalSymbolData, | ||
std::vector< MachSymbolData > & | ExternalSymbolData, | ||
std::vector< MachSymbolData > & | UndefinedSymbolData | ||
) |
Compute the symbol table data.
computeSymbolTable - Compute the symbol table data
Definition at line586 of fileMachObjectWriter.cpp.
Referencesassert(),llvm::support::endian::Writer::Endian,isSymbolLinkerVisible(),llvm::little,llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::lookup(),llvm::sort(), andW.
Referenced bywriteObject().
Definition at line65 of fileMachObjectWriter.cpp.
Referencesllvm::MCSymbol::isUndefined().
| overridevirtual |
Perform any late binding of symbols (for example, to assign symbol indices for use when generating relocations).
This routine is called by the assembler after layout and relaxation is complete.
Reimplemented fromllvm::MCObjectWriter.
Definition at line716 of fileMachObjectWriter.cpp.
ReferencesbindIndirectSymbols(), andcomputeSectionAddresses().
Definition at line380 of fileMachObjectWriter.cpp.
Referencesllvm::MCSymbol::getVariableValue(),llvm::MCSymbol::isVariable(),llvm::Ref, andSym.
Referenced byisSymbolRefDifferenceFullyResolvedImpl(), andwriteNlist().
| inline |
Definition at line202 of fileMCMachObjectWriter.h.
uint64_t MachObjectWriter::getFragmentAddress | ( | constMCAssembler & | Asm, |
constMCFragment * | Fragment | ||
) | const |
Definition at line92 of fileMachObjectWriter.cpp.
Referencesllvm::MCFragment::getParent(), andgetSectionAddress().
| inline |
Definition at line199 of fileMCMachObjectWriter.h.
| inline |
Definition at line255 of fileMCMachObjectWriter.h.
| inline |
Definition at line207 of fileMCMachObjectWriter.h.
uint64_t MachObjectWriter::getPaddingSize | ( | constMCAssembler & | Asm, |
constMCSection * | SD | ||
) | const |
Definition at line131 of fileMachObjectWriter.cpp.
Referencesllvm::MCSection::getAlign(),getSectionAddress(),llvm::MCSection::isVirtualSection(),llvm::offsetToAlignment(), andllvm::SmallVectorBase< Size_T >::size().
Referenced bycomputeSectionAddresses(), andwriteObject().
Definition at line209 of fileMCMachObjectWriter.h.
Referenced bygetFragmentAddress(),getPaddingSize(),getSymbolAddress(), andwriteObject().
| inline |
Definition at line206 of fileMCMachObjectWriter.h.
| inline |
Definition at line203 of fileMCMachObjectWriter.h.
uint64_t MachObjectWriter::getSymbolAddress | ( | constMCSymbol & | S, |
constMCAssembler & | Asm | ||
) | const |
Definition at line98 of fileMachObjectWriter.cpp.
Referencesllvm::Address,llvm::CallingConv::C,llvm::MCExpr::evaluateAsRelocatable(),llvm::MCSymbol::getFragment(),llvm::MCSymbol::getName(),llvm::Target::getName(),llvm::MCFragment::getParent(),getSectionAddress(),getSymbolAddress(),llvm::MCSymbol::getVariableValue(),llvm::MCSymbol::isVariable(), andllvm::report_fatal_error().
Referenced bygetSymbolAddress(),writeNlist(), andwriteObject().
| inline |
Definition at line264 of fileMCMachObjectWriter.h.
Referenced bypopulateAddrSigSection(),writeHeader(),writeLinkerOptionsLoadCommand(),writeNlist(),writeObject(),writeSection(), andwriteSegmentLoadCommand().
bool MachObjectWriter::isFixupKindPCRel | ( | constMCAssembler & | Asm, |
unsigned | Kind | ||
) |
Definition at line84 of fileMachObjectWriter.cpp.
Referencesllvm::MCFixupKindInfo::FKF_IsPCRel, andllvm::MCFixupKindInfo::Flags.
| overridevirtual |
Reimplemented fromllvm::MCObjectWriter.
Definition at line723 of fileMachObjectWriter.cpp.
ReferencesfindAliasedSymbol(),llvm::MCFragment::getAtom(),llvm::MCSymbol::getFragment(),llvm::MCFragment::getParent(),llvm::MCSymbol::getSection(),llvm::MCSymbol::isInSection(),llvm::MCSymbol::isTemporary(),isX86_64(), andllvm::MCObjectWriter::SubsectionsViaSymbols.
| inline |
Definition at line265 of fileMCMachObjectWriter.h.
Referencesllvm::MachO::CPU_TYPE_X86_64.
Referenced byisSymbolRefDifferenceFullyResolvedImpl().
void MachObjectWriter::populateAddrSigSection | ( | MCAssembler & | Asm | ) |
Definition at line780 of fileMachObjectWriter.cpp.
ReferencesaddRelocation(),llvm::MachO::GENERIC_RELOC_VANILLA,llvm::MCObjectWriter::getAddrsigSyms(),is64Bit(),llvm::MachO::any_relocation_info::r_word0, andllvm::MachO::any_relocation_info::r_word1.
Referenced bywriteObject().
| overridevirtual |
Record a relocation entry.
This routine is called by the assembler after layout and relaxation, and post layout binding. The implementation is responsible for storing information about the relocation so that it can be emitted duringwriteObject().
Implementsllvm::MCObjectWriter.
Definition at line515 of fileMachObjectWriter.cpp.
ReferencesFixup, andisFixupTargetValid().
| overridevirtual |
lifetime management
Reimplemented fromllvm::MCObjectWriter.
Definition at line45 of fileMachObjectWriter.cpp.
Referencesllvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(),llvm::SmallVectorImpl< T >::clear(),llvm::MCLOHContainer::reset(), andllvm::MCObjectWriter::reset().
| inline |
Definition at line234 of fileMCMachObjectWriter.h.
ReferencesMajor,Minor,Platform,SDKVersion, andUpdate.
| inline |
Definition at line244 of fileMCMachObjectWriter.h.
ReferencesMajor,Minor,Platform,SDKVersion, andUpdate.
| inline |
Mach-O deployment target version information.
Definition at line224 of fileMCMachObjectWriter.h.
ReferencesMajor,Minor,SDKVersion,Type, andUpdate.
void MachObjectWriter::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 | ||
) |
Definition at line332 of fileMachObjectWriter.cpp.
Referencesassert(),llvm::support::endian::Writer::OS,llvm::raw_ostream::tell(),W, andllvm::support::endian::Writer::write().
Referenced bywriteObject().
void MachObjectWriter::writeHeader | ( | MachO::HeaderFileType | Type, |
unsigned | NumLoadCommands, | ||
unsigned | LoadCommandsSize, | ||
bool | SubsectionsViaSymbols | ||
) |
Definition at line174 of fileMachObjectWriter.cpp.
Referencesassert(),llvm::MachO::CPU_SUBTYPE_ARM64E,llvm::MachO::CPU_SUBTYPE_ARM64E_WITH_PTRAUTH_VERSION(),llvm::MachO::CPU_TYPE_ARM64,is64Bit(),llvm::MachO::MH_MAGIC,llvm::MachO::MH_MAGIC_64,llvm::MachO::MH_SUBSECTIONS_VIA_SYMBOLS,llvm::support::endian::Writer::OS,llvm::MCObjectWriter::SubsectionsViaSymbols,llvm::raw_ostream::tell(),Type,W, andllvm::support::endian::Writer::write().
Referenced bywriteObject().
void MachObjectWriter::writeLinkeditLoadCommand | ( | uint32_t | Type, |
uint32_t | DataOffset, | ||
uint32_t | DataSize | ||
) |
Definition at line460 of fileMachObjectWriter.cpp.
Referencesassert(),llvm::support::endian::Writer::OS,llvm::raw_ostream::tell(),Type,W, andllvm::support::endian::Writer::write().
Referenced bywriteObject().
void MachObjectWriter::writeLinkerOptionsLoadCommand | ( | const std::vector< std::string > & | Options | ) |
Definition at line483 of fileMachObjectWriter.cpp.
Referencesassert(),ComputeLinkerOptionsLoadCommandSize(),is64Bit(),llvm::offsetToAlignment(),Options,llvm::support::endian::Writer::OS,Size,llvm::raw_ostream::tell(),W,llvm::support::endian::Writer::write(), andllvm::raw_ostream::write_zeros().
Referenced bywriteObject().
void MachObjectWriter::writeNlist | ( | MachSymbolData & | MSD, |
constMCAssembler & | Asm | ||
) |
Definition at line392 of fileMachObjectWriter.cpp.
Referencesllvm::Address,llvm::Data,findAliasedSymbol(),getSymbolAddress(),is64Bit(),llvm::MachO::N_ABS,llvm::MachO::N_EXT,llvm::MachO::N_INDR,llvm::MachO::N_PEXT,llvm::MachO::N_SECT,llvm::MachO::N_UNDF,llvm::support::endian::Writer::OS,W, andllvm::support::endian::Writer::write().
Referenced bywriteObject().
| overridevirtual |
Write the object file and returns the number of bytes written.
This routine is called by the assembler after layout and relaxation is complete, fixups have been evaluated and applied, and relocations generated.
Implementsllvm::MCObjectWriter.
Definition at line794 of fileMachObjectWriter.cpp.
Referencesllvm::Address,llvm::alignTo(),assert(),llvm::MCSection::begin(),llvm::MCObjectWriter::CGProfile,ComputeLinkerOptionsLoadCommandSize(),computeSymbolTable(),llvm::Data,llvm::dbgs(),llvm::MCLOHContainer::emit(),End,llvm::support::endian::Writer::Endian,llvm::MCLOHContainer::getEmitSize(),getLCFromMCVM(),llvm::SectionKind::getMetadata(),getPaddingSize(),getSectionAddress(),getSymbolAddress(),llvm::MachO::INDIRECT_SYMBOL_ABS,llvm::MachO::INDIRECT_SYMBOL_LOCAL,is64Bit(),LLVM_DEBUG,llvm::MachO::MH_OBJECT,Minor,llvm::offsetToAlignment(),llvm::support::endian::Writer::OS,OS,populateAddrSigSection(),llvm::report_fatal_error(),llvm::reverse(),llvm::MachO::S_ATTR_SOME_INSTRUCTIONS,llvm::MachO::S_NON_LAZY_SYMBOL_POINTERS,SDKVersion,Size,llvm::MCObjectWriter::SubsectionsViaSymbols,llvm::raw_ostream::tell(),Update,llvm::MachO::VM_PROT_EXECUTE,llvm::MachO::VM_PROT_READ,llvm::MachO::VM_PROT_WRITE,W,llvm::support::endian::Writer::write(),llvm::support::endian::write(),llvm::raw_ostream::write_zeros(),writeDysymtabLoadCommand(),writeHeader(),writeLinkeditLoadCommand(),writeLinkerOptionsLoadCommand(),writeNlist(),writeSection(),writeSegmentLoadCommand(), andwriteSymtabLoadCommand().
void MachObjectWriter::writeSection | ( | constMCAssembler & | Asm, |
constMCSection & | Sec, | ||
uint64_t | VMAddr, | ||
uint64_t | FileOffset, | ||
unsigned | Flags, | ||
uint64_t | RelocationsStart, | ||
unsigned | NumRelocations | ||
) |
Definition at line266 of fileMachObjectWriter.cpp.
Referencesassert(),is64Bit(),llvm::Log2(),llvm::support::endian::Writer::OS,llvm::raw_ostream::tell(),W, andllvm::support::endian::Writer::write().
Referenced bywriteObject().
void MachObjectWriter::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.
writeSegmentLoadCommand - Write a segment load command.
NumSections | The number of sections in this segment. |
SectionDataSize | The total size of the sections. |
Definition at line226 of fileMachObjectWriter.cpp.
Referencesassert(),is64Bit(),Name,llvm::support::endian::Writer::OS,llvm::raw_ostream::tell(),W, andllvm::support::endian::Writer::write().
Referenced bywriteObject().
void MachObjectWriter::writeSymtabLoadCommand | ( | uint32_t | SymbolOffset, |
uint32_t | NumSymbols, | ||
uint32_t | StringTableOffset, | ||
uint32_t | StringTableSize | ||
) |
Definition at line313 of fileMachObjectWriter.cpp.
Referencesassert(),llvm::support::endian::Writer::OS,llvm::raw_ostream::tell(),W, andllvm::support::endian::Writer::write().
Referenced bywriteObject().
unsigned llvm::MachObjectWriter::Major |
Definition at line102 of fileMCMachObjectWriter.h.
Referenced bysetBuildVersion(),setTargetVariantBuildVersion(), andsetVersionMin().
unsigned llvm::MachObjectWriter::Minor |
Definition at line103 of fileMCMachObjectWriter.h.
Referenced bysetBuildVersion(),setTargetVariantBuildVersion(),setVersionMin(), andwriteObject().
MachO::PlatformType llvm::MachObjectWriter::Platform |
Used when EmitBuildVersion==true.
Definition at line100 of fileMCMachObjectWriter.h.
Referenced bysetBuildVersion(), andsetTargetVariantBuildVersion().
VersionTuple llvm::MachObjectWriter::SDKVersion |
An optional version of the SDK that was used to build the source.
Definition at line106 of fileMCMachObjectWriter.h.
Referenced bysetBuildVersion(),setTargetVariantBuildVersion(),setVersionMin(), andwriteObject().
MCVersionMinType llvm::MachObjectWriter::Type |
Used when EmitBuildVersion==false.
Definition at line99 of fileMCMachObjectWriter.h.
Referenced bysetVersionMin(),writeHeader(), andwriteLinkeditLoadCommand().
union { ... } llvm::MachObjectWriter::TypeOrPlatform |
unsigned llvm::MachObjectWriter::Update |
Definition at line104 of fileMCMachObjectWriter.h.
Referenced bysetBuildVersion(),setTargetVariantBuildVersion(),setVersionMin(), andwriteObject().
support::endian::Writer llvm::MachObjectWriter::W |
Definition at line183 of fileMCMachObjectWriter.h.
Referenced bycomputeSymbolTable(),llvm::MCLOHDirective::emit(),writeDysymtabLoadCommand(),writeHeader(),writeLinkeditLoadCommand(),writeLinkerOptionsLoadCommand(),writeNlist(),writeObject(),writeSection(),writeSegmentLoadCommand(), andwriteSymtabLoadCommand().