LLVM  3.7.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
llvm::MCObjectWriter Class Referenceabstract

Defines the object file and target independent interfaces used by the assembler backend to write native file format object files. More...

#include <MCObjectWriter.h>

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

Public Member Functions

virtual ~MCObjectWriter ()
 
virtual void reset ()
 lifetime management More...
 
bool isLittleEndian () const
 
raw_ostreamgetStream ()
 
High-Level API
virtual void executePostLayoutBinding (MCAssembler &Asm, const MCAsmLayout &Layout)=0
 Perform any late binding of symbols (for example, to assign symbol indices for use when generating relocations). More...
 
virtual void recordRelocation (MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, bool &IsPCRel, uint64_t &FixedValue)=0
 Record a relocation entry. More...
 
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 isSymbolRefDifferenceFullyResolvedImpl (const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const
 
virtual bool isWeak (const MCSymbol &Sym) const
 True if this symbol (which is a variable) is weak. More...
 
virtual void writeObject (MCAssembler &Asm, const MCAsmLayout &Layout)=0
 Write the object file. More...
 
Binary Output
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)
 

Protected Member Functions

 MCObjectWriter (raw_pwrite_stream &OS, bool IsLittleEndian)
 

Protected Attributes

raw_pwrite_streamOS
 
unsigned IsLittleEndian: 1
 

Detailed Description

Defines the object file and target independent interfaces used by the assembler backend to write native file format object files.

The object writer contains a few callbacks used by the assembler to allow the object writer to modify the assembler data structures at appropriate points. Once assembly is complete, the object writer is given the MCAssembler instance, which contains all the symbol and section data which should be emitted as part of writeObject().

The object writer also contains a number of helper methods for writing binary data to the output stream.

Definition at line 39 of file MCObjectWriter.h.

Constructor & Destructor Documentation

llvm::MCObjectWriter::MCObjectWriter ( raw_pwrite_stream OS,
bool  IsLittleEndian 
)
inlineprotected

Definition at line 49 of file MCObjectWriter.h.

MCObjectWriter::~MCObjectWriter ( )
virtual

Definition at line 17 of file MCObjectWriter.cpp.

Member Function Documentation

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

Implemented in llvm::MachObjectWriter.

Referenced by llvm::MCAssembler::Finish().

raw_ostream& llvm::MCObjectWriter::getStream ( )
inline

Definition at line 60 of file MCObjectWriter.h.

References OS.

Referenced by llvm::MCLOHDirective::emit(), writeFragment(), and llvm::MCAssembler::writeSectionData().

bool llvm::MCObjectWriter::isLittleEndian ( ) const
inline

Definition at line 58 of file MCObjectWriter.h.

References IsLittleEndian.

bool MCObjectWriter::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.

Clients are not required to answer precisely and may conservatively return false, even when a difference is fully resolved.

Definition at line 20 of file MCObjectWriter.cpp.

References llvm::MCSymbol::getFragment(), llvm::MCSymbolRefExpr::getKind(), llvm::MCSymbolRefExpr::getSymbol(), isSymbolRefDifferenceFullyResolvedImpl(), llvm::MCSymbol::isUndefined(), and llvm::MCSymbolRefExpr::VK_None.

bool MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl ( const MCAssembler Asm,
const MCSymbol SymA,
const MCFragment FB,
bool  InSet,
bool  IsPCRel 
) const
virtual
bool MCObjectWriter::isWeak ( const MCSymbol Sym) const
virtual

True if this symbol (which is a variable) is weak.

This is not just STB_WEAK, but more generally whether or not we can evaluate past it.

Definition at line 49 of file MCObjectWriter.cpp.

Referenced by canExpand().

virtual void llvm::MCObjectWriter::recordRelocation ( MCAssembler Asm,
const MCAsmLayout Layout,
const MCFragment Fragment,
const MCFixup Fixup,
MCValue  Target,
bool IsPCRel,
uint64_t &  FixedValue 
)
pure 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().

Implemented in llvm::MachObjectWriter.

virtual void llvm::MCObjectWriter::reset ( )
inlinevirtual

lifetime management

Reimplemented in llvm::MachObjectWriter.

Definition at line 56 of file MCObjectWriter.h.

Referenced by llvm::MachObjectWriter::reset(), and llvm::MCAssembler::reset().

void llvm::MCObjectWriter::write16 ( uint16_t  Value)
inline
void llvm::MCObjectWriter::write32 ( uint32_t  Value)
inline
void llvm::MCObjectWriter::write64 ( uint64_t  Value)
inline
void llvm::MCObjectWriter::write8 ( uint8_t  Value)
inline

Definition at line 116 of file MCObjectWriter.h.

References OS.

Referenced by writeFragment(), and llvm::MachObjectWriter::writeNlist().

void llvm::MCObjectWriter::writeBE16 ( uint16_t  Value)
inline

Definition at line 130 of file MCObjectWriter.h.

References OS, and llvm::support::endian::write().

Referenced by write16().

void llvm::MCObjectWriter::writeBE32 ( uint32_t  Value)
inline

Definition at line 134 of file MCObjectWriter.h.

References OS, and llvm::support::endian::write().

Referenced by write32().

void llvm::MCObjectWriter::writeBE64 ( uint64_t  Value)
inline

Definition at line 138 of file MCObjectWriter.h.

References OS, and llvm::support::endian::write().

Referenced by write64().

void llvm::MCObjectWriter::writeBytes ( const SmallVectorImpl< char > &  ByteVec,
unsigned  ZeroFillSize = 0 
)
inline
void llvm::MCObjectWriter::writeBytes ( StringRef  Str,
unsigned  ZeroFillSize = 0 
)
inline

Definition at line 177 of file MCObjectWriter.h.

References OS, llvm::StringRef::size(), and WriteZeros().

void llvm::MCObjectWriter::writeLE16 ( uint16_t  Value)
inline

Definition at line 118 of file MCObjectWriter.h.

References OS, and llvm::support::endian::write().

Referenced by write16().

void llvm::MCObjectWriter::writeLE32 ( uint32_t  Value)
inline

Definition at line 122 of file MCObjectWriter.h.

References OS, and llvm::support::endian::write().

Referenced by write32().

void llvm::MCObjectWriter::writeLE64 ( uint64_t  Value)
inline

Definition at line 126 of file MCObjectWriter.h.

References OS, and llvm::support::endian::write().

Referenced by write64().

virtual void llvm::MCObjectWriter::writeObject ( MCAssembler Asm,
const MCAsmLayout Layout 
)
pure 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.

Implemented in llvm::MachObjectWriter.

Referenced by llvm::MCAssembler::Finish().

void llvm::MCObjectWriter::WriteZeros ( unsigned  N)
inline

Member Data Documentation

unsigned llvm::MCObjectWriter::IsLittleEndian
protected
raw_pwrite_stream& llvm::MCObjectWriter::OS
protected

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