LLVM 20.0.0git
Classes | Public Member Functions | Public Attributes | List of all members
llvm::ELFObjectWriter Class Referencefinal

#include "llvm/MC/MCELFObjectWriter.h"

Inheritance diagram for llvm::ELFObjectWriter:
Inheritance graph
[legend]

Classes

struct  Symver
 

Public Member Functions

 ELFObjectWriter (std::unique_ptr< MCELFObjectTargetWriter > MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
 
 ELFObjectWriter (std::unique_ptr< MCELFObjectTargetWriter > MOTW, raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS, bool IsLittleEndian)
 
void reset () override
 lifetime management
 
void executePostLayoutBinding (MCAssembler &Asm) override
 Perform any late binding of symbols (for example, to assign symbol indices for use when generating relocations).
 
void recordRelocation (MCAssembler &Asm, const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target, uint64_t &FixedValue) override
 Record a relocation entry.
 
bool isSymbolRefDifferenceFullyResolvedImpl (const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const override
 
uint64_t writeObject (MCAssembler &Asm) override
 Write the object file and returns the number of bytes written.
 
bool hasRelocationAddend () const
 
bool usesRela (const MCTargetOptions *TO, const MCSectionELF &Sec) const
 
bool shouldRelocateWithSymbol (const MCAssembler &Asm, const MCValue &Val, const MCSymbolELF *Sym, uint64_t C, unsigned Type) const
 
bool checkRelocation (MCContext &Ctx, SMLoc Loc, const MCSectionELF *From, const MCSectionELF *To)
 
unsigned getELFHeaderEFlags () const
 
void setELFHeaderEFlags (unsigned Flags)
 
void markGnuAbi ()
 
bool seenGnuAbi () const
 
void setOverrideABIVersion (uint8_t V)
 
- Public Member Functions inherited from llvm::MCObjectWriter
 MCObjectWriter (const MCObjectWriter &)=delete
 
MCObjectWriteroperator= (const MCObjectWriter &)=delete
 
virtual ~MCObjectWriter ()
 
virtual void reset ()
 lifetime management
 
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.
 
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)
 

Public Attributes

std::unique_ptr< MCELFObjectTargetWriterTargetObjectWriter
 
raw_pwrite_streamOS
 
raw_pwrite_streamDwoOS = nullptr
 
DenseMap< const MCSectionELF *, std::vector< ELFRelocationEntry > > Relocations
 
DenseMap< const MCSymbolELF *, const MCSymbolELF * > Renames
 
bool IsLittleEndian = false
 
bool SeenGnuAbi = false
 
std::optional< uint8_t > OverrideABIVersion
 
SmallVector< Symver, 0 > Symvers
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::MCObjectWriter
 MCObjectWriter ()=default
 
- Protected Attributes inherited from llvm::MCObjectWriter
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

Definition at line 152 of file MCELFObjectWriter.h.

Constructor & Destructor Documentation

◆ ELFObjectWriter() [1/2]

ELFObjectWriter::ELFObjectWriter ( std::unique_ptr< MCELFObjectTargetWriter MOTW,
raw_pwrite_stream OS,
bool  IsLittleEndian 
)

Definition at line 1157 of file ELFObjectWriter.cpp.

◆ ELFObjectWriter() [2/2]

ELFObjectWriter::ELFObjectWriter ( std::unique_ptr< MCELFObjectTargetWriter MOTW,
raw_pwrite_stream OS,
raw_pwrite_stream DwoOS,
bool  IsLittleEndian 
)

Definition at line 1161 of file ELFObjectWriter.cpp.

Member Function Documentation

◆ checkRelocation()

bool ELFObjectWriter::checkRelocation ( MCContext Ctx,
SMLoc  Loc,
const MCSectionELF From,
const MCSectionELF To 
)

Definition at line 1368 of file ELFObjectWriter.cpp.

References DwoOS, From, isDwoSection(), and llvm::MCContext::reportError().

Referenced by recordRelocation().

◆ executePostLayoutBinding()

void ELFObjectWriter::executePostLayoutBinding ( MCAssembler Asm)
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.

Reimplemented from llvm::MCObjectWriter.

Definition at line 1181 of file ELFObjectWriter.cpp.

References llvm::MCObjectWriter::AddrsigSyms, assert(), llvm::MCSymbolRefExpr::create(), llvm::StringRef::find(), llvm::StringRef::npos, Renames, llvm::StringRef::starts_with(), llvm::StringRef::substr(), Sym, Symvers, and llvm::CallingConv::Tail.

◆ getELFHeaderEFlags()

unsigned llvm::ELFObjectWriter::getELFHeaderEFlags ( ) const
inline

Definition at line 202 of file MCELFObjectWriter.h.

◆ hasRelocationAddend()

bool ELFObjectWriter::hasRelocationAddend ( ) const

Definition at line 1177 of file ELFObjectWriter.cpp.

References TargetObjectWriter.

Referenced by shouldRelocateWithSymbol(), and usesRela().

◆ isSymbolRefDifferenceFullyResolvedImpl()

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

◆ markGnuAbi()

void llvm::ELFObjectWriter::markGnuAbi ( )
inline

◆ recordRelocation()

void ELFObjectWriter::recordRelocation ( MCAssembler Asm,
const MCFragment Fragment,
const MCFixup Fixup,
MCValue  Target,
uint64_t FixedValue 
)
overridevirtual

◆ reset()

void ELFObjectWriter::reset ( )
overridevirtual

lifetime management

Reimplemented from llvm::MCObjectWriter.

Definition at line 1167 of file ELFObjectWriter.cpp.

References OverrideABIVersion, Relocations, Renames, llvm::MCObjectWriter::reset(), SeenGnuAbi, and Symvers.

◆ seenGnuAbi()

bool llvm::ELFObjectWriter::seenGnuAbi ( ) const
inline

Definition at line 207 of file MCELFObjectWriter.h.

References SeenGnuAbi.

◆ setELFHeaderEFlags()

void llvm::ELFObjectWriter::setELFHeaderEFlags ( unsigned  Flags)
inline

Definition at line 203 of file MCELFObjectWriter.h.

◆ setOverrideABIVersion()

void llvm::ELFObjectWriter::setOverrideABIVersion ( uint8_t  V)
inline

Definition at line 210 of file MCELFObjectWriter.h.

References OverrideABIVersion.

◆ shouldRelocateWithSymbol()

bool ELFObjectWriter::shouldRelocateWithSymbol ( const MCAssembler Asm,
const MCValue Val,
const MCSymbolELF Sym,
uint64_t  C,
unsigned  Type 
) const

◆ usesRela()

bool ELFObjectWriter::usesRela ( const MCTargetOptions TO,
const MCSectionELF Sec 
) const

◆ writeObject()

uint64_t ELFObjectWriter::writeObject ( MCAssembler Asm)
overridevirtual

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.

Implements llvm::MCObjectWriter.

Definition at line 1495 of file ELFObjectWriter.cpp.

References DwoOS, IsLittleEndian, OS, and Size.

Member Data Documentation

◆ DwoOS

raw_pwrite_stream* llvm::ELFObjectWriter::DwoOS = nullptr

Definition at line 158 of file MCELFObjectWriter.h.

Referenced by checkRelocation(), and writeObject().

◆ IsLittleEndian

bool llvm::ELFObjectWriter::IsLittleEndian = false

Definition at line 162 of file MCELFObjectWriter.h.

Referenced by writeObject().

◆ OS

raw_pwrite_stream& llvm::ELFObjectWriter::OS

Definition at line 157 of file MCELFObjectWriter.h.

Referenced by writeObject().

◆ OverrideABIVersion

std::optional<uint8_t> llvm::ELFObjectWriter::OverrideABIVersion

Definition at line 164 of file MCELFObjectWriter.h.

Referenced by reset(), and setOverrideABIVersion().

◆ Relocations

DenseMap<const MCSectionELF *, std::vector<ELFRelocationEntry> > llvm::ELFObjectWriter::Relocations

Definition at line 160 of file MCELFObjectWriter.h.

Referenced by recordRelocation(), and reset().

◆ Renames

DenseMap<const MCSymbolELF *, const MCSymbolELF *> llvm::ELFObjectWriter::Renames

Definition at line 161 of file MCELFObjectWriter.h.

Referenced by executePostLayoutBinding(), recordRelocation(), and reset().

◆ SeenGnuAbi

bool llvm::ELFObjectWriter::SeenGnuAbi = false

Definition at line 163 of file MCELFObjectWriter.h.

Referenced by markGnuAbi(), reset(), and seenGnuAbi().

◆ Symvers

SmallVector<Symver, 0> llvm::ELFObjectWriter::Symvers

◆ TargetObjectWriter

std::unique_ptr<MCELFObjectTargetWriter> llvm::ELFObjectWriter::TargetObjectWriter

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