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

#include "llvm/MC/MCMachObjectWriter.h"

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

Public Member Functions

 MachObjectWriter (std::unique_ptr< MCMachObjectTargetWriter > MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
 
const MCSymbolfindAliasedSymbol (const MCSymbol &Sym) const
 
void writeHeader (MachO::HeaderFileType Type, unsigned NumLoadCommands, unsigned LoadCommandsSize, bool SubsectionsViaSymbols)
 
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. More...
 
void writeSection (const MCAsmLayout &Layout, const MCSection &Sec, uint64_t VMAddr, uint64_t FileOffset, unsigned Flags, 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, 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 &A, const MCSymbol &B, bool InSet) const override
 
bool isSymbolRefDifferenceFullyResolvedImpl (const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const override
 
uint64_t writeObject (MCAssembler &Asm, const MCAsmLayout &Layout) override
 Write the object file and returns the number of bytes written. 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
 MCObjectWriter (const MCObjectWriter &)=delete
 
MCObjectWriteroperator= (const MCObjectWriter &)=delete
 
virtual ~MCObjectWriter ()
 
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 void emitAddrsigSection ()
 Tell the object writer to emit an address-significance table during writeObject(). More...
 
virtual void addAddrsigSymbol (const MCSymbol *Sym)
 Record the given symbol in the address-significance table to be written diring writeObject(). More...
 

Public Attributes

support::endian::Writer W
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::MCObjectWriter
 MCObjectWriter ()=default
 

Detailed Description

Definition at line 82 of file MCMachObjectWriter.h.

Constructor & Destructor Documentation

◆ MachObjectWriter()

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

Definition at line 127 of file MCMachObjectWriter.h.

Member Function Documentation

◆ addRelocation()

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

◆ bindIndirectSymbols()

void MachObjectWriter::bindIndirectSymbols ( MCAssembler Asm)

◆ computeSectionAddresses()

void MachObjectWriter::computeSectionAddresses ( const MCAssembler Asm,
const MCAsmLayout Layout 
)

◆ computeSymbolTable()

void MachObjectWriter::computeSymbolTable ( MCAssembler Asm,
std::vector< MachSymbolData > &  LocalSymbolData,
std::vector< MachSymbolData > &  ExternalSymbolData,
std::vector< MachSymbolData > &  UndefinedSymbolData 
)

◆ doesSymbolRequireExternRelocation()

bool MachObjectWriter::doesSymbolRequireExternRelocation ( const MCSymbol S)

◆ executePostLayoutBinding()

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

References bindIndirectSymbols(), and computeSectionAddresses().

◆ findAliasedSymbol()

const MCSymbol & MachObjectWriter::findAliasedSymbol ( const MCSymbol Sym) const

◆ getFragmentAddress()

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

◆ getPaddingSize()

uint64_t MachObjectWriter::getPaddingSize ( const MCSection SD,
const MCAsmLayout Layout 
) const

◆ getSectionAddress()

uint64_t llvm::MachObjectWriter::getSectionAddress ( const MCSection Sec) const
inline

◆ getSectionAddressMap()

SectionAddrMap& llvm::MachObjectWriter::getSectionAddressMap ( )
inline

◆ getSymbolAddress()

uint64_t MachObjectWriter::getSymbolAddress ( const MCSymbol S,
const MCAsmLayout Layout 
) const

◆ is64Bit()

bool llvm::MachObjectWriter::is64Bit ( ) const
inline

Definition at line 167 of file MCMachObjectWriter.h.

Referenced by writeLinkerOptionsLoadCommand(), writeNlist(), and writeObject().

◆ isFixupKindPCRel()

bool MachObjectWriter::isFixupKindPCRel ( const MCAssembler Asm,
unsigned  Kind 
)

◆ isSymbolRefDifferenceFullyResolvedImpl() [1/2]

bool MachObjectWriter::isSymbolRefDifferenceFullyResolvedImpl ( const MCAssembler Asm,
const MCSymbol A,
const MCSymbol B,
bool  InSet 
) const
overridevirtual

◆ isSymbolRefDifferenceFullyResolvedImpl() [2/2]

bool MachObjectWriter::isSymbolRefDifferenceFullyResolvedImpl ( const MCAssembler Asm,
const MCSymbol SymA,
const MCFragment FB,
bool  InSet,
bool  IsPCRel 
) const
overridevirtual

◆ isX86_64()

bool llvm::MachObjectWriter::isX86_64 ( ) const
inline

Definition at line 168 of file MCMachObjectWriter.h.

References llvm::MachO::CPU_TYPE_X86_64, and Name.

Referenced by isSymbolRefDifferenceFullyResolvedImpl().

◆ recordRelocation()

void MachObjectWriter::recordRelocation ( MCAssembler Asm,
const MCAsmLayout Layout,
const MCFragment Fragment,
const MCFixup Fixup,
MCValue  Target,
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 452 of file MachObjectWriter.cpp.

◆ recordScatteredRelocation()

void llvm::MachObjectWriter::recordScatteredRelocation ( const MCAssembler Asm,
const MCAsmLayout Layout,
const MCFragment Fragment,
const MCFixup Fixup,
MCValue  Target,
unsigned  Log2Size,
uint64_t &  FixedValue 
)

◆ recordTLVPRelocation()

void llvm::MachObjectWriter::recordTLVPRelocation ( const MCAssembler Asm,
const MCAsmLayout Layout,
const MCFragment Fragment,
const MCFixup Fixup,
MCValue  Target,
uint64_t &  FixedValue 
)

◆ reset()

void MachObjectWriter::reset ( )
overridevirtual

lifetime management

Reimplemented from llvm::MCObjectWriter.

Definition at line 44 of file MachObjectWriter.cpp.

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

◆ writeDysymtabLoadCommand()

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

Referenced by writeObject().

◆ writeHeader()

void MachObjectWriter::writeHeader ( MachO::HeaderFileType  Type,
unsigned  NumLoadCommands,
unsigned  LoadCommandsSize,
bool  SubsectionsViaSymbols 
)

Definition at line 132 of file MachObjectWriter.cpp.

References llvm::MachO::MH_SUBSECTIONS_VIA_SYMBOLS.

Referenced by writeObject().

◆ writeLinkeditLoadCommand()

void MachObjectWriter::writeLinkeditLoadCommand ( uint32_t  Type,
uint32_t  DataOffset,
uint32_t  DataSize 
)

Definition at line 406 of file MachObjectWriter.cpp.

Referenced by writeObject().

◆ writeLinkerOptionsLoadCommand()

void MachObjectWriter::writeLinkerOptionsLoadCommand ( const std::vector< std::string > &  Options)

Definition at line 429 of file MachObjectWriter.cpp.

References ComputeLinkerOptionsLoadCommandSize(), is64Bit(), and Size.

Referenced by writeObject().

◆ writeNlist()

void MachObjectWriter::writeNlist ( MachSymbolData &  MSD,
const MCAsmLayout Layout 
)

◆ writeObject()

uint64_t MachObjectWriter::writeObject ( MCAssembler Asm,
const MCAsmLayout Layout 
)
overridevirtual

◆ writeSection()

void MachObjectWriter::writeSection ( const MCAsmLayout Layout,
const MCSection Sec,
uint64_t  VMAddr,
uint64_t  FileOffset,
unsigned  Flags,
uint64_t  RelocationsStart,
unsigned  NumRelocations 
)

◆ writeSegmentLoadCommand()

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.

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

Definition at line 173 of file MachObjectWriter.cpp.

Referenced by writeObject().

◆ writeSymtabLoadCommand()

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

Definition at line 258 of file MachObjectWriter.cpp.

Referenced by writeObject().

Member Data Documentation

◆ W

support::endian::Writer llvm::MachObjectWriter::W

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