37 #define DEBUG_TYPE "WinCOFFStreamer"
55 for (
unsigned i = 0, e = Fixups.
size(); i != e; ++i) {
80 assert(Symbol->
isUndefined() &&
"Cannot define a symbol twice!");
94 assert(Symbol &&
"Symbol must be non-null!");
97 "Got non-COFF section in the COFF backend!");
102 default:
return false;
105 cast<MCSymbolCOFF>(
Symbol)->setIsWeakExternal();
123 "Got non-COFF section in the COFF backend!");
126 FatalError(
"starting a new symbol definition without completing the "
133 FatalError(
"storage class specified outside of symbol definition");
136 FatalError(
"storage class value '" +
Twine(StorageClass) +
145 FatalError(
"symbol type specified outside of a symbol definition");
148 FatalError(
"type value '" +
Twine(Type) +
"' out of range");
156 FatalError(
"ending symbol definition without starting one");
163 if (
getContext().getObjectFileInfo()->getTargetTriple().getArch() !=
207 "Got non-COFF section in the COFF backend!");
211 if (ByteAlignment > 32)
215 Size = std::max(Size, static_cast<uint64_t>(ByteAlignment));
229 OS <<
" -aligncomm:\"" << Symbol->
getName() <<
"\","
242 assert(!Symbol->
isInSection() &&
"Symbol must not already have a section!");
247 Section->setAlignment(ByteAlignment);
254 if (ByteAlignment != 1)
256 ByteAlignment, Section);
259 0, 0, Size, Section);
291 void MCWinCOFFStreamer::FatalError(
const Twine &Msg)
const {
void AssignSection(MCSymbol *Symbol, MCSection *Section)
Sets the symbol's section.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
unsigned Log2_32_Ceil(uint32_t Value)
Log2_32_Ceil - This function returns the ceil log base 2 of the specified value, 32 if the value is z...
void InitSections(bool NoExecStack) override
Create the default sections and set the initial one.
void EmitThumbFunc(MCSymbol *Func) override
Note in the output that the specified Func is a Thumb mode function (ARM target only).
void EmitBytes(StringRef Data) override
Emit the bytes in Data into the output.
void setType(uint16_t Ty) const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
void EmitCOFFSectionIndex(MCSymbol const *Symbol) override
Emits a COFF section index.
void EmitLabel(MCSymbol *Symbol) override
Emit a label for Symbol into the current section.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
SectionVariant getVariant() const
void EmitWinEHHandlerData() override
void setAlignment(unsigned Value)
const MCSymbol * CurSymbol
void EmitAssemblerFlag(MCAssemblerFlag Flag) override
Note in the output the specified Flag.
LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L, const Twine &Msg) const
MCCodeEmitter & getEmitter() const
A raw_ostream that writes to an SmallVector or SmallString.
void registerSymbol(const MCSymbol &Symbol, bool *Created=nullptr)
void PushSection()
Save the current and previous section on the section stack.
void EmitCOFFSymbolStorageClass(int StorageClass) override
Emit the storage class of the symbol.
bool registerSection(MCSection &Section)
unsigned getAlignment() const
static std::error_code getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
COFF::SymbolStorageClass StorageClass
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void EmitFileDirective(StringRef Filename) override
Switch to a new logical file.
virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
EncodeInstruction - Encode the given Inst to bytes on the output stream OS.
Represent a reference to a symbol from inside an expression.
void setCommon(uint64_t Size, unsigned Align)
Mark this symbol as being 'common'.
A four-byte section relative fixup.
MCContext & getContext() const
Context object for machine code objects.
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
MCSection * getBSSSection() const
A two-byte section relative fixup.
Streaming object file generation interface.
void setExternal(bool Value) const
void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override
Set the DescValue for the Symbol.
const Triple & getTargetTriple() const
SmallVectorImpl< char > & getContents()
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a local common (.lcomm) symbol.
Instances of this class represent a single low-level machine instruction.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a common symbol.
The instances of the Type class are immutable: once they are created, they are never changed...
void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit=0) override
Emit nops until the byte alignment ByteAlignment is reached.
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
MCAssembler & getAssembler()
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
MCCodeEmitter - Generic instruction encoding interface.
SmallVectorImpl< MCFixup > & getFixups()
A function that returns a base type.
MCSection * getDrectveSection() const
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a thread local bss (.tbss) symbol.
void EmitCOFFSymbolType(int Type) override
Emit the type of the symbol.
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
Triple - Helper class for working with autoconf configuration names.
MCSection * getSXDataSection() const
PowerPC TLS Dynamic Call Fixup
void setFragment(MCFragment *Value) const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
#define LLVM_ATTRIBUTE_NORETURN
void addFileName(StringRef FileName)
void EndCOFFSymbolDef() override
Marks the end of the symbol definition.
StringRef getName() const
getName - Get the symbol name.
void FinishImpl() override
Streamer specific finalization.
void EmitCOFFSecRel32(MCSymbol const *Symbol) override
Emits a COFF section relative relocation.
void setIsSafeSEH() const
MCWinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB, MCCodeEmitter &CE, raw_pwrite_stream &OS)
void EmitLabel(MCSymbol *Symbol) override
Emit a label for Symbol into the current section.
MCSubtargetInfo - Generic base class for all target subtargets.
void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) override
void BeginCOFFSymbolDef(MCSymbol const *Symbol) override
Start emitting COFF symbol definition.
An abstract base class for streams implementations that also support a pwrite operation.
void EmitIdent(StringRef IdentString) override
Emit the "identifiers" directive.
Fragment for data and encoded instructions.
void EmitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit the zerofill section and an optional symbol.
bool PopSection()
Restore the current and previous section from the section stack.
Generic interface to target specific assembler backends.
const MCObjectFileInfo * getObjectFileInfo() const
bool isKnownWindowsMSVCEnvironment() const
StringRef - Represent a constant reference to a string, i.e.
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
void EmitCOFFSafeSEH(MCSymbol const *Symbol) override
Represents a location in source code.
MCDataFragment * getOrCreateDataFragment()
Get a data fragment to write into, creating a new one if the current fragment is not a data fragment...
void FinishImpl() override
Streamer specific finalization.