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 | |
Protected Member Functions inherited from llvm::MCObjectWriter | |
MCObjectWriter ()=default | |
Protected Attributes inherited from llvm::MCObjectWriter | |
SmallVector< std::pair< std::string, size_t >, 0 > | FileNames |
List of declared file names. | |
std::string | CompilerVersion |
std::vector< const MCSymbol * > | AddrsigSyms |
bool | EmitAddrsigSection = false |
bool | SubsectionsViaSymbols = false |
SmallVector< CGProfileEntry, 0 > | CGProfile |
Definition at line 86 of file MCMachObjectWriter.h.
using llvm::MachObjectWriter::VersionInfoType = { bool EmitBuildVersion |
Definition at line 96 of file MCMachObjectWriter.h.
|
inline |
Definition at line 175 of file MCMachObjectWriter.h.
|
inline |
Definition at line 325 of file MCMachObjectWriter.h.
References P.
Referenced by populateAddrSigSection().
void MachObjectWriter::bindIndirectSymbols | ( | MCAssembler & | Asm | ) |
Definition at line 529 of file MachObjectWriter.cpp.
References llvm::enumerate(), llvm::report_fatal_error(), llvm::MachO::S_LAZY_SYMBOL_POINTERS, llvm::MachO::S_NON_LAZY_SYMBOL_POINTERS, llvm::MachO::S_SYMBOL_STUBS, and llvm::MachO::S_THREAD_LOCAL_VARIABLE_POINTERS.
Referenced by executePostLayoutBinding().
void MachObjectWriter::computeSectionAddresses | ( | const MCAssembler & | Asm | ) |
strictly be necessary.
Definition at line 686 of file MachObjectWriter.cpp.
References llvm::alignTo(), getPaddingSize(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by executePostLayoutBinding().
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 line 586 of file MachObjectWriter.cpp.
References assert(), llvm::support::endian::Writer::Endian, isSymbolLinkerVisible(), llvm::little, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::lookup(), llvm::sort(), and W.
Referenced by writeObject().
Definition at line 65 of file MachObjectWriter.cpp.
References llvm::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 from llvm::MCObjectWriter.
Definition at line 716 of file MachObjectWriter.cpp.
References bindIndirectSymbols(), and computeSectionAddresses().
Definition at line 380 of file MachObjectWriter.cpp.
References llvm::MCSymbol::getVariableValue(), llvm::MCSymbol::isVariable(), llvm::Ref, and Sym.
Referenced by isSymbolRefDifferenceFullyResolvedImpl(), and writeNlist().
Definition at line 155 of file MachObjectWriter.cpp.
References llvm::MCFragment::getAtom(), llvm::MCSymbol::getFragment(), llvm::MCFragment::getParent(), llvm::MCSymbol::isInSection(), llvm::MCAsmInfoDarwin::isSectionAtomizableBySymbols(), and isSymbolLinkerVisible().
|
inline |
Definition at line 202 of file MCMachObjectWriter.h.
uint64_t MachObjectWriter::getFragmentAddress | ( | const MCAssembler & | Asm, |
const MCFragment * | Fragment | ||
) | const |
Definition at line 92 of file MachObjectWriter.cpp.
References llvm::MCFragment::getParent(), and getSectionAddress().
|
inline |
Definition at line 199 of file MCMachObjectWriter.h.
|
inline |
Definition at line 255 of file MCMachObjectWriter.h.
|
inline |
Definition at line 207 of file MCMachObjectWriter.h.
uint64_t MachObjectWriter::getPaddingSize | ( | const MCAssembler & | Asm, |
const MCSection * | SD | ||
) | const |
Definition at line 131 of file MachObjectWriter.cpp.
References llvm::MCSection::getAlign(), getSectionAddress(), llvm::MCSection::isVirtualSection(), llvm::offsetToAlignment(), and llvm::SmallVectorBase< Size_T >::size().
Referenced by computeSectionAddresses(), and writeObject().
Definition at line 209 of file MCMachObjectWriter.h.
Referenced by getFragmentAddress(), getPaddingSize(), getSymbolAddress(), and writeObject().
|
inline |
Definition at line 206 of file MCMachObjectWriter.h.
|
inline |
Definition at line 203 of file MCMachObjectWriter.h.
uint64_t MachObjectWriter::getSymbolAddress | ( | const MCSymbol & | S, |
const MCAssembler & | Asm | ||
) | const |
Definition at line 98 of file MachObjectWriter.cpp.
References llvm::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(), and llvm::report_fatal_error().
Referenced by getSymbolAddress(), writeNlist(), and writeObject().
|
inline |
Definition at line 264 of file MCMachObjectWriter.h.
Referenced by populateAddrSigSection(), writeHeader(), writeLinkerOptionsLoadCommand(), writeNlist(), writeObject(), writeSection(), and writeSegmentLoadCommand().
bool MachObjectWriter::isFixupKindPCRel | ( | const MCAssembler & | Asm, |
unsigned | Kind | ||
) |
Definition at line 84 of file MachObjectWriter.cpp.
References llvm::MCFixupKindInfo::FKF_IsPCRel, and llvm::MCFixupKindInfo::Flags.
|
overridevirtual |
Reimplemented from llvm::MCObjectWriter.
Definition at line 723 of file MachObjectWriter.cpp.
References findAliasedSymbol(), llvm::MCFragment::getAtom(), llvm::MCSymbol::getFragment(), llvm::MCFragment::getParent(), llvm::MCSymbol::getSection(), llvm::MCSymbol::isInSection(), llvm::MCSymbol::isTemporary(), isX86_64(), and llvm::MCObjectWriter::SubsectionsViaSymbols.
|
inline |
Definition at line 265 of file MCMachObjectWriter.h.
References llvm::MachO::CPU_TYPE_X86_64.
Referenced by isSymbolRefDifferenceFullyResolvedImpl().
void MachObjectWriter::populateAddrSigSection | ( | MCAssembler & | Asm | ) |
Definition at line 780 of file MachObjectWriter.cpp.
References addRelocation(), llvm::MachO::GENERIC_RELOC_VANILLA, llvm::MCObjectWriter::getAddrsigSyms(), is64Bit(), llvm::MachO::any_relocation_info::r_word0, and llvm::MachO::any_relocation_info::r_word1.
Referenced by writeObject().
|
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 during writeObject().
Implements llvm::MCObjectWriter.
Definition at line 515 of file MachObjectWriter.cpp.
References Fixup, and isFixupTargetValid().
|
overridevirtual |
lifetime management
Reimplemented from llvm::MCObjectWriter.
Definition at line 45 of file MachObjectWriter.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::MCLOHContainer::reset(), and llvm::MCObjectWriter::reset().
|
inline |
Definition at line 234 of file MCMachObjectWriter.h.
References Major, Minor, Platform, SDKVersion, and Update.
|
inline |
Definition at line 244 of file MCMachObjectWriter.h.
References Major, Minor, Platform, SDKVersion, and Update.
|
inline |
Mach-O deployment target version information.
Definition at line 224 of file MCMachObjectWriter.h.
References Major, Minor, SDKVersion, Type, and Update.
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 line 332 of file MachObjectWriter.cpp.
References assert(), llvm::support::endian::Writer::OS, llvm::raw_ostream::tell(), W, and llvm::support::endian::Writer::write().
Referenced by writeObject().
void MachObjectWriter::writeHeader | ( | MachO::HeaderFileType | Type, |
unsigned | NumLoadCommands, | ||
unsigned | LoadCommandsSize, | ||
bool | SubsectionsViaSymbols | ||
) |
Definition at line 174 of file MachObjectWriter.cpp.
References assert(), 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, and llvm::support::endian::Writer::write().
Referenced by writeObject().
void MachObjectWriter::writeLinkeditLoadCommand | ( | uint32_t | Type, |
uint32_t | DataOffset, | ||
uint32_t | DataSize | ||
) |
Definition at line 460 of file MachObjectWriter.cpp.
References assert(), llvm::support::endian::Writer::OS, llvm::raw_ostream::tell(), Type, W, and llvm::support::endian::Writer::write().
Referenced by writeObject().
void MachObjectWriter::writeLinkerOptionsLoadCommand | ( | const std::vector< std::string > & | Options | ) |
Definition at line 483 of file MachObjectWriter.cpp.
References assert(), ComputeLinkerOptionsLoadCommandSize(), is64Bit(), llvm::offsetToAlignment(), Options, llvm::support::endian::Writer::OS, Size, llvm::raw_ostream::tell(), W, llvm::support::endian::Writer::write(), and llvm::raw_ostream::write_zeros().
Referenced by writeObject().
void MachObjectWriter::writeNlist | ( | MachSymbolData & | MSD, |
const MCAssembler & | Asm | ||
) |
Definition at line 392 of file MachObjectWriter.cpp.
References llvm::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, and llvm::support::endian::Writer::write().
Referenced by writeObject().
|
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.
Implements llvm::MCObjectWriter.
Definition at line 794 of file MachObjectWriter.cpp.
References llvm::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(), and writeSymtabLoadCommand().
void MachObjectWriter::writeSection | ( | const MCAssembler & | Asm, |
const MCSection & | Sec, | ||
uint64_t | VMAddr, | ||
uint64_t | FileOffset, | ||
unsigned | Flags, | ||
uint64_t | RelocationsStart, | ||
unsigned | NumRelocations | ||
) |
Definition at line 266 of file MachObjectWriter.cpp.
References assert(), is64Bit(), llvm::Log2(), llvm::support::endian::Writer::OS, llvm::raw_ostream::tell(), W, and llvm::support::endian::Writer::write().
Referenced by writeObject().
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 line 226 of file MachObjectWriter.cpp.
References assert(), is64Bit(), Name, llvm::support::endian::Writer::OS, llvm::raw_ostream::tell(), W, and llvm::support::endian::Writer::write().
Referenced by writeObject().
void MachObjectWriter::writeSymtabLoadCommand | ( | uint32_t | SymbolOffset, |
uint32_t | NumSymbols, | ||
uint32_t | StringTableOffset, | ||
uint32_t | StringTableSize | ||
) |
Definition at line 313 of file MachObjectWriter.cpp.
References assert(), llvm::support::endian::Writer::OS, llvm::raw_ostream::tell(), W, and llvm::support::endian::Writer::write().
Referenced by writeObject().
unsigned llvm::MachObjectWriter::Major |
Definition at line 102 of file MCMachObjectWriter.h.
Referenced by setBuildVersion(), setTargetVariantBuildVersion(), and setVersionMin().
unsigned llvm::MachObjectWriter::Minor |
Definition at line 103 of file MCMachObjectWriter.h.
Referenced by setBuildVersion(), setTargetVariantBuildVersion(), setVersionMin(), and writeObject().
MachO::PlatformType llvm::MachObjectWriter::Platform |
Used when EmitBuildVersion==true.
Definition at line 100 of file MCMachObjectWriter.h.
Referenced by setBuildVersion(), and setTargetVariantBuildVersion().
VersionTuple llvm::MachObjectWriter::SDKVersion |
An optional version of the SDK that was used to build the source.
Definition at line 106 of file MCMachObjectWriter.h.
Referenced by setBuildVersion(), setTargetVariantBuildVersion(), setVersionMin(), and writeObject().
MCVersionMinType llvm::MachObjectWriter::Type |
Used when EmitBuildVersion==false.
Definition at line 99 of file MCMachObjectWriter.h.
Referenced by setVersionMin(), writeHeader(), and writeLinkeditLoadCommand().
union { ... } llvm::MachObjectWriter::TypeOrPlatform |
unsigned llvm::MachObjectWriter::Update |
Definition at line 104 of file MCMachObjectWriter.h.
Referenced by setBuildVersion(), setTargetVariantBuildVersion(), setVersionMin(), and writeObject().
support::endian::Writer llvm::MachObjectWriter::W |
Definition at line 183 of file MCMachObjectWriter.h.
Referenced by computeSymbolTable(), llvm::MCLOHDirective::emit(), writeDysymtabLoadCommand(), writeHeader(), writeLinkeditLoadCommand(), writeLinkerOptionsLoadCommand(), writeNlist(), writeObject(), writeSection(), writeSegmentLoadCommand(), and writeSymtabLoadCommand().