LLVM  3.7.0
Classes | Public Member Functions | List of all members
llvm::MachObjectWriter Class Reference

#include <MCMachObjectWriter.h>

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

Public Member Functions

 MachObjectWriter (MCMachObjectTargetWriter *MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
 
const MCSymbolfindAliasedSymbol (const MCSymbol &Sym) const
 
void writeHeader (unsigned NumLoadCommands, unsigned LoadCommandsSize, bool SubsectionsViaSymbols)
 
void writeSegmentLoadCommand (unsigned NumSections, uint64_t VMSize, uint64_t SectionDataStartOffset, uint64_t SectionDataSize)
 Write a segment load command. More...
 
void writeSection (const MCAssembler &Asm, const MCAsmLayout &Layout, const MCSection &Sec, 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 MCSymbol *RelSymbol, const MCSection *Sec, 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 (MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, bool &IsPCRel, uint64_t &FixedValue) override
 Record a relocation entry. More...
 
void bindIndirectSymbols (MCAssembler &Asm)
 
void computeSymbolTable (MCAssembler &Asm, std::vector< MachSymbolData > &LocalSymbolData, std::vector< MachSymbolData > &ExternalSymbolData, std::vector< MachSymbolData > &UndefinedSymbolData)
 Compute the symbol table data. More...
 
void computeSectionAddresses (const 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). More...
 
bool isSymbolRefDifferenceFullyResolvedImpl (const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const override
 
void writeObject (MCAssembler &Asm, const MCAsmLayout &Layout) override
 Write the object file. More...
 
Lifetime management Methods
void reset () override
 lifetime management More...
 
Utility Methods
bool isFixupKindPCRel (const MCAssembler &Asm, unsigned Kind)
 
SectionAddrMapgetSectionAddressMap ()
 
uint64_t getSectionAddress (const MCSection *Sec) const
 
uint64_t getSymbolAddress (const MCSymbol &S, const MCAsmLayout &Layout) const
 
uint64_t getFragmentAddress (const MCFragment *Fragment, const MCAsmLayout &Layout) const
 
uint64_t getPaddingSize (const MCSection *SD, const MCAsmLayout &Layout) const
 
bool doesSymbolRequireExternRelocation (const MCSymbol &S)
 
Target Writer Proxy Accessors
bool is64Bit () const
 
bool isX86_64 () const
 
- Public Member Functions inherited from llvm::MCObjectWriter
virtual ~MCObjectWriter ()
 
bool isLittleEndian () const
 
raw_ostreamgetStream ()
 
bool isSymbolRefDifferenceFullyResolved (const MCAssembler &Asm, const MCSymbolRefExpr *A, const MCSymbolRefExpr *B, bool InSet) const
 Check whether the difference (A - B) between two symbol references is fully resolved. More...
 
virtual bool isWeak (const MCSymbol &Sym) const
 True if this symbol (which is a variable) is weak. More...
 
void write8 (uint8_t Value)
 
void writeLE16 (uint16_t Value)
 
void writeLE32 (uint32_t Value)
 
void writeLE64 (uint64_t Value)
 
void writeBE16 (uint16_t Value)
 
void writeBE32 (uint32_t Value)
 
void writeBE64 (uint64_t Value)
 
void write16 (uint16_t Value)
 
void write32 (uint32_t Value)
 
void write64 (uint64_t Value)
 
void WriteZeros (unsigned N)
 
void writeBytes (const SmallVectorImpl< char > &ByteVec, unsigned ZeroFillSize=0)
 
void writeBytes (StringRef Str, unsigned ZeroFillSize=0)
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::MCObjectWriter
 MCObjectWriter (raw_pwrite_stream &OS, bool IsLittleEndian)
 
- Protected Attributes inherited from llvm::MCObjectWriter
raw_pwrite_streamOS
 
unsigned IsLittleEndian: 1
 

Detailed Description

Definition at line 74 of file MCMachObjectWriter.h.

Constructor & Destructor Documentation

llvm::MachObjectWriter::MachObjectWriter ( MCMachObjectTargetWriter MOTW,
raw_pwrite_stream OS,
bool  IsLittleEndian 
)
inline

Definition at line 117 of file MCMachObjectWriter.h.

Member Function Documentation

void llvm::MachObjectWriter::addRelocation ( const MCSymbol RelSymbol,
const MCSection Sec,
MachO::any_relocation_info MRE 
)
inline

Definition at line 213 of file MCMachObjectWriter.h.

References P.

void MachObjectWriter::bindIndirectSymbols ( MCAssembler Asm)
void MachObjectWriter::computeSectionAddresses ( const MCAssembler Asm,
const MCAsmLayout Layout 
)
void MachObjectWriter::computeSymbolTable ( MCAssembler Asm,
std::vector< MachSymbolData > &  LocalSymbolData,
std::vector< MachSymbolData > &  ExternalSymbolData,
std::vector< MachSymbolData > &  UndefinedSymbolData 
)
bool MachObjectWriter::doesSymbolRequireExternRelocation ( const MCSymbol S)

Definition at line 41 of file MachObjectWriter.cpp.

References llvm::MCSymbol::isUndefined().

void MachObjectWriter::executePostLayoutBinding ( MCAssembler Asm,
const MCAsmLayout Layout 
)
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.

Implements llvm::MCObjectWriter.

Definition at line 622 of file MachObjectWriter.cpp.

References bindIndirectSymbols(), and computeSectionAddresses().

const MCSymbol & MachObjectWriter::findAliasedSymbol ( const MCSymbol Sym) const
uint64_t MachObjectWriter::getFragmentAddress ( const MCFragment Fragment,
const MCAsmLayout Layout 
) const
uint64_t MachObjectWriter::getPaddingSize ( const MCSection SD,
const MCAsmLayout Layout 
) const
uint64_t llvm::MachObjectWriter::getSectionAddress ( const MCSection Sec) const
inline
SectionAddrMap& llvm::MachObjectWriter::getSectionAddressMap ( )
inline

Definition at line 135 of file MCMachObjectWriter.h.

uint64_t MachObjectWriter::getSymbolAddress ( const MCSymbol S,
const MCAsmLayout Layout 
) const
bool llvm::MachObjectWriter::is64Bit ( ) const
inline
bool MachObjectWriter::isFixupKindPCRel ( const MCAssembler Asm,
unsigned  Kind 
)
bool MachObjectWriter::isSymbolRefDifferenceFullyResolvedImpl ( const MCAssembler Asm,
const MCSymbol SymA,
const MCFragment FB,
bool  InSet,
bool  IsPCRel 
) const
overridevirtual
bool llvm::MachObjectWriter::isX86_64 ( ) const
inline
void MachObjectWriter::recordRelocation ( MCAssembler Asm,
const MCAsmLayout Layout,
const MCFragment Fragment,
const MCFixup Fixup,
MCValue  Target,
bool IsPCRel,
uint64_t &  FixedValue 
)
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 435 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 ( )
overridevirtual

lifetime management

Reimplemented from llvm::MCObjectWriter.

Definition at line 31 of file MachObjectWriter.cpp.

References llvm::StringTableBuilder::clear(), and llvm::MCObjectWriter::reset().

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 
)
overridevirtual

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

References llvm::dwarf::syntax::Address, ComputeLinkerOptionsLoadCommandSize(), computeSymbolTable(), llvm::StringTableBuilder::data(), llvm::Data, llvm::dbgs(), DEBUG, llvm::DataRegionData::End, llvm::MCAsmLayout::getAssembler(), llvm::MCAssembler::getDataRegions(), llvm::MCLOHContainer::getEmitSize(), llvm::MCAssembler::getLinkerOptions(), llvm::MCAssembler::getLOHContainer(), llvm::MCSymbol::getName(), getPaddingSize(), getSectionAddress(), llvm::MCAsmLayout::getSectionAddressSize(), llvm::MCAsmLayout::getSectionFileSize(), getSymbolAddress(), llvm::MCSectionMachO::getType(), llvm::MCAssembler::getVersionMinInfo(), llvm::MachO::INDIRECT_SYMBOL_ABS, llvm::MachO::INDIRECT_SYMBOL_LOCAL, is64Bit(), 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::make_range(), 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::StringRef::size(), llvm::MCAssembler::size(), llvm::DataRegionData::Start, llvm::raw_ostream::tell(), llvm::MCAssembler::VersionMinInfoType::Update, llvm::MCObjectWriter::write16(), llvm::MCObjectWriter::write32(), llvm::MCObjectWriter::writeBytes(), writeDysymtabLoadCommand(), writeHeader(), writeLinkeditLoadCommand(), writeLinkerOptionsLoadCommand(), writeNlist(), writeSection(), writeSegmentLoadCommand(), writeSymtabLoadCommand(), and llvm::MCObjectWriter::WriteZeros().

void MachObjectWriter::writeSection ( const MCAssembler Asm,
const MCAsmLayout Layout,
const MCSection Sec,
uint64_t  FileOffset,
uint64_t  RelocationsStart,
unsigned  NumRelocations 
)
void MachObjectWriter::writeSegmentLoadCommand ( unsigned  NumSections,
uint64_t  VMSize,
uint64_t  SectionDataStartOffset,
uint64_t  SectionDataSize 
)

Write a segment load command.

writeSegmentLoadCommand - Write a segment load command.

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

Definition at line 154 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 
)

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