LLVM 20.0.0git
MCWinCOFFStreamer.cpp
Go to the documentation of this file.
1//===- llvm/MC/MCWinCOFFStreamer.cpp --------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains an implementation of a Windows COFF object file streamer.
10//
11//===----------------------------------------------------------------------===//
12
16#include "llvm/ADT/Twine.h"
19#include "llvm/MC/MCAssembler.h"
21#include "llvm/MC/MCCodeView.h"
22#include "llvm/MC/MCContext.h"
23#include "llvm/MC/MCExpr.h"
24#include "llvm/MC/MCFixup.h"
25#include "llvm/MC/MCFragment.h"
32#include "llvm/MC/MCValue.h"
37#include "llvm/Support/SMLoc.h"
40#include <algorithm>
41#include <cstdint>
42
43using namespace llvm;
44
45#define DEBUG_TYPE "WinCOFFStreamer"
46
47/// MCExpr that represents the physical number for the sections that contains
48/// a symbol.
50 const MCSymbol &SectionSymbol;
51 const WinCOFFObjectWriter &Writer;
52
53 MCCOFFSectionNumberTargetExpr(const MCSymbol &SectionSymbol_,
54 const WinCOFFObjectWriter &Writer_)
55 : SectionSymbol(SectionSymbol_), Writer(Writer_) {}
56
57public:
59 create(const MCSymbol &SectionSymbol, const WinCOFFObjectWriter &Writer,
60 MCContext &Ctx) {
61 return new (Ctx) MCCOFFSectionNumberTargetExpr(SectionSymbol, Writer);
62 }
63
64 void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override {
65 OS << ":secnum:";
66 SectionSymbol.print(OS, MAI);
67 }
68
70 const MCFixup *Fixup) const override {
71 auto sectionNumber = Writer.getSectionNumber(SectionSymbol.getSection());
72 assert(sectionNumber != 0 &&
73 "Containing section was not assigned a number");
74 Res = MCValue::get(sectionNumber);
75 return true;
76 }
77
78 void visitUsedExpr(MCStreamer &Streamer) const override {
79 // Contains no sub-expressions.
80 }
81
83 return SectionSymbol.getFragment();
84 }
85
86 void fixELFSymbolsInTLSFixups(MCAssembler &) const override {
87 llvm_unreachable("Not supported for ELF");
88 }
89};
90
91/// MCExpr that represents the offset to a symbol from the beginning of its
92/// section.
94 const MCSymbol &Symbol;
95
96 MCCOFFSectionOffsetTargetExpr(const MCSymbol &Symbol_) : Symbol(Symbol_) {}
97
98public:
100 MCContext &Ctx) {
101 return new (Ctx) MCCOFFSectionOffsetTargetExpr(Symbol);
102 }
103
104 void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override {
105 OS << ":secoffset:";
106 Symbol.print(OS, MAI);
107 }
108
110 const MCFixup *Fixup) const override {
111 uint64_t CallsiteOffset = 0;
112 if (!Asm->getSymbolOffset(Symbol, CallsiteOffset)) {
113 return true;
114 }
115 Res = MCValue::get(CallsiteOffset);
116 return true;
117 }
118
119 void visitUsedExpr(MCStreamer &Streamer) const override {
120 // Contains no sub-expressions.
121 }
122
124 return Symbol.getFragment();
125 }
126
127 void fixELFSymbolsInTLSFixups(MCAssembler &) const override {
128 llvm_unreachable("Not supported for ELF");
129 }
130};
131
133 std::unique_ptr<MCAsmBackend> MAB,
134 std::unique_ptr<MCCodeEmitter> CE,
135 std::unique_ptr<MCObjectWriter> OW)
136 : MCObjectStreamer(Context, std::move(MAB), std::move(OW), std::move(CE)),
137 CurSymbol(nullptr) {
138 auto *TO = Context.getTargetOptions();
139 if (TO && TO->MCIncrementalLinkerCompatible)
141}
142
144 return static_cast<WinCOFFObjectWriter &>(getAssembler().getWriter());
145}
146
148 const MCSubtargetInfo &STI) {
150
152 SmallString<256> Code;
153 getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
154
155 // Add the fixups and data.
156 for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
157 Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size());
158 DF->getFixups().push_back(Fixups[i]);
159 }
160 DF->setHasInstructions(STI);
161 DF->appendContents(Code);
162}
163
165 const MCSubtargetInfo &STI) {
166 // FIXME: this is identical to the ELF one.
167 // This emulates the same behavior of GNU as. This makes it easier
168 // to compare the output as the major sections are in the same order.
169 switchSection(getContext().getObjectFileInfo()->getTextSection());
170 emitCodeAlignment(Align(4), &STI);
171
172 switchSection(getContext().getObjectFileInfo()->getDataSection());
173 emitCodeAlignment(Align(4), &STI);
174
175 switchSection(getContext().getObjectFileInfo()->getBSSSection());
176 emitCodeAlignment(Align(4), &STI);
177
178 switchSection(getContext().getObjectFileInfo()->getTextSection());
179}
180
182 changeSectionImpl(Section, Subsection);
183 // Ensure that the first and the second symbols relative to the section are
184 // the section symbol and the COMDAT symbol.
185 getAssembler().registerSymbol(*Section->getBeginSymbol());
186 if (auto *Sym = cast<MCSectionCOFF>(Section)->getCOMDATSymbol())
188}
189
191 auto *Symbol = cast<MCSymbolCOFF>(S);
192 MCObjectStreamer::emitLabel(Symbol, Loc);
193}
194
196 // Let the target do whatever target specific stuff it needs to do.
198
199 switch (Flag) {
200 // None of these require COFF specific handling.
202 case MCAF_Code16:
203 case MCAF_Code32:
204 case MCAF_Code64:
205 break;
207 llvm_unreachable("COFF doesn't support .subsections_via_symbols");
208 }
209}
210
212 llvm_unreachable("not implemented");
213}
214
217 auto *Symbol = cast<MCSymbolCOFF>(S);
218 getAssembler().registerSymbol(*Symbol);
219
220 switch (Attribute) {
221 default: return false;
223 case MCSA_Weak:
224 Symbol->setWeakExternalCharacteristics(COFF::IMAGE_WEAK_EXTERN_SEARCH_ALIAS);
225 Symbol->setExternal(true);
226 break;
227 case MCSA_WeakAntiDep:
228 Symbol->setWeakExternalCharacteristics(COFF::IMAGE_WEAK_EXTERN_ANTI_DEPENDENCY);
229 Symbol->setExternal(true);
230 Symbol->setIsWeakExternal(true);
231 break;
232 case MCSA_Global:
233 Symbol->setExternal(true);
234 break;
235 case MCSA_AltEntry:
236 llvm_unreachable("COFF doesn't support the .alt_entry attribute");
237 }
238
239 return true;
240}
241
242void MCWinCOFFStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
243 llvm_unreachable("not implemented");
244}
245
247 auto *Symbol = cast<MCSymbolCOFF>(S);
248 if (CurSymbol)
249 Error("starting a new symbol definition without completing the "
250 "previous one");
251 CurSymbol = Symbol;
252}
253
255 if (!CurSymbol) {
256 Error("storage class specified outside of symbol definition");
257 return;
258 }
259
261 Error("storage class value '" + Twine(StorageClass) +
262 "' out of range");
263 return;
264 }
265
267 cast<MCSymbolCOFF>(CurSymbol)->setClass((uint16_t)StorageClass);
268}
269
271 if (!CurSymbol) {
272 Error("symbol type specified outside of a symbol definition");
273 return;
274 }
275
276 if (Type & ~0xffff) {
277 Error("type value '" + Twine(Type) + "' out of range");
278 return;
279 }
280
282 cast<MCSymbolCOFF>(CurSymbol)->setType((uint16_t)Type);
283}
284
286 if (!CurSymbol)
287 Error("ending symbol definition without starting one");
288 CurSymbol = nullptr;
289}
290
292 // SafeSEH is a feature specific to 32-bit x86. It does not exist (and is
293 // unnecessary) on all platforms which use table-based exception dispatch.
294 if (getContext().getTargetTriple().getArch() != Triple::x86)
295 return;
296
297 const MCSymbolCOFF *CSymbol = cast<MCSymbolCOFF>(Symbol);
298 if (CSymbol->isSafeSEH())
299 return;
300
302 changeSection(SXData);
303 SXData->ensureMinAlignment(Align(4));
304
305 insert(getContext().allocFragment<MCSymbolIdFragment>(Symbol));
306 getAssembler().registerSymbol(*Symbol);
307 CSymbol->setIsSafeSEH();
308
309 // The Microsoft linker requires that the symbol type of a handler be
310 // function. Go ahead and oblige it here.
313}
314
317 Sec->ensureMinAlignment(Align(4));
318
319 insert(getContext().allocFragment<MCSymbolIdFragment>(Symbol));
320 getAssembler().registerSymbol(*Symbol);
321}
322
324 visitUsedSymbol(*Symbol);
326 const MCSymbolRefExpr *SRE = MCSymbolRefExpr::create(Symbol, getContext());
327 MCFixup Fixup = MCFixup::create(DF->getContents().size(), SRE, FK_SecRel_2);
328 DF->getFixups().push_back(Fixup);
329 DF->appendContents(2, 0);
330}
331
334 visitUsedSymbol(*Symbol);
336 // Create Symbol A for the relocation relative reference.
337 const MCExpr *MCE = MCSymbolRefExpr::create(Symbol, getContext());
338 // Add the constant offset, if given.
339 if (Offset)
342 // Build the secrel32 relocation.
343 MCFixup Fixup = MCFixup::create(DF->getContents().size(), MCE, FK_SecRel_4);
344 // Record the relocation.
345 DF->getFixups().push_back(Fixup);
346 // Emit 4 bytes (zeros) to the object file.
347 DF->appendContents(4, 0);
348}
349
351 int64_t Offset) {
352 visitUsedSymbol(*Symbol);
354 // Create Symbol A for the relocation relative reference.
355 const MCExpr *MCE = MCSymbolRefExpr::create(
357 // Add the constant offset, if given.
358 if (Offset)
361 // Build the imgrel relocation.
362 MCFixup Fixup = MCFixup::create(DF->getContents().size(), MCE, FK_Data_4);
363 // Record the relocation.
364 DF->getFixups().push_back(Fixup);
365 // Emit 4 bytes (zeros) to the object file.
366 DF->appendContents(4, 0);
367}
368
370 visitUsedSymbol(*Symbol);
372 // Create Symbol for section number.
374 *Symbol, this->getWriter(), getContext());
375 // Build the relocation.
376 MCFixup Fixup = MCFixup::create(DF->getContents().size(), MCE, FK_Data_4);
377 // Record the relocation.
378 DF->getFixups().push_back(Fixup);
379 // Emit 4 bytes (zeros) to the object file.
380 DF->appendContents(4, 0);
381}
382
384 visitUsedSymbol(*Symbol);
386 // Create Symbol for section offset.
387 const MCExpr *MCE =
389 // Build the relocation.
390 MCFixup Fixup = MCFixup::create(DF->getContents().size(), MCE, FK_Data_4);
391 // Record the relocation.
392 DF->getFixups().push_back(Fixup);
393 // Emit 4 bytes (zeros) to the object file.
394 DF->appendContents(4, 0);
395}
396
398 Align ByteAlignment) {
399 auto *Symbol = cast<MCSymbolCOFF>(S);
400
401 const Triple &T = getContext().getTargetTriple();
402 if (T.isWindowsMSVCEnvironment()) {
403 if (ByteAlignment > 32)
404 report_fatal_error("alignment is limited to 32-bytes");
405
406 // Round size up to alignment so that we will honor the alignment request.
407 Size = std::max(Size, ByteAlignment.value());
408 }
409
410 getAssembler().registerSymbol(*Symbol);
411 Symbol->setExternal(true);
412 Symbol->setCommon(Size, ByteAlignment);
413
414 if (!T.isWindowsMSVCEnvironment() && ByteAlignment > 1) {
418
419 OS << " -aligncomm:\"" << Symbol->getName() << "\","
420 << Log2_32_Ceil(ByteAlignment.value());
421
422 pushSection();
425 popSection();
426 }
427}
428
430 Align ByteAlignment) {
431 auto *Symbol = cast<MCSymbolCOFF>(S);
432
434 pushSection();
435 switchSection(Section);
436 emitValueToAlignment(ByteAlignment, 0, 1, 0);
437 emitLabel(Symbol);
438 Symbol->setExternal(false);
440 popSection();
441}
442
444 const MCSymbol *Symbol) {
445 auto *Alias = cast<MCSymbolCOFF>(AliasS);
447
448 getAssembler().registerSymbol(*Symbol);
449 Alias->setVariableValue(MCSymbolRefExpr::create(
451}
452
454 uint64_t Size, Align ByteAlignment,
455 SMLoc Loc) {
456 llvm_unreachable("not implemented");
457}
458
460 uint64_t Size, Align ByteAlignment) {
461 llvm_unreachable("not implemented");
462}
463
464// TODO: Implement this if you want to emit .comment section in COFF obj files.
466 llvm_unreachable("not implemented");
467}
468
470 llvm_unreachable("not implemented");
471}
472
474 const MCSymbolRefExpr *To,
475 uint64_t Count) {
476 // Ignore temporary symbols for now.
477 if (!From->getSymbol().isTemporary() && !To->getSymbol().isTemporary())
478 getWriter().getCGProfile().push_back({From, To, Count});
479}
480
482 const MCSymbol *S = &SRE->getSymbol();
483 if (getAssembler().registerSymbol(*S))
484 cast<MCSymbolCOFF>(S)->setExternal(true);
485}
486
489 MCAssembler &Asm = getAssembler();
490 if (Asm.getWriter().getEmitAddrsigSection()) {
491 // Register the section.
492 switchSection(Asm.getContext().getCOFFSection(".llvm_addrsig",
494 }
495 if (!Asm.getWriter().getCGProfile().empty()) {
496 for (auto &E : Asm.getWriter().getCGProfile()) {
499 }
500 switchSection(Asm.getContext().getCOFFSection(".llvm.call-graph-profile",
502 }
503
505}
506
507void MCWinCOFFStreamer::Error(const Twine &Msg) const {
508 getContext().reportError(SMLoc(), Msg);
509}
BlockVerifier::State From
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
uint64_t Size
Symbol * Sym
Definition: ELF_riscv.cpp:479
PowerPC TLS Dynamic Call Fixup
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file defines the SmallString class.
This file defines the SmallVector class.
MCExpr that represents the physical number for the sections that contains a symbol.
void fixELFSymbolsInTLSFixups(MCAssembler &) const override
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
static MCCOFFSectionNumberTargetExpr * create(const MCSymbol &SectionSymbol, const WinCOFFObjectWriter &Writer, MCContext &Ctx)
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const override
void visitUsedExpr(MCStreamer &Streamer) const override
MCFragment * findAssociatedFragment() const override
MCExpr that represents the offset to a symbol from the beginning of its section.
MCFragment * findAssociatedFragment() const override
static MCCOFFSectionOffsetTargetExpr * create(const MCSymbol &Symbol, MCContext &Ctx)
void fixELFSymbolsInTLSFixups(MCAssembler &) const override
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, const MCFixup *Fixup) const override
void visitUsedExpr(MCStreamer &Streamer) const override
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
virtual void handleAssemblerFlag(MCAssemblerFlag Flag)
Handle any target-specific assembler flags. By default, do nothing.
Definition: MCAsmBackend.h:226
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
MCObjectWriter & getWriter() const
Definition: MCAssembler.h:192
MCCodeEmitter & getEmitter() const
Definition: MCAssembler.h:190
MCAsmBackend & getBackend() const
Definition: MCAssembler.h:188
bool registerSymbol(const MCSymbol &Symbol)
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:537
virtual void encodeInstruction(const MCInst &Inst, SmallVectorImpl< char > &CB, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
Encode the given Inst to bytes and append to CB.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:222
Context object for machine code objects.
Definition: MCContext.h:83
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:416
CodeViewContext & getCVContext()
Definition: MCContext.cpp:1017
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1072
const MCTargetOptions * getTargetOptions() const
Definition: MCContext.h:420
const Triple & getTargetTriple() const
Definition: MCContext.h:400
Fragment for data and encoded instructions.
Definition: MCFragment.h:213
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:71
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
Definition: MCFixup.h:87
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:185
MCSection * getSXDataSection() const
MCSection * getBSSSection() const
MCSection * getDrectveSection() const
Streaming object file generation interface.
void emitValueToAlignment(Align Alignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0) override
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
MCDataFragment * getOrCreateDataFragment(const MCSubtargetInfo *STI=nullptr)
Get a data fragment to write into, creating a new one if the current fragment is not a data fragment.
MCAssembler & getAssembler()
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
bool changeSectionImpl(MCSection *Section, uint32_t Subsection)
void visitUsedSymbol(const MCSymbol &Sym) override
void insert(MCFragment *F)
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
void finishImpl() override
Streamer specific finalization.
void emitCodeAlignment(Align ByteAlignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit=0) override
Emit nops until the byte alignment ByteAlignment is reached.
SmallVector< CGProfileEntry, 0 > & getCGProfile()
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:36
void ensureMinAlignment(Align MinAlignment)
Makes sure that Alignment is at least MinAlignment.
Definition: MCSection.h:150
Streaming machine code generation interface.
Definition: MCStreamer.h:213
virtual bool popSection()
Restore the current and previous section from the section stack.
MCContext & getContext() const
Definition: MCStreamer.h:300
void pushSection()
Save the current and previous section on the section stack.
Definition: MCStreamer.h:418
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:400
void emitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Definition: MCStreamer.cpp:229
Generic base class for all target subtargets.
void setIsSafeSEH() const
Definition: MCSymbolCOFF.h:65
void setType(uint16_t Ty) const
Definition: MCSymbolCOFF.h:39
bool isSafeSEH() const
Definition: MCSymbolCOFF.h:62
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:192
const MCSymbol & getSymbol() const
Definition: MCExpr.h:411
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:398
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
void setExternal(bool Value) const
Definition: MCSymbol.h:408
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
Definition: MCSymbol.h:222
This is an extension point for target-specific MCExpr subclasses to implement.
Definition: MCExpr.h:657
This represents an "assembler immediate".
Definition: MCValue.h:36
static MCValue get(const MCSymbolRefExpr *SymA, const MCSymbolRefExpr *SymB=nullptr, int64_t Val=0, uint32_t RefKind=0)
Definition: MCValue.h:59
void emitCOFFSectionIndex(MCSymbol const *Symbol) override
Emits a COFF section index.
void emitAssemblerFlag(MCAssemblerFlag Flag) override
Note in the output the specified Flag.
void finalizeCGProfileEntry(const MCSymbolRefExpr *&S)
void emitThumbFunc(MCSymbol *Func) override
Note in the output that the specified Func is a Thumb mode function (ARM target only).
void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) override
Emits a COFF image relative relocation.
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
void emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment, SMLoc Loc=SMLoc()) override
Emit the zerofill section and an optional symbol.
void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override
Emit an weak reference from Alias to Symbol.
void initSections(bool NoExecStack, const MCSubtargetInfo &STI) override
Create the default sections and set the initial one.
void emitCOFFSafeSEH(MCSymbol const *Symbol) override
void emitCOFFSecOffset(MCSymbol const *Symbol) override
Emits the offset of the symbol from the beginning of the section during object writing (i....
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment) override
Emit a common symbol.
void endCOFFSymbolDef() override
Marks the end of the symbol definition.
MCWinCOFFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCObjectWriter > OW)
void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment) override
Emit a thread local bss (.tbss) symbol.
void changeSection(MCSection *Section, uint32_t Subsection=0) override
This is called by popSection and switchSection, if the current section changes.
void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override
Emits a COFF section relative relocation.
void finishImpl() override
Streamer specific finalization.
void emitIdent(StringRef IdentString) override
Emit the "identifiers" directive.
void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count) override
void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment) override
Emit a local common (.lcomm) symbol.
WinCOFFObjectWriter & getWriter()
void emitCOFFSymbolType(int Type) override
Emit the type of the symbol.
void emitCOFFSecNumber(MCSymbol const *Symbol) override
Emits the physical number of the section containing the given symbol as assigned during object writin...
void emitWinEHHandlerData(SMLoc Loc) override
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override
Set the DescValue for the Symbol.
const MCSymbol * CurSymbol
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
void emitCOFFSymbolIndex(MCSymbol const *Symbol) override
Emits the symbol table index of a Symbol into the current section.
void beginCOFFSymbolDef(MCSymbol const *Symbol) override
Start emitting COFF symbol definition.
void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) override
void emitCOFFSymbolStorageClass(int StorageClass) override
Emit the storage class of the symbol.
Represents a location in source code.
Definition: SMLoc.h:23
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
int getSectionNumber(const MCSection &Section) const
void setIncrementalLinkerCompatible(bool Value)
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:691
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_SCN_LNK_REMOVE
Definition: COFF.h:307
@ SSC_Invalid
Definition: COFF.h:218
@ IMAGE_WEAK_EXTERN_SEARCH_ALIAS
Definition: COFF.h:489
@ IMAGE_WEAK_EXTERN_ANTI_DEPENDENCY
Definition: COFF.h:490
@ IMAGE_SYM_DTYPE_FUNCTION
A function that returns a base type.
Definition: COFF.h:275
@ SCT_COMPLEX_TYPE_SHIFT
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
Definition: COFF.h:279
StorageClass
Definition: XCOFF.h:170
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
Definition: MathExtras.h:353
@ Offset
Definition: DWP.cpp:480
static Error getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:167
@ FK_SecRel_2
A two-byte section relative fixup.
Definition: MCFixup.h:41
@ FK_Data_4
A four-byte fixup.
Definition: MCFixup.h:25
@ FK_SecRel_4
A four-byte section relative fixup.
Definition: MCFixup.h:42
MCAssemblerFlag
Definition: MCDirectives.h:53
@ MCAF_SyntaxUnified
.syntax (ARM/ELF)
Definition: MCDirectives.h:54
@ MCAF_Code64
.code64 (X86)
Definition: MCDirectives.h:58
@ MCAF_Code16
.code16 (X86) / .code 16 (ARM)
Definition: MCDirectives.h:56
@ MCAF_Code32
.code32 (X86) / .code 32 (ARM)
Definition: MCDirectives.h:57
@ MCAF_SubsectionsViaSymbols
.subsections_via_symbols (MachO)
Definition: MCDirectives.h:55
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1873
MCSymbolAttr
Definition: MCDirectives.h:18
@ MCSA_WeakReference
.weak_reference (MachO)
Definition: MCDirectives.h:47
@ MCSA_AltEntry
.alt_entry (MachO)
Definition: MCDirectives.h:41
@ MCSA_Weak
.weak
Definition: MCDirectives.h:45
@ MCSA_Global
.type _foo, @gnu_unique_object
Definition: MCDirectives.h:30
@ MCSA_WeakAntiDep
.weak_anti_dep (COFF)
Definition: MCDirectives.h:49
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39