LLVM API Documentation

Classes | Public Member Functions
llvm::MachObjectWriter Class Reference

#include <MCMachObjectWriter.h>

Inheritance diagram for llvm::MachObjectWriter:
Inheritance graph
[legend]
Collaboration diagram for llvm::MachObjectWriter:
Collaboration graph
[legend]

List of all members.

Classes

struct  MachSymbolData

Public Member Functions

 MachObjectWriter (MCMachObjectTargetWriter *MOTW, raw_ostream &_OS, bool _IsLittleEndian)
void WriteHeader (unsigned NumLoadCommands, unsigned LoadCommandsSize, bool SubsectionsViaSymbols)
void WriteSegmentLoadCommand (unsigned NumSections, uint64_t VMSize, uint64_t SectionDataStartOffset, uint64_t SectionDataSize)
void WriteSection (const MCAssembler &Asm, const MCAsmLayout &Layout, const MCSectionData &SD, uint64_t FileOffset, uint64_t RelocationsStart, unsigned NumRelocations)
void WriteSymtabLoadCommand (uint32_t SymbolOffset, uint32_t NumSymbols, uint32_t StringTableOffset, uint32_t StringTableSize)
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)
void WriteNlist (MachSymbolData &MSD, const MCAsmLayout &Layout)
void WriteLinkeditLoadCommand (uint32_t Type, uint32_t DataOffset, uint32_t DataSize)
void WriteLinkerOptionsLoadCommand (const std::vector< std::string > &Options)
void addRelocation (const MCSectionData *SD, MachO::any_relocation_info &MRE)
void RecordScatteredRelocation (const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, unsigned Log2Size, uint64_t &FixedValue)
void RecordTLVPRelocation (const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue)
void RecordRelocation (const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, bool &IsPCRel, uint64_t &FixedValue) override
 Record a relocation entry.
void BindIndirectSymbols (MCAssembler &Asm)
void ComputeSymbolTable (MCAssembler &Asm, SmallString< 256 > &StringTable, std::vector< MachSymbolData > &LocalSymbolData, std::vector< MachSymbolData > &ExternalSymbolData, std::vector< MachSymbolData > &UndefinedSymbolData)
void computeSectionAddresses (const MCAssembler &Asm, const MCAsmLayout &Layout)
void markAbsoluteVariableSymbols (MCAssembler &Asm, const MCAsmLayout &Layout)
void ExecutePostLayoutBinding (MCAssembler &Asm, const MCAsmLayout &Layout) override
 Perform any late binding of symbols (for example, to assign symbol indices for use when generating relocations).
bool IsSymbolRefDifferenceFullyResolvedImpl (const MCAssembler &Asm, const MCSymbolData &DataA, const MCFragment &FB, bool InSet, bool IsPCRel) const override
void WriteObject (MCAssembler &Asm, const MCAsmLayout &Layout) override
 Write the object file.
Lifetime management Methods
void reset () override
 lifetime management
Target Writer Proxy Accessors
bool is64Bit () const
bool isX86_64 () const

Utility Methods

SectionAddrMap SectionAddress
bool isFixupKindPCRel (const MCAssembler &Asm, unsigned Kind)
SectionAddrMapgetSectionAddressMap ()
uint64_t getSectionAddress (const MCSectionData *SD) const
uint64_t getSymbolAddress (const MCSymbolData *SD, const MCAsmLayout &Layout) const
uint64_t getFragmentAddress (const MCFragment *Fragment, const MCAsmLayout &Layout) const
uint64_t getPaddingSize (const MCSectionData *SD, const MCAsmLayout &Layout) const
bool doesSymbolRequireExternRelocation (const MCSymbolData *SD)

Detailed Description

Definition at line 81 of file MCMachObjectWriter.h.


Constructor & Destructor Documentation

llvm::MachObjectWriter::MachObjectWriter ( MCMachObjectTargetWriter MOTW,
raw_ostream _OS,
bool  _IsLittleEndian 
) [inline]

Definition at line 115 of file MCMachObjectWriter.h.


Member Function Documentation

Definition at line 213 of file MCMachObjectWriter.h.

void MachObjectWriter::ComputeSymbolTable ( MCAssembler Asm,
SmallString< 256 > &  StringTable,
std::vector< MachSymbolData > &  LocalSymbolData,
std::vector< MachSymbolData > &  ExternalSymbolData,
std::vector< MachSymbolData > &  UndefinedSymbolData 
)

ComputeSymbolTable - Compute the symbol table data

Parameters:
StringTable[out] - The string table data.

ComputeSymbolTable - Compute the symbol table data

Parameters:
StringTable[out] - The string table data.
StringIndexMap[out] - Map from symbol names to offsets in the string table.

Definition at line 533 of file MachObjectWriter.cpp.

References llvm::MCAssembler::begin(), llvm::MCAssembler::end(), llvm::MCSymbol::getName(), llvm::MCSymbol::getSection(), llvm::MCSymbol::isAbsolute(), llvm::MCAssembler::isSymbolLinkerVisible(), llvm::MCSymbol::isUndefined(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT >, KeyT, ValueT, KeyInfoT >::lookup(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::ARMBuildAttrs::Symbol, and llvm::MCAssembler::symbols().

Referenced by ExecutePostLayoutBinding().

void MachObjectWriter::ExecutePostLayoutBinding ( MCAssembler Asm,
const MCAsmLayout Layout 
) [override, virtual]

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.

Implements llvm::MCObjectWriter.

Definition at line 674 of file MachObjectWriter.cpp.

References BindIndirectSymbols(), computeSectionAddresses(), ComputeSymbolTable(), and markAbsoluteVariableSymbols().

uint64_t MachObjectWriter::getFragmentAddress ( const MCFragment Fragment,
const MCAsmLayout Layout 
) const
uint64_t MachObjectWriter::getPaddingSize ( const MCSectionData SD,
const MCAsmLayout Layout 
) const

Definition at line 134 of file MCMachObjectWriter.h.

uint64_t MachObjectWriter::getSymbolAddress ( const MCSymbolData SD,
const MCAsmLayout Layout 
) const
bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl ( const MCAssembler Asm,
const MCSymbolData DataA,
const MCFragment FB,
bool  InSet,
bool  IsPCRel 
) const [override, virtual]

Definition at line 156 of file MCMachObjectWriter.h.

Referenced by IsSymbolRefDifferenceFullyResolvedImpl().

void MachObjectWriter::RecordRelocation ( const MCAssembler Asm,
const MCAsmLayout Layout,
const MCFragment Fragment,
const MCFixup Fixup,
MCValue  Target,
bool IsPCRel,
uint64_t &  FixedValue 
) [override, virtual]

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 452 of file MachObjectWriter.cpp.

void llvm::MachObjectWriter::RecordScatteredRelocation ( const MCAssembler Asm,
const MCAsmLayout Layout,
const MCFragment Fragment,
const MCFixup Fixup,
MCValue  Target,
unsigned  Log2Size,
uint64_t &  FixedValue 
)
void llvm::MachObjectWriter::RecordTLVPRelocation ( const MCAssembler Asm,
const MCAsmLayout Layout,
const MCFragment Fragment,
const MCFixup Fixup,
MCValue  Target,
uint64_t &  FixedValue 
)
void MachObjectWriter::reset ( ) [override, virtual]
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 
)
void MachObjectWriter::WriteHeader ( unsigned  NumLoadCommands,
unsigned  LoadCommandsSize,
bool  SubsectionsViaSymbols 
)
void MachObjectWriter::WriteLinkeditLoadCommand ( uint32_t  Type,
uint32_t  DataOffset,
uint32_t  DataSize 
)
void MachObjectWriter::WriteLinkerOptionsLoadCommand ( const std::vector< std::string > &  Options)
void MachObjectWriter::WriteNlist ( MachSymbolData &  MSD,
const MCAsmLayout Layout 
)
void MachObjectWriter::WriteObject ( MCAssembler Asm,
const MCAsmLayout Layout 
) [override, virtual]

Write the object file.

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 770 of file MachObjectWriter.cpp.

References llvm::MCAssembler::begin(), ComputeLinkerOptionsLoadCommandSize(), llvm::MCAssembler::data_region_begin(), llvm::MCAssembler::data_region_end(), llvm::dbgs(), DEBUG, llvm::MCLOHContainer::Emit(), llvm::DataRegionData::End, llvm::MCAssembler::end(), llvm::MCAsmLayout::getAssembler(), llvm::MCAssembler::getDataRegions(), llvm::MCLOHContainer::getEmitSize(), llvm::MCSymbolData::getIndex(), llvm::MCAssembler::getLinkerOptions(), llvm::MCAssembler::getLOHContainer(), llvm::MCSymbol::getName(), getPaddingSize(), llvm::MCSectionData::getSection(), getSectionAddress(), llvm::MCAsmLayout::getSectionAddressSize(), llvm::MCAsmLayout::getSectionFileSize(), llvm::MCAssembler::getSubsectionsViaSymbols(), getSymbolAddress(), llvm::MCAssembler::getSymbolData(), llvm::MCSectionMachO::getType(), llvm::MCAssembler::getVersionMinInfo(), llvm::MachO::INDIRECT_SYMBOL_ABS, llvm::MCAssembler::indirect_symbol_begin(), llvm::MCAssembler::indirect_symbol_end(), llvm::MachO::INDIRECT_SYMBOL_LOCAL, llvm::MCAssembler::indirect_symbol_size(), is64Bit(), llvm::MCSymbolData::isExternal(), llvm::MCSection::isVirtualSection(), llvm::DataRegionData::Kind, llvm::MCAssembler::VersionMinInfoType::Kind, llvm::MachO::LC_DATA_IN_CODE, llvm::MachO::LC_LINKER_OPTIMIZATION_HINT, llvm::MachO::LC_VERSION_MIN_IPHONEOS, llvm::MachO::LC_VERSION_MIN_MACOSX, llvm::MCAssembler::VersionMinInfoType::Major, llvm::MCVM_OSXVersionMin, llvm::MCAssembler::VersionMinInfoType::Minor, llvm::OffsetToAlignment(), llvm::MCObjectWriter::OS, llvm::RoundUpToAlignment(), llvm::MachO::S_NON_LAZY_SYMBOL_POINTERS, llvm::ARMBuildAttrs::Section, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::size(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::MCAssembler::size(), llvm::DataRegionData::Start, llvm::SmallString< InternalLen >::str(), llvm::raw_ostream::tell(), llvm::MCAssembler::VersionMinInfoType::Update, llvm::MCObjectWriter::Write16(), llvm::MCObjectWriter::Write32(), llvm::MCObjectWriter::Write8(), llvm::MCObjectWriter::WriteBytes(), WriteDysymtabLoadCommand(), WriteHeader(), WriteLinkeditLoadCommand(), WriteLinkerOptionsLoadCommand(), WriteNlist(), WriteSection(), llvm::MCAssembler::writeSectionData(), WriteSegmentLoadCommand(), WriteSymtabLoadCommand(), and llvm::MCObjectWriter::WriteZeros().

void MachObjectWriter::WriteSection ( const MCAssembler Asm,
const MCAsmLayout Layout,
const MCSectionData SD,
uint64_t  FileOffset,
uint64_t  RelocationsStart,
unsigned  NumRelocations 
)
void MachObjectWriter::WriteSegmentLoadCommand ( unsigned  NumSections,
uint64_t  VMSize,
uint64_t  SectionDataStartOffset,
uint64_t  SectionDataSize 
)

WriteSegmentLoadCommand - Write a segment load command.

Parameters:
NumSectionsThe number of sections in this segment.
SectionDataSizeThe total size of the sections.

Definition at line 160 of file MachObjectWriter.cpp.

References is64Bit(), llvm::MachO::LC_SEGMENT, llvm::MachO::LC_SEGMENT_64, llvm::MCObjectWriter::OS, llvm::raw_ostream::tell(), llvm::MachO::VM_PROT_EXECUTE, llvm::MachO::VM_PROT_READ, llvm::MachO::VM_PROT_WRITE, llvm::MCObjectWriter::Write32(), llvm::MCObjectWriter::Write64(), and llvm::MCObjectWriter::WriteBytes().

Referenced by WriteObject().

void MachObjectWriter::WriteSymtabLoadCommand ( uint32_t  SymbolOffset,
uint32_t  NumSymbols,
uint32_t  StringTableOffset,
uint32_t  StringTableSize 
)

Member Data Documentation

Definition at line 132 of file MCMachObjectWriter.h.

Referenced by computeSectionAddresses(), and getSectionAddress().


The documentation for this class was generated from the following files: