xref: /minix3/external/bsd/llvm/dist/llvm/lib/MC/MCELFStreamer.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc //===- lib/MC/MCELFStreamer.cpp - ELF Object Output -----------------------===//
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc //                     The LLVM Compiler Infrastructure
4f4a2713aSLionel Sambuc //
5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7f4a2713aSLionel Sambuc //
8f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9f4a2713aSLionel Sambuc //
10f4a2713aSLionel Sambuc // This file assembles .s files and emits ELF .o object files.
11f4a2713aSLionel Sambuc //
12f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc #include "llvm/MC/MCELFStreamer.h"
15f4a2713aSLionel Sambuc #include "llvm/ADT/STLExtras.h"
16*0a6a1f1dSLionel Sambuc #include "llvm/ADT/SmallPtrSet.h"
17*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCAsmBackend.h"
18*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCAsmInfo.h"
19f4a2713aSLionel Sambuc #include "llvm/MC/MCAssembler.h"
20f4a2713aSLionel Sambuc #include "llvm/MC/MCCodeEmitter.h"
21f4a2713aSLionel Sambuc #include "llvm/MC/MCContext.h"
22f4a2713aSLionel Sambuc #include "llvm/MC/MCELF.h"
23f4a2713aSLionel Sambuc #include "llvm/MC/MCELFSymbolFlags.h"
24f4a2713aSLionel Sambuc #include "llvm/MC/MCExpr.h"
25f4a2713aSLionel Sambuc #include "llvm/MC/MCInst.h"
26*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCObjectFileInfo.h"
27f4a2713aSLionel Sambuc #include "llvm/MC/MCObjectStreamer.h"
28f4a2713aSLionel Sambuc #include "llvm/MC/MCSection.h"
29f4a2713aSLionel Sambuc #include "llvm/MC/MCSectionELF.h"
30f4a2713aSLionel Sambuc #include "llvm/MC/MCSymbol.h"
31f4a2713aSLionel Sambuc #include "llvm/MC/MCValue.h"
32f4a2713aSLionel Sambuc #include "llvm/Support/Debug.h"
33f4a2713aSLionel Sambuc #include "llvm/Support/ELF.h"
34f4a2713aSLionel Sambuc #include "llvm/Support/ErrorHandling.h"
35f4a2713aSLionel Sambuc #include "llvm/Support/raw_ostream.h"
36f4a2713aSLionel Sambuc 
37f4a2713aSLionel Sambuc using namespace llvm;
38f4a2713aSLionel Sambuc 
~MCELFStreamer()39f4a2713aSLionel Sambuc MCELFStreamer::~MCELFStreamer() {
40f4a2713aSLionel Sambuc }
41f4a2713aSLionel Sambuc 
InitSections(bool NoExecStack)42*0a6a1f1dSLionel Sambuc void MCELFStreamer::InitSections(bool NoExecStack) {
43f4a2713aSLionel Sambuc   // This emulates the same behavior of GNU as. This makes it easier
44f4a2713aSLionel Sambuc   // to compare the output as the major sections are in the same order.
45*0a6a1f1dSLionel Sambuc   MCContext &Ctx = getContext();
46*0a6a1f1dSLionel Sambuc   SwitchSection(Ctx.getObjectFileInfo()->getTextSection());
47*0a6a1f1dSLionel Sambuc   EmitCodeAlignment(4);
48*0a6a1f1dSLionel Sambuc 
49*0a6a1f1dSLionel Sambuc   SwitchSection(Ctx.getObjectFileInfo()->getDataSection());
50*0a6a1f1dSLionel Sambuc   EmitCodeAlignment(4);
51*0a6a1f1dSLionel Sambuc 
52*0a6a1f1dSLionel Sambuc   SwitchSection(Ctx.getObjectFileInfo()->getBSSSection());
53*0a6a1f1dSLionel Sambuc   EmitCodeAlignment(4);
54*0a6a1f1dSLionel Sambuc 
55*0a6a1f1dSLionel Sambuc   SwitchSection(Ctx.getObjectFileInfo()->getTextSection());
56*0a6a1f1dSLionel Sambuc 
57*0a6a1f1dSLionel Sambuc   if (NoExecStack)
58*0a6a1f1dSLionel Sambuc     SwitchSection(Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx));
59f4a2713aSLionel Sambuc }
60f4a2713aSLionel Sambuc 
EmitLabel(MCSymbol * Symbol)61f4a2713aSLionel Sambuc void MCELFStreamer::EmitLabel(MCSymbol *Symbol) {
62f4a2713aSLionel Sambuc   assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
63f4a2713aSLionel Sambuc 
64f4a2713aSLionel Sambuc   MCObjectStreamer::EmitLabel(Symbol);
65f4a2713aSLionel Sambuc 
66f4a2713aSLionel Sambuc   const MCSectionELF &Section =
67f4a2713aSLionel Sambuc     static_cast<const MCSectionELF&>(Symbol->getSection());
68f4a2713aSLionel Sambuc   MCSymbolData &SD = getAssembler().getSymbolData(*Symbol);
69f4a2713aSLionel Sambuc   if (Section.getFlags() & ELF::SHF_TLS)
70f4a2713aSLionel Sambuc     MCELF::SetType(SD, ELF::STT_TLS);
71f4a2713aSLionel Sambuc }
72f4a2713aSLionel Sambuc 
EmitAssemblerFlag(MCAssemblerFlag Flag)73f4a2713aSLionel Sambuc void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
74*0a6a1f1dSLionel Sambuc   // Let the target do whatever target specific stuff it needs to do.
75*0a6a1f1dSLionel Sambuc   getAssembler().getBackend().handleAssemblerFlag(Flag);
76*0a6a1f1dSLionel Sambuc   // Do any generic stuff we need to do.
77f4a2713aSLionel Sambuc   switch (Flag) {
78f4a2713aSLionel Sambuc   case MCAF_SyntaxUnified: return; // no-op here.
79f4a2713aSLionel Sambuc   case MCAF_Code16: return; // Change parsing mode; no-op here.
80f4a2713aSLionel Sambuc   case MCAF_Code32: return; // Change parsing mode; no-op here.
81f4a2713aSLionel Sambuc   case MCAF_Code64: return; // Change parsing mode; no-op here.
82f4a2713aSLionel Sambuc   case MCAF_SubsectionsViaSymbols:
83f4a2713aSLionel Sambuc     getAssembler().setSubsectionsViaSymbols(true);
84f4a2713aSLionel Sambuc     return;
85f4a2713aSLionel Sambuc   }
86f4a2713aSLionel Sambuc 
87f4a2713aSLionel Sambuc   llvm_unreachable("invalid assembler flag!");
88f4a2713aSLionel Sambuc }
89f4a2713aSLionel Sambuc 
ChangeSection(const MCSection * Section,const MCExpr * Subsection)90f4a2713aSLionel Sambuc void MCELFStreamer::ChangeSection(const MCSection *Section,
91f4a2713aSLionel Sambuc                                   const MCExpr *Subsection) {
92f4a2713aSLionel Sambuc   MCSectionData *CurSection = getCurrentSectionData();
93f4a2713aSLionel Sambuc   if (CurSection && CurSection->isBundleLocked())
94f4a2713aSLionel Sambuc     report_fatal_error("Unterminated .bundle_lock when changing a section");
95*0a6a1f1dSLionel Sambuc 
96*0a6a1f1dSLionel Sambuc   MCAssembler &Asm = getAssembler();
97*0a6a1f1dSLionel Sambuc   auto *SectionELF = static_cast<const MCSectionELF *>(Section);
98*0a6a1f1dSLionel Sambuc   const MCSymbol *Grp = SectionELF->getGroup();
99f4a2713aSLionel Sambuc   if (Grp)
100*0a6a1f1dSLionel Sambuc     Asm.getOrCreateSymbolData(*Grp);
101*0a6a1f1dSLionel Sambuc 
102f4a2713aSLionel Sambuc   this->MCObjectStreamer::ChangeSection(Section, Subsection);
103*0a6a1f1dSLionel Sambuc   MCSymbol *SectionSymbol = getContext().getOrCreateSectionSymbol(*SectionELF);
104*0a6a1f1dSLionel Sambuc   if (SectionSymbol->isUndefined()) {
105*0a6a1f1dSLionel Sambuc     EmitLabel(SectionSymbol);
106*0a6a1f1dSLionel Sambuc     MCELF::SetType(Asm.getSymbolData(*SectionSymbol), ELF::STT_SECTION);
107*0a6a1f1dSLionel Sambuc   }
108f4a2713aSLionel Sambuc }
109f4a2713aSLionel Sambuc 
EmitWeakReference(MCSymbol * Alias,const MCSymbol * Symbol)110f4a2713aSLionel Sambuc void MCELFStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {
111f4a2713aSLionel Sambuc   getAssembler().getOrCreateSymbolData(*Symbol);
112*0a6a1f1dSLionel Sambuc   const MCExpr *Value = MCSymbolRefExpr::Create(
113*0a6a1f1dSLionel Sambuc       Symbol, MCSymbolRefExpr::VK_WEAKREF, getContext());
114f4a2713aSLionel Sambuc   Alias->setVariableValue(Value);
115f4a2713aSLionel Sambuc }
116f4a2713aSLionel Sambuc 
117f4a2713aSLionel Sambuc // When GNU as encounters more than one .type declaration for an object it seems
118f4a2713aSLionel Sambuc // to use a mechanism similar to the one below to decide which type is actually
119f4a2713aSLionel Sambuc // used in the object file.  The greater of T1 and T2 is selected based on the
120f4a2713aSLionel Sambuc // following ordering:
121f4a2713aSLionel Sambuc //  STT_NOTYPE < STT_OBJECT < STT_FUNC < STT_GNU_IFUNC < STT_TLS < anything else
122f4a2713aSLionel Sambuc // If neither T1 < T2 nor T2 < T1 according to this ordering, use T2 (the user
123f4a2713aSLionel Sambuc // provided type).
CombineSymbolTypes(unsigned T1,unsigned T2)124f4a2713aSLionel Sambuc static unsigned CombineSymbolTypes(unsigned T1, unsigned T2) {
125f4a2713aSLionel Sambuc   unsigned TypeOrdering[] = {ELF::STT_NOTYPE, ELF::STT_OBJECT, ELF::STT_FUNC,
126f4a2713aSLionel Sambuc                              ELF::STT_GNU_IFUNC, ELF::STT_TLS};
127f4a2713aSLionel Sambuc   for (unsigned i = 0; i != array_lengthof(TypeOrdering); ++i) {
128f4a2713aSLionel Sambuc     if (T1 == TypeOrdering[i])
129f4a2713aSLionel Sambuc       return T2;
130f4a2713aSLionel Sambuc     if (T2 == TypeOrdering[i])
131f4a2713aSLionel Sambuc       return T1;
132f4a2713aSLionel Sambuc   }
133f4a2713aSLionel Sambuc 
134f4a2713aSLionel Sambuc   return T2;
135f4a2713aSLionel Sambuc }
136f4a2713aSLionel Sambuc 
EmitSymbolAttribute(MCSymbol * Symbol,MCSymbolAttr Attribute)137f4a2713aSLionel Sambuc bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
138f4a2713aSLionel Sambuc                                         MCSymbolAttr Attribute) {
139f4a2713aSLionel Sambuc   // Indirect symbols are handled differently, to match how 'as' handles
140f4a2713aSLionel Sambuc   // them. This makes writing matching .o files easier.
141f4a2713aSLionel Sambuc   if (Attribute == MCSA_IndirectSymbol) {
142f4a2713aSLionel Sambuc     // Note that we intentionally cannot use the symbol data here; this is
143f4a2713aSLionel Sambuc     // important for matching the string table that 'as' generates.
144f4a2713aSLionel Sambuc     IndirectSymbolData ISD;
145f4a2713aSLionel Sambuc     ISD.Symbol = Symbol;
146f4a2713aSLionel Sambuc     ISD.SectionData = getCurrentSectionData();
147f4a2713aSLionel Sambuc     getAssembler().getIndirectSymbols().push_back(ISD);
148f4a2713aSLionel Sambuc     return true;
149f4a2713aSLionel Sambuc   }
150f4a2713aSLionel Sambuc 
151f4a2713aSLionel Sambuc   // Adding a symbol attribute always introduces the symbol, note that an
152f4a2713aSLionel Sambuc   // important side effect of calling getOrCreateSymbolData here is to register
153f4a2713aSLionel Sambuc   // the symbol with the assembler.
154f4a2713aSLionel Sambuc   MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
155f4a2713aSLionel Sambuc 
156f4a2713aSLionel Sambuc   // The implementation of symbol attributes is designed to match 'as', but it
157f4a2713aSLionel Sambuc   // leaves much to desired. It doesn't really make sense to arbitrarily add and
158f4a2713aSLionel Sambuc   // remove flags, but 'as' allows this (in particular, see .desc).
159f4a2713aSLionel Sambuc   //
160f4a2713aSLionel Sambuc   // In the future it might be worth trying to make these operations more well
161f4a2713aSLionel Sambuc   // defined.
162f4a2713aSLionel Sambuc   switch (Attribute) {
163f4a2713aSLionel Sambuc   case MCSA_LazyReference:
164f4a2713aSLionel Sambuc   case MCSA_Reference:
165f4a2713aSLionel Sambuc   case MCSA_SymbolResolver:
166f4a2713aSLionel Sambuc   case MCSA_PrivateExtern:
167f4a2713aSLionel Sambuc   case MCSA_WeakDefinition:
168f4a2713aSLionel Sambuc   case MCSA_WeakDefAutoPrivate:
169f4a2713aSLionel Sambuc   case MCSA_Invalid:
170f4a2713aSLionel Sambuc   case MCSA_IndirectSymbol:
171f4a2713aSLionel Sambuc     return false;
172f4a2713aSLionel Sambuc 
173f4a2713aSLionel Sambuc   case MCSA_NoDeadStrip:
174f4a2713aSLionel Sambuc   case MCSA_ELF_TypeGnuUniqueObject:
175f4a2713aSLionel Sambuc     // Ignore for now.
176f4a2713aSLionel Sambuc     break;
177f4a2713aSLionel Sambuc 
178f4a2713aSLionel Sambuc   case MCSA_Global:
179f4a2713aSLionel Sambuc     MCELF::SetBinding(SD, ELF::STB_GLOBAL);
180f4a2713aSLionel Sambuc     SD.setExternal(true);
181f4a2713aSLionel Sambuc     BindingExplicitlySet.insert(Symbol);
182f4a2713aSLionel Sambuc     break;
183f4a2713aSLionel Sambuc 
184f4a2713aSLionel Sambuc   case MCSA_WeakReference:
185f4a2713aSLionel Sambuc   case MCSA_Weak:
186f4a2713aSLionel Sambuc     MCELF::SetBinding(SD, ELF::STB_WEAK);
187f4a2713aSLionel Sambuc     SD.setExternal(true);
188f4a2713aSLionel Sambuc     BindingExplicitlySet.insert(Symbol);
189f4a2713aSLionel Sambuc     break;
190f4a2713aSLionel Sambuc 
191f4a2713aSLionel Sambuc   case MCSA_Local:
192f4a2713aSLionel Sambuc     MCELF::SetBinding(SD, ELF::STB_LOCAL);
193f4a2713aSLionel Sambuc     SD.setExternal(false);
194f4a2713aSLionel Sambuc     BindingExplicitlySet.insert(Symbol);
195f4a2713aSLionel Sambuc     break;
196f4a2713aSLionel Sambuc 
197f4a2713aSLionel Sambuc   case MCSA_ELF_TypeFunction:
198f4a2713aSLionel Sambuc     MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD),
199f4a2713aSLionel Sambuc                                           ELF::STT_FUNC));
200f4a2713aSLionel Sambuc     break;
201f4a2713aSLionel Sambuc 
202f4a2713aSLionel Sambuc   case MCSA_ELF_TypeIndFunction:
203f4a2713aSLionel Sambuc     MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD),
204f4a2713aSLionel Sambuc                                           ELF::STT_GNU_IFUNC));
205f4a2713aSLionel Sambuc     break;
206f4a2713aSLionel Sambuc 
207f4a2713aSLionel Sambuc   case MCSA_ELF_TypeObject:
208f4a2713aSLionel Sambuc     MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD),
209f4a2713aSLionel Sambuc                                           ELF::STT_OBJECT));
210f4a2713aSLionel Sambuc     break;
211f4a2713aSLionel Sambuc 
212f4a2713aSLionel Sambuc   case MCSA_ELF_TypeTLS:
213f4a2713aSLionel Sambuc     MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD),
214f4a2713aSLionel Sambuc                                           ELF::STT_TLS));
215f4a2713aSLionel Sambuc     break;
216f4a2713aSLionel Sambuc 
217f4a2713aSLionel Sambuc   case MCSA_ELF_TypeCommon:
218f4a2713aSLionel Sambuc     // TODO: Emit these as a common symbol.
219f4a2713aSLionel Sambuc     MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD),
220f4a2713aSLionel Sambuc                                           ELF::STT_OBJECT));
221f4a2713aSLionel Sambuc     break;
222f4a2713aSLionel Sambuc 
223f4a2713aSLionel Sambuc   case MCSA_ELF_TypeNoType:
224f4a2713aSLionel Sambuc     MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD),
225f4a2713aSLionel Sambuc                                           ELF::STT_NOTYPE));
226f4a2713aSLionel Sambuc     break;
227f4a2713aSLionel Sambuc 
228f4a2713aSLionel Sambuc   case MCSA_Protected:
229f4a2713aSLionel Sambuc     MCELF::SetVisibility(SD, ELF::STV_PROTECTED);
230f4a2713aSLionel Sambuc     break;
231f4a2713aSLionel Sambuc 
232f4a2713aSLionel Sambuc   case MCSA_Hidden:
233f4a2713aSLionel Sambuc     MCELF::SetVisibility(SD, ELF::STV_HIDDEN);
234f4a2713aSLionel Sambuc     break;
235f4a2713aSLionel Sambuc 
236f4a2713aSLionel Sambuc   case MCSA_Internal:
237f4a2713aSLionel Sambuc     MCELF::SetVisibility(SD, ELF::STV_INTERNAL);
238f4a2713aSLionel Sambuc     break;
239f4a2713aSLionel Sambuc   }
240f4a2713aSLionel Sambuc 
241f4a2713aSLionel Sambuc   return true;
242f4a2713aSLionel Sambuc }
243f4a2713aSLionel Sambuc 
EmitCommonSymbol(MCSymbol * Symbol,uint64_t Size,unsigned ByteAlignment)244f4a2713aSLionel Sambuc void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
245f4a2713aSLionel Sambuc                                        unsigned ByteAlignment) {
246f4a2713aSLionel Sambuc   MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
247f4a2713aSLionel Sambuc 
248f4a2713aSLionel Sambuc   if (!BindingExplicitlySet.count(Symbol)) {
249f4a2713aSLionel Sambuc     MCELF::SetBinding(SD, ELF::STB_GLOBAL);
250f4a2713aSLionel Sambuc     SD.setExternal(true);
251f4a2713aSLionel Sambuc   }
252f4a2713aSLionel Sambuc 
253f4a2713aSLionel Sambuc   MCELF::SetType(SD, ELF::STT_OBJECT);
254f4a2713aSLionel Sambuc 
255f4a2713aSLionel Sambuc   if (MCELF::GetBinding(SD) == ELF_STB_Local) {
256f4a2713aSLionel Sambuc     const MCSection *Section = getAssembler().getContext().getELFSection(".bss",
257f4a2713aSLionel Sambuc                                                          ELF::SHT_NOBITS,
258f4a2713aSLionel Sambuc                                                          ELF::SHF_WRITE |
259f4a2713aSLionel Sambuc                                                          ELF::SHF_ALLOC,
260f4a2713aSLionel Sambuc                                                          SectionKind::getBSS());
261f4a2713aSLionel Sambuc 
262f4a2713aSLionel Sambuc     AssignSection(Symbol, Section);
263f4a2713aSLionel Sambuc 
264f4a2713aSLionel Sambuc     struct LocalCommon L = {&SD, Size, ByteAlignment};
265f4a2713aSLionel Sambuc     LocalCommons.push_back(L);
266f4a2713aSLionel Sambuc   } else {
267f4a2713aSLionel Sambuc     SD.setCommon(Size, ByteAlignment);
268f4a2713aSLionel Sambuc   }
269f4a2713aSLionel Sambuc 
270f4a2713aSLionel Sambuc   SD.setSize(MCConstantExpr::Create(Size, getContext()));
271f4a2713aSLionel Sambuc }
272f4a2713aSLionel Sambuc 
EmitELFSize(MCSymbol * Symbol,const MCExpr * Value)273f4a2713aSLionel Sambuc void MCELFStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
274f4a2713aSLionel Sambuc   MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
275f4a2713aSLionel Sambuc   SD.setSize(Value);
276f4a2713aSLionel Sambuc }
277f4a2713aSLionel Sambuc 
EmitLocalCommonSymbol(MCSymbol * Symbol,uint64_t Size,unsigned ByteAlignment)278f4a2713aSLionel Sambuc void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
279f4a2713aSLionel Sambuc                                           unsigned ByteAlignment) {
280f4a2713aSLionel Sambuc   // FIXME: Should this be caught and done earlier?
281f4a2713aSLionel Sambuc   MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
282f4a2713aSLionel Sambuc   MCELF::SetBinding(SD, ELF::STB_LOCAL);
283f4a2713aSLionel Sambuc   SD.setExternal(false);
284f4a2713aSLionel Sambuc   BindingExplicitlySet.insert(Symbol);
285f4a2713aSLionel Sambuc   EmitCommonSymbol(Symbol, Size, ByteAlignment);
286f4a2713aSLionel Sambuc }
287f4a2713aSLionel Sambuc 
EmitValueImpl(const MCExpr * Value,unsigned Size,const SMLoc & Loc)288*0a6a1f1dSLionel Sambuc void MCELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
289*0a6a1f1dSLionel Sambuc                                   const SMLoc &Loc) {
290f4a2713aSLionel Sambuc   if (getCurrentSectionData()->isBundleLocked())
291f4a2713aSLionel Sambuc     report_fatal_error("Emitting values inside a locked bundle is forbidden");
292f4a2713aSLionel Sambuc   fixSymbolsInTLSFixups(Value);
293*0a6a1f1dSLionel Sambuc   MCObjectStreamer::EmitValueImpl(Value, Size, Loc);
294f4a2713aSLionel Sambuc }
295f4a2713aSLionel Sambuc 
EmitValueToAlignment(unsigned ByteAlignment,int64_t Value,unsigned ValueSize,unsigned MaxBytesToEmit)296f4a2713aSLionel Sambuc void MCELFStreamer::EmitValueToAlignment(unsigned ByteAlignment,
297f4a2713aSLionel Sambuc                                          int64_t Value,
298f4a2713aSLionel Sambuc                                          unsigned ValueSize,
299f4a2713aSLionel Sambuc                                          unsigned MaxBytesToEmit) {
300f4a2713aSLionel Sambuc   if (getCurrentSectionData()->isBundleLocked())
301f4a2713aSLionel Sambuc     report_fatal_error("Emitting values inside a locked bundle is forbidden");
302f4a2713aSLionel Sambuc   MCObjectStreamer::EmitValueToAlignment(ByteAlignment, Value,
303f4a2713aSLionel Sambuc                                          ValueSize, MaxBytesToEmit);
304f4a2713aSLionel Sambuc }
305f4a2713aSLionel Sambuc 
306f4a2713aSLionel Sambuc // Add a symbol for the file name of this module. They start after the
307f4a2713aSLionel Sambuc // null symbol and don't count as normal symbol, i.e. a non-STT_FILE symbol
308f4a2713aSLionel Sambuc // with the same name may appear.
EmitFileDirective(StringRef Filename)309f4a2713aSLionel Sambuc void MCELFStreamer::EmitFileDirective(StringRef Filename) {
310f4a2713aSLionel Sambuc   getAssembler().addFileName(Filename);
311f4a2713aSLionel Sambuc }
312f4a2713aSLionel Sambuc 
EmitIdent(StringRef IdentString)313f4a2713aSLionel Sambuc void MCELFStreamer::EmitIdent(StringRef IdentString) {
314f4a2713aSLionel Sambuc   const MCSection *Comment = getAssembler().getContext().getELFSection(
315f4a2713aSLionel Sambuc       ".comment", ELF::SHT_PROGBITS, ELF::SHF_MERGE | ELF::SHF_STRINGS,
316f4a2713aSLionel Sambuc       SectionKind::getReadOnly(), 1, "");
317f4a2713aSLionel Sambuc   PushSection();
318f4a2713aSLionel Sambuc   SwitchSection(Comment);
319f4a2713aSLionel Sambuc   if (!SeenIdent) {
320f4a2713aSLionel Sambuc     EmitIntValue(0, 1);
321f4a2713aSLionel Sambuc     SeenIdent = true;
322f4a2713aSLionel Sambuc   }
323f4a2713aSLionel Sambuc   EmitBytes(IdentString);
324f4a2713aSLionel Sambuc   EmitIntValue(0, 1);
325f4a2713aSLionel Sambuc   PopSection();
326f4a2713aSLionel Sambuc }
327f4a2713aSLionel Sambuc 
fixSymbolsInTLSFixups(const MCExpr * expr)328f4a2713aSLionel Sambuc void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
329f4a2713aSLionel Sambuc   switch (expr->getKind()) {
330f4a2713aSLionel Sambuc   case MCExpr::Target:
331f4a2713aSLionel Sambuc     cast<MCTargetExpr>(expr)->fixELFSymbolsInTLSFixups(getAssembler());
332f4a2713aSLionel Sambuc     break;
333f4a2713aSLionel Sambuc   case MCExpr::Constant:
334f4a2713aSLionel Sambuc     break;
335f4a2713aSLionel Sambuc 
336f4a2713aSLionel Sambuc   case MCExpr::Binary: {
337f4a2713aSLionel Sambuc     const MCBinaryExpr *be = cast<MCBinaryExpr>(expr);
338f4a2713aSLionel Sambuc     fixSymbolsInTLSFixups(be->getLHS());
339f4a2713aSLionel Sambuc     fixSymbolsInTLSFixups(be->getRHS());
340f4a2713aSLionel Sambuc     break;
341f4a2713aSLionel Sambuc   }
342f4a2713aSLionel Sambuc 
343f4a2713aSLionel Sambuc   case MCExpr::SymbolRef: {
344f4a2713aSLionel Sambuc     const MCSymbolRefExpr &symRef = *cast<MCSymbolRefExpr>(expr);
345f4a2713aSLionel Sambuc     switch (symRef.getKind()) {
346f4a2713aSLionel Sambuc     default:
347f4a2713aSLionel Sambuc       return;
348f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_GOTTPOFF:
349f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_INDNTPOFF:
350f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_NTPOFF:
351f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_GOTNTPOFF:
352f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_TLSGD:
353f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_TLSLD:
354f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_TLSLDM:
355f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_TPOFF:
356f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_DTPOFF:
357f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_Mips_TLSGD:
358f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_Mips_GOTTPREL:
359f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_Mips_TPREL_HI:
360f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_Mips_TPREL_LO:
361f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_DTPMOD:
362f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_TPREL:
363f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_TPREL_LO:
364f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_TPREL_HI:
365f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_TPREL_HA:
366f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_TPREL_HIGHER:
367f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_TPREL_HIGHERA:
368f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_TPREL_HIGHEST:
369f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_TPREL_HIGHESTA:
370f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_DTPREL:
371f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_DTPREL_LO:
372f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_DTPREL_HI:
373f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_DTPREL_HA:
374f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHER:
375f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHERA:
376f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHEST:
377f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHESTA:
378f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_TPREL:
379f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_TPREL_LO:
380f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_TPREL_HI:
381f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_TPREL_HA:
382f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_DTPREL:
383f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_DTPREL_LO:
384f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_DTPREL_HI:
385f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_DTPREL_HA:
386f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_TLS:
387f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_TLSGD:
388f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_TLSGD_LO:
389f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HI:
390f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HA:
391f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_TLSGD:
392f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_TLSLD:
393f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_TLSLD_LO:
394f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HI:
395f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HA:
396f4a2713aSLionel Sambuc     case MCSymbolRefExpr::VK_PPC_TLSLD:
397f4a2713aSLionel Sambuc       break;
398f4a2713aSLionel Sambuc     }
399f4a2713aSLionel Sambuc     MCSymbolData &SD = getAssembler().getOrCreateSymbolData(symRef.getSymbol());
400f4a2713aSLionel Sambuc     MCELF::SetType(SD, ELF::STT_TLS);
401f4a2713aSLionel Sambuc     break;
402f4a2713aSLionel Sambuc   }
403f4a2713aSLionel Sambuc 
404f4a2713aSLionel Sambuc   case MCExpr::Unary:
405f4a2713aSLionel Sambuc     fixSymbolsInTLSFixups(cast<MCUnaryExpr>(expr)->getSubExpr());
406f4a2713aSLionel Sambuc     break;
407f4a2713aSLionel Sambuc   }
408f4a2713aSLionel Sambuc }
409f4a2713aSLionel Sambuc 
EmitInstToFragment(const MCInst & Inst,const MCSubtargetInfo & STI)410*0a6a1f1dSLionel Sambuc void MCELFStreamer::EmitInstToFragment(const MCInst &Inst,
411*0a6a1f1dSLionel Sambuc                                        const MCSubtargetInfo &STI) {
412*0a6a1f1dSLionel Sambuc   this->MCObjectStreamer::EmitInstToFragment(Inst, STI);
413f4a2713aSLionel Sambuc   MCRelaxableFragment &F = *cast<MCRelaxableFragment>(getCurrentFragment());
414f4a2713aSLionel Sambuc 
415f4a2713aSLionel Sambuc   for (unsigned i = 0, e = F.getFixups().size(); i != e; ++i)
416f4a2713aSLionel Sambuc     fixSymbolsInTLSFixups(F.getFixups()[i].getValue());
417f4a2713aSLionel Sambuc }
418f4a2713aSLionel Sambuc 
EmitInstToData(const MCInst & Inst,const MCSubtargetInfo & STI)419*0a6a1f1dSLionel Sambuc void MCELFStreamer::EmitInstToData(const MCInst &Inst,
420*0a6a1f1dSLionel Sambuc                                    const MCSubtargetInfo &STI) {
421f4a2713aSLionel Sambuc   MCAssembler &Assembler = getAssembler();
422f4a2713aSLionel Sambuc   SmallVector<MCFixup, 4> Fixups;
423f4a2713aSLionel Sambuc   SmallString<256> Code;
424f4a2713aSLionel Sambuc   raw_svector_ostream VecOS(Code);
425*0a6a1f1dSLionel Sambuc   Assembler.getEmitter().EncodeInstruction(Inst, VecOS, Fixups, STI);
426f4a2713aSLionel Sambuc   VecOS.flush();
427f4a2713aSLionel Sambuc 
428f4a2713aSLionel Sambuc   for (unsigned i = 0, e = Fixups.size(); i != e; ++i)
429f4a2713aSLionel Sambuc     fixSymbolsInTLSFixups(Fixups[i].getValue());
430f4a2713aSLionel Sambuc 
431f4a2713aSLionel Sambuc   // There are several possibilities here:
432f4a2713aSLionel Sambuc   //
433f4a2713aSLionel Sambuc   // If bundling is disabled, append the encoded instruction to the current data
434f4a2713aSLionel Sambuc   // fragment (or create a new such fragment if the current fragment is not a
435f4a2713aSLionel Sambuc   // data fragment).
436f4a2713aSLionel Sambuc   //
437f4a2713aSLionel Sambuc   // If bundling is enabled:
438f4a2713aSLionel Sambuc   // - If we're not in a bundle-locked group, emit the instruction into a
439f4a2713aSLionel Sambuc   //   fragment of its own. If there are no fixups registered for the
440f4a2713aSLionel Sambuc   //   instruction, emit a MCCompactEncodedInstFragment. Otherwise, emit a
441f4a2713aSLionel Sambuc   //   MCDataFragment.
442f4a2713aSLionel Sambuc   // - If we're in a bundle-locked group, append the instruction to the current
443f4a2713aSLionel Sambuc   //   data fragment because we want all the instructions in a group to get into
444f4a2713aSLionel Sambuc   //   the same fragment. Be careful not to do that for the first instruction in
445f4a2713aSLionel Sambuc   //   the group, though.
446f4a2713aSLionel Sambuc   MCDataFragment *DF;
447f4a2713aSLionel Sambuc 
448f4a2713aSLionel Sambuc   if (Assembler.isBundlingEnabled()) {
449f4a2713aSLionel Sambuc     MCSectionData *SD = getCurrentSectionData();
450f4a2713aSLionel Sambuc     if (SD->isBundleLocked() && !SD->isBundleGroupBeforeFirstInst())
451f4a2713aSLionel Sambuc       // If we are bundle-locked, we re-use the current fragment.
452f4a2713aSLionel Sambuc       // The bundle-locking directive ensures this is a new data fragment.
453f4a2713aSLionel Sambuc       DF = cast<MCDataFragment>(getCurrentFragment());
454f4a2713aSLionel Sambuc     else if (!SD->isBundleLocked() && Fixups.size() == 0) {
455f4a2713aSLionel Sambuc       // Optimize memory usage by emitting the instruction to a
456f4a2713aSLionel Sambuc       // MCCompactEncodedInstFragment when not in a bundle-locked group and
457f4a2713aSLionel Sambuc       // there are no fixups registered.
458f4a2713aSLionel Sambuc       MCCompactEncodedInstFragment *CEIF = new MCCompactEncodedInstFragment();
459f4a2713aSLionel Sambuc       insert(CEIF);
460f4a2713aSLionel Sambuc       CEIF->getContents().append(Code.begin(), Code.end());
461f4a2713aSLionel Sambuc       return;
462f4a2713aSLionel Sambuc     } else {
463f4a2713aSLionel Sambuc       DF = new MCDataFragment();
464f4a2713aSLionel Sambuc       insert(DF);
465f4a2713aSLionel Sambuc     }
466*0a6a1f1dSLionel Sambuc     if (SD->getBundleLockState() == MCSectionData::BundleLockedAlignToEnd) {
467*0a6a1f1dSLionel Sambuc       // If this fragment is for a group marked "align_to_end", set a flag
468*0a6a1f1dSLionel Sambuc       // in the fragment. This can happen after the fragment has already been
469*0a6a1f1dSLionel Sambuc       // created if there are nested bundle_align groups and an inner one
470*0a6a1f1dSLionel Sambuc       // is the one marked align_to_end.
471*0a6a1f1dSLionel Sambuc       DF->setAlignToBundleEnd(true);
472f4a2713aSLionel Sambuc     }
473f4a2713aSLionel Sambuc 
474f4a2713aSLionel Sambuc     // We're now emitting an instruction in a bundle group, so this flag has
475f4a2713aSLionel Sambuc     // to be turned off.
476f4a2713aSLionel Sambuc     SD->setBundleGroupBeforeFirstInst(false);
477f4a2713aSLionel Sambuc   } else {
478f4a2713aSLionel Sambuc     DF = getOrCreateDataFragment();
479f4a2713aSLionel Sambuc   }
480f4a2713aSLionel Sambuc 
481f4a2713aSLionel Sambuc   // Add the fixups and data.
482f4a2713aSLionel Sambuc   for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
483f4a2713aSLionel Sambuc     Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size());
484f4a2713aSLionel Sambuc     DF->getFixups().push_back(Fixups[i]);
485f4a2713aSLionel Sambuc   }
486f4a2713aSLionel Sambuc   DF->setHasInstructions(true);
487f4a2713aSLionel Sambuc   DF->getContents().append(Code.begin(), Code.end());
488f4a2713aSLionel Sambuc }
489f4a2713aSLionel Sambuc 
EmitBundleAlignMode(unsigned AlignPow2)490f4a2713aSLionel Sambuc void MCELFStreamer::EmitBundleAlignMode(unsigned AlignPow2) {
491f4a2713aSLionel Sambuc   assert(AlignPow2 <= 30 && "Invalid bundle alignment");
492f4a2713aSLionel Sambuc   MCAssembler &Assembler = getAssembler();
493*0a6a1f1dSLionel Sambuc   if (AlignPow2 > 0 && (Assembler.getBundleAlignSize() == 0 ||
494*0a6a1f1dSLionel Sambuc                         Assembler.getBundleAlignSize() == 1U << AlignPow2))
495*0a6a1f1dSLionel Sambuc     Assembler.setBundleAlignSize(1U << AlignPow2);
496f4a2713aSLionel Sambuc   else
497*0a6a1f1dSLionel Sambuc     report_fatal_error(".bundle_align_mode cannot be changed once set");
498f4a2713aSLionel Sambuc }
499f4a2713aSLionel Sambuc 
EmitBundleLock(bool AlignToEnd)500f4a2713aSLionel Sambuc void MCELFStreamer::EmitBundleLock(bool AlignToEnd) {
501f4a2713aSLionel Sambuc   MCSectionData *SD = getCurrentSectionData();
502f4a2713aSLionel Sambuc 
503f4a2713aSLionel Sambuc   // Sanity checks
504f4a2713aSLionel Sambuc   //
505f4a2713aSLionel Sambuc   if (!getAssembler().isBundlingEnabled())
506f4a2713aSLionel Sambuc     report_fatal_error(".bundle_lock forbidden when bundling is disabled");
507*0a6a1f1dSLionel Sambuc 
508*0a6a1f1dSLionel Sambuc   if (!SD->isBundleLocked())
509*0a6a1f1dSLionel Sambuc     SD->setBundleGroupBeforeFirstInst(true);
510f4a2713aSLionel Sambuc 
511f4a2713aSLionel Sambuc   SD->setBundleLockState(AlignToEnd ? MCSectionData::BundleLockedAlignToEnd :
512f4a2713aSLionel Sambuc                                       MCSectionData::BundleLocked);
513f4a2713aSLionel Sambuc }
514f4a2713aSLionel Sambuc 
EmitBundleUnlock()515f4a2713aSLionel Sambuc void MCELFStreamer::EmitBundleUnlock() {
516f4a2713aSLionel Sambuc   MCSectionData *SD = getCurrentSectionData();
517f4a2713aSLionel Sambuc 
518f4a2713aSLionel Sambuc   // Sanity checks
519f4a2713aSLionel Sambuc   if (!getAssembler().isBundlingEnabled())
520f4a2713aSLionel Sambuc     report_fatal_error(".bundle_unlock forbidden when bundling is disabled");
521f4a2713aSLionel Sambuc   else if (!SD->isBundleLocked())
522f4a2713aSLionel Sambuc     report_fatal_error(".bundle_unlock without matching lock");
523f4a2713aSLionel Sambuc   else if (SD->isBundleGroupBeforeFirstInst())
524f4a2713aSLionel Sambuc     report_fatal_error("Empty bundle-locked group is forbidden");
525f4a2713aSLionel Sambuc 
526f4a2713aSLionel Sambuc   SD->setBundleLockState(MCSectionData::NotBundleLocked);
527f4a2713aSLionel Sambuc }
528f4a2713aSLionel Sambuc 
Flush()529f4a2713aSLionel Sambuc void MCELFStreamer::Flush() {
530f4a2713aSLionel Sambuc   for (std::vector<LocalCommon>::const_iterator i = LocalCommons.begin(),
531f4a2713aSLionel Sambuc                                                 e = LocalCommons.end();
532f4a2713aSLionel Sambuc        i != e; ++i) {
533f4a2713aSLionel Sambuc     MCSymbolData *SD = i->SD;
534f4a2713aSLionel Sambuc     uint64_t Size = i->Size;
535f4a2713aSLionel Sambuc     unsigned ByteAlignment = i->ByteAlignment;
536f4a2713aSLionel Sambuc     const MCSymbol &Symbol = SD->getSymbol();
537f4a2713aSLionel Sambuc     const MCSection &Section = Symbol.getSection();
538f4a2713aSLionel Sambuc 
539f4a2713aSLionel Sambuc     MCSectionData &SectData = getAssembler().getOrCreateSectionData(Section);
540f4a2713aSLionel Sambuc     new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &SectData);
541f4a2713aSLionel Sambuc 
542f4a2713aSLionel Sambuc     MCFragment *F = new MCFillFragment(0, 0, Size, &SectData);
543f4a2713aSLionel Sambuc     SD->setFragment(F);
544f4a2713aSLionel Sambuc 
545f4a2713aSLionel Sambuc     // Update the maximum alignment of the section if necessary.
546f4a2713aSLionel Sambuc     if (ByteAlignment > SectData.getAlignment())
547f4a2713aSLionel Sambuc       SectData.setAlignment(ByteAlignment);
548f4a2713aSLionel Sambuc   }
549f4a2713aSLionel Sambuc 
550f4a2713aSLionel Sambuc   LocalCommons.clear();
551f4a2713aSLionel Sambuc }
552f4a2713aSLionel Sambuc 
FinishImpl()553f4a2713aSLionel Sambuc void MCELFStreamer::FinishImpl() {
554*0a6a1f1dSLionel Sambuc   EmitFrames(nullptr);
555f4a2713aSLionel Sambuc 
556f4a2713aSLionel Sambuc   Flush();
557f4a2713aSLionel Sambuc 
558f4a2713aSLionel Sambuc   this->MCObjectStreamer::FinishImpl();
559f4a2713aSLionel Sambuc }
560f4a2713aSLionel Sambuc 
createELFStreamer(MCContext & Context,MCAsmBackend & MAB,raw_ostream & OS,MCCodeEmitter * CE,bool RelaxAll)561*0a6a1f1dSLionel Sambuc MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB,
562*0a6a1f1dSLionel Sambuc                                     raw_ostream &OS, MCCodeEmitter *CE,
563*0a6a1f1dSLionel Sambuc                                     bool RelaxAll) {
564*0a6a1f1dSLionel Sambuc   MCELFStreamer *S = new MCELFStreamer(Context, MAB, OS, CE);
565f4a2713aSLionel Sambuc   if (RelaxAll)
566f4a2713aSLionel Sambuc     S->getAssembler().setRelaxAll(true);
567f4a2713aSLionel Sambuc   return S;
568f4a2713aSLionel Sambuc }
569f4a2713aSLionel Sambuc 
EmitThumbFunc(MCSymbol * Func)570f4a2713aSLionel Sambuc void MCELFStreamer::EmitThumbFunc(MCSymbol *Func) {
571f4a2713aSLionel Sambuc   llvm_unreachable("Generic ELF doesn't support this directive");
572f4a2713aSLionel Sambuc }
573f4a2713aSLionel Sambuc 
EmitSymbolDesc(MCSymbol * Symbol,unsigned DescValue)574f4a2713aSLionel Sambuc void MCELFStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
575f4a2713aSLionel Sambuc   llvm_unreachable("ELF doesn't support this directive");
576f4a2713aSLionel Sambuc }
577f4a2713aSLionel Sambuc 
BeginCOFFSymbolDef(const MCSymbol * Symbol)578f4a2713aSLionel Sambuc void MCELFStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) {
579f4a2713aSLionel Sambuc   llvm_unreachable("ELF doesn't support this directive");
580f4a2713aSLionel Sambuc }
581f4a2713aSLionel Sambuc 
EmitCOFFSymbolStorageClass(int StorageClass)582f4a2713aSLionel Sambuc void MCELFStreamer::EmitCOFFSymbolStorageClass(int StorageClass) {
583f4a2713aSLionel Sambuc   llvm_unreachable("ELF doesn't support this directive");
584f4a2713aSLionel Sambuc }
585f4a2713aSLionel Sambuc 
EmitCOFFSymbolType(int Type)586f4a2713aSLionel Sambuc void MCELFStreamer::EmitCOFFSymbolType(int Type) {
587f4a2713aSLionel Sambuc   llvm_unreachable("ELF doesn't support this directive");
588f4a2713aSLionel Sambuc }
589f4a2713aSLionel Sambuc 
EndCOFFSymbolDef()590f4a2713aSLionel Sambuc void MCELFStreamer::EndCOFFSymbolDef() {
591f4a2713aSLionel Sambuc   llvm_unreachable("ELF doesn't support this directive");
592f4a2713aSLionel Sambuc }
593f4a2713aSLionel Sambuc 
EmitZerofill(const MCSection * Section,MCSymbol * Symbol,uint64_t Size,unsigned ByteAlignment)594f4a2713aSLionel Sambuc void MCELFStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
595f4a2713aSLionel Sambuc                                  uint64_t Size, unsigned ByteAlignment) {
596f4a2713aSLionel Sambuc   llvm_unreachable("ELF doesn't support this directive");
597f4a2713aSLionel Sambuc }
598f4a2713aSLionel Sambuc 
EmitTBSSSymbol(const MCSection * Section,MCSymbol * Symbol,uint64_t Size,unsigned ByteAlignment)599f4a2713aSLionel Sambuc void MCELFStreamer::EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
600f4a2713aSLionel Sambuc                                    uint64_t Size, unsigned ByteAlignment) {
601f4a2713aSLionel Sambuc   llvm_unreachable("ELF doesn't support this directive");
602f4a2713aSLionel Sambuc }
603