LLVM 20.0.0git
|
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"
Classes | |
struct | CGProfileEntry |
Public Member Functions | |
MCObjectWriter (const MCObjectWriter &)=delete | |
MCObjectWriter & | operator= (const MCObjectWriter &)=delete |
virtual | ~MCObjectWriter () |
virtual void | reset () |
lifetime management | |
High-Level API | |
virtual void | executePostLayoutBinding (MCAssembler &Asm) |
Perform any late binding of symbols (for example, to assign symbol indices for use when generating relocations). | |
virtual void | recordRelocation (MCAssembler &Asm, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue)=0 |
Record a relocation entry. | |
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. | |
virtual bool | isSymbolRefDifferenceFullyResolvedImpl (const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const |
MutableArrayRef< std::pair< std::string, size_t > > | getFileNames () |
void | addFileName (MCAssembler &Asm, 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 (MCAssembler &Asm)=0 |
Write the object file and returns the number of bytes written. | |
Protected Member Functions | |
MCObjectWriter ()=default | |
Protected Attributes | |
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 |
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 33 of file MCObjectWriter.h.
|
protecteddefault |
|
delete |
|
virtualdefault |
Record the given symbol in the address-significance table to be written diring writeObject().
Definition at line 113 of file MCObjectWriter.h.
References AddrsigSyms, and Sym.
Referenced by llvm::MCObjectStreamer::emitAddrsigSym().
void MCObjectWriter::addFileName | ( | MCAssembler & | Asm, |
StringRef | FileName | ||
) |
Definition at line 57 of file MCObjectWriter.cpp.
References llvm::SmallVectorImpl< T >::emplace_back(), and FileNames.
|
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 107 of file MCObjectWriter.h.
References EmitAddrsigSection.
Referenced by llvm::MCObjectStreamer::emitAddrsig().
|
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 68 of file MCObjectWriter.h.
Referenced by llvm::MCAssembler::layout().
Definition at line 115 of file MCObjectWriter.h.
References AddrsigSyms.
Referenced by llvm::MachObjectWriter::populateAddrSigSection().
|
inline |
Definition at line 116 of file MCObjectWriter.h.
References CGProfile.
Referenced by llvm::MCELFStreamer::emitCGProfileEntry(), llvm::MCWinCOFFStreamer::emitCGProfileEntry(), and llvm::WinCOFFWriter::writeObject().
|
inline |
Definition at line 109 of file MCObjectWriter.h.
References EmitAddrsigSection.
Referenced by llvm::WinCOFFWriter::writeObject().
|
inline |
Definition at line 96 of file MCObjectWriter.h.
References FileNames.
|
inline |
Definition at line 119 of file MCObjectWriter.h.
References SubsectionsViaSymbols.
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 30 of file MCObjectWriter.cpp.
References A, assert(), B, llvm::MCSymbol::getFragment(), isSymbolRefDifferenceFullyResolvedImpl(), llvm::MCSymbol::isUndefined(), and llvm::MCSymbolRefExpr::VK_None.
|
virtual |
Reimplemented in llvm::ELFObjectWriter, llvm::MachObjectWriter, and llvm::WinCOFFObjectWriter.
Definition at line 48 of file MCObjectWriter.cpp.
References llvm::MCFragment::getParent(), and llvm::MCSymbol::getSection().
Referenced by isSymbolRefDifferenceFullyResolved().
|
delete |
|
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::ELFObjectWriter, llvm::MachObjectWriter, and llvm::WinCOFFObjectWriter.
|
virtual |
lifetime management
Reimplemented in llvm::ELFObjectWriter, llvm::MachObjectWriter, and llvm::WinCOFFObjectWriter.
Definition at line 22 of file MCObjectWriter.cpp.
References AddrsigSyms, CGProfile, llvm::SmallVectorImpl< T >::clear(), EmitAddrsigSection, FileNames, and SubsectionsViaSymbols.
Referenced by llvm::ELFObjectWriter::reset(), llvm::MachObjectWriter::reset(), and llvm::WinCOFFObjectWriter::reset().
|
inline |
Definition at line 100 of file MCObjectWriter.h.
References CompilerVersion.
|
inline |
Definition at line 120 of file MCObjectWriter.h.
References SubsectionsViaSymbols.
|
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::ELFObjectWriter, llvm::MachObjectWriter, and llvm::WinCOFFObjectWriter.
Referenced by llvm::MCAssembler::Finish().
Definition at line 39 of file MCObjectWriter.h.
Referenced by addAddrsigSymbol(), llvm::ELFObjectWriter::executePostLayoutBinding(), getAddrsigSyms(), reset(), and llvm::WinCOFFWriter::writeObject().
|
protected |
Definition at line 48 of file MCObjectWriter.h.
Referenced by getCGProfile(), reset(), and llvm::MachObjectWriter::writeObject().
|
protected |
Definition at line 38 of file MCObjectWriter.h.
Referenced by setCompilerVersion().
|
protected |
Definition at line 40 of file MCObjectWriter.h.
Referenced by emitAddrsigSection(), getEmitAddrsigSection(), and reset().
|
protected |
List of declared file names.
Definition at line 36 of file MCObjectWriter.h.
Referenced by addFileName(), getFileNames(), and reset().
|
protected |
Definition at line 41 of file MCObjectWriter.h.
Referenced by getSubsectionsViaSymbols(), llvm::MachObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(), reset(), setSubsectionsViaSymbols(), llvm::MachObjectWriter::writeHeader(), and llvm::MachObjectWriter::writeObject().