LLVM 22.0.0git
Classes | 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 "llvm/MC/MCObjectWriter.h"

Inheritance diagram for llvm::MCObjectWriter:
[legend]

Classes

struct  CGProfileEntry
 

Public Member Functions

 MCObjectWriter (const MCObjectWriter &)=delete
 
MCObjectWriteroperator= (const MCObjectWriter &)=delete
 
virtual ~MCObjectWriter ()
 
virtual void setAssembler (MCAssembler *A)
 
MCContextgetContext () const
 
virtual void reset ()
 lifetime management
 
High-Level API
virtual void executePostLayoutBinding ()
 Perform any late binding of symbols (for example, to assign symbol indices for use when generating relocations).
 
virtual void recordRelocation (const MCFragment &F, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue)
 Record a relocation entry.
 
bool isSymbolRefDifferenceFullyResolved (const MCSymbol &A, const MCSymbol &B, bool InSet) const
 Check whether the difference (A - B) between two symbol references is fully resolved.
 
virtual bool isSymbolRefDifferenceFullyResolvedImpl (const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const
 
MutableArrayRef< std::pair< std::string, size_t > > getFileNames ()
 
void addFileName (StringRef FileName)
 
void setCompilerVersion (StringRef CompilerVers)
 
void emitAddrsigSection ()
 Tell the object writer to emit an address-significance table during writeObject().
 
bool getEmitAddrsigSection ()
 
void addAddrsigSymbol (const MCSymbol *Sym)
 Record the given symbol in the address-significance table to be written diring writeObject().
 
std::vector< const MCSymbol * > & getAddrsigSyms ()
 
SmallVector< CGProfileEntry, 0 > & getCGProfile ()
 
bool getSubsectionsViaSymbols () const
 
void setSubsectionsViaSymbols (bool Value)
 
virtual uint64_t writeObject ()=0
 Write the object file and returns the number of bytes written.
 

Protected Member Functions

 MCObjectWriter ()=default
 

Protected Attributes

MCAssemblerAsm = nullptr
 
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
 

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().

Definition at line 34 of file MCObjectWriter.h.

Constructor & Destructor Documentation

◆ MCObjectWriter() [1/2]

llvm::MCObjectWriter::MCObjectWriter ( )
protecteddefault

◆ MCObjectWriter() [2/2]

llvm::MCObjectWriter::MCObjectWriter ( const MCObjectWriter )
delete

◆ ~MCObjectWriter()

MCObjectWriter::~MCObjectWriter ( )
virtualdefault

Member Function Documentation

◆ addAddrsigSymbol()

void llvm::MCObjectWriter::addAddrsigSymbol ( const MCSymbol Sym)
inline

Record the given symbol in the address-significance table to be written diring writeObject().

Definition at line 115 of file MCObjectWriter.h.

References Sym.

Referenced by llvm::MCObjectStreamer::emitAddrsigSym().

◆ addFileName()

void MCObjectWriter::addFileName ( StringRef  FileName)

Definition at line 53 of file MCObjectWriter.cpp.

References Asm, llvm::SmallVectorImpl< T >::emplace_back(), and FileNames.

◆ emitAddrsigSection()

void llvm::MCObjectWriter::emitAddrsigSection ( )
inline

Tell the object writer to emit an address-significance table during writeObject().

If this function is not called, all symbols are treated as address-significant.

Definition at line 109 of file MCObjectWriter.h.

Referenced by llvm::MCObjectStreamer::emitAddrsig().

◆ executePostLayoutBinding()

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

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 in llvm::ELFObjectWriter, llvm::MachObjectWriter, and llvm::WinCOFFObjectWriter.

Definition at line 74 of file MCObjectWriter.h.

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

◆ getAddrsigSyms()

std::vector< const MCSymbol * > & llvm::MCObjectWriter::getAddrsigSyms ( )
inline

Definition at line 117 of file MCObjectWriter.h.

Referenced by llvm::MachObjectWriter::populateAddrSigSection().

◆ getCGProfile()

SmallVector< CGProfileEntry, 0 > & llvm::MCObjectWriter::getCGProfile ( )
inline

◆ getContext()

MCContext & MCObjectWriter::getContext ( ) const

◆ getEmitAddrsigSection()

bool llvm::MCObjectWriter::getEmitAddrsigSection ( )
inline

Definition at line 111 of file MCObjectWriter.h.

Referenced by llvm::WinCOFFWriter::writeObject().

◆ getFileNames()

MutableArrayRef< std::pair< std::string, size_t > > llvm::MCObjectWriter::getFileNames ( )
inline

Definition at line 98 of file MCObjectWriter.h.

◆ getSubsectionsViaSymbols()

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

Definition at line 121 of file MCObjectWriter.h.

◆ isSymbolRefDifferenceFullyResolved()

bool MCObjectWriter::isSymbolRefDifferenceFullyResolved ( const MCSymbol A,
const MCSymbol 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 36 of file MCObjectWriter.cpp.

References assert(), llvm::MCSymbol::getFragment(), isSymbolRefDifferenceFullyResolvedImpl(), and llvm::MCSymbol::isUndefined().

◆ isSymbolRefDifferenceFullyResolvedImpl()

bool MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl ( const MCSymbol SymA,
const MCFragment FB,
bool  InSet,
bool  IsPCRel 
) const
virtual

◆ operator=()

MCObjectWriter & llvm::MCObjectWriter::operator= ( const MCObjectWriter )
delete

◆ recordRelocation()

void MCObjectWriter::recordRelocation ( const MCFragment F,
const MCFixup Fixup,
MCValue  Target,
uint64_t FixedValue 
)
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().

Reimplemented in llvm::ELFObjectWriter, llvm::GOFFObjectWriter, llvm::MachObjectWriter, and llvm::WinCOFFObjectWriter.

Definition at line 33 of file MCObjectWriter.cpp.

Referenced by llvm::LoongArchAsmBackend::addReloc(), llvm::RISCVAsmBackend::addReloc(), llvm::AVRAsmBackend::applyFixup(), llvm::MCAsmBackend::maybeAddReloc(), and llvm::RISCVAsmBackend::maybeAddVendorReloc().

◆ reset()

void MCObjectWriter::reset ( )
virtual

◆ setAssembler()

virtual void llvm::MCObjectWriter::setAssembler ( MCAssembler A)
inlinevirtual

◆ setCompilerVersion()

void llvm::MCObjectWriter::setCompilerVersion ( StringRef  CompilerVers)
inline

Definition at line 102 of file MCObjectWriter.h.

◆ setSubsectionsViaSymbols()

void llvm::MCObjectWriter::setSubsectionsViaSymbols ( bool  Value)
inline

Definition at line 122 of file MCObjectWriter.h.

◆ writeObject()

virtual uint64_t llvm::MCObjectWriter::writeObject ( )
pure virtual

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.

Implemented in llvm::DXContainerObjectWriter, llvm::ELFObjectWriter, llvm::GOFFObjectWriter, llvm::MachObjectWriter, and llvm::WinCOFFObjectWriter.

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

Member Data Documentation

◆ AddrsigSyms

std::vector<const MCSymbol *> llvm::MCObjectWriter::AddrsigSyms
protected

◆ Asm

MCAssembler* llvm::MCObjectWriter::Asm = nullptr
protected

◆ CGProfile

SmallVector<CGProfileEntry, 0> llvm::MCObjectWriter::CGProfile
protected

Definition at line 50 of file MCObjectWriter.h.

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

◆ CompilerVersion

std::string llvm::MCObjectWriter::CompilerVersion
protected

Definition at line 40 of file MCObjectWriter.h.

◆ EmitAddrsigSection

bool llvm::MCObjectWriter::EmitAddrsigSection = false
protected

Definition at line 42 of file MCObjectWriter.h.

Referenced by reset().

◆ FileNames

SmallVector<std::pair<std::string, size_t>, 0> llvm::MCObjectWriter::FileNames
protected

List of declared file names.

Definition at line 38 of file MCObjectWriter.h.

Referenced by addFileName(), and reset().

◆ SubsectionsViaSymbols

bool llvm::MCObjectWriter::SubsectionsViaSymbols = false
protected

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