1 //===- lib/MC/MCELFStreamer.cpp - ELF Object Output -----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file assembles .s files and emits ELF .o object files.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/MC/MCELFStreamer.h"
15 #include "llvm/ADT/SmallString.h"
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/BinaryFormat/ELF.h"
18 #include "llvm/MC/MCAsmBackend.h"
19 #include "llvm/MC/MCAsmInfo.h"
20 #include "llvm/MC/MCAssembler.h"
21 #include "llvm/MC/MCCodeEmitter.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"
26 #include "llvm/MC/MCObjectFileInfo.h"
27 #include "llvm/MC/MCObjectWriter.h"
28 #include "llvm/MC/MCSection.h"
29 #include "llvm/MC/MCSectionELF.h"
30 #include "llvm/MC/MCStreamer.h"
31 #include "llvm/MC/MCSymbol.h"
32 #include "llvm/MC/MCSymbolELF.h"
33 #include "llvm/Support/Casting.h"
34 #include "llvm/Support/ErrorHandling.h"
35 #include "llvm/Support/TargetRegistry.h"
36 #include "llvm/Support/raw_ostream.h"
42 bool MCELFStreamer::isBundleLocked() const {
43 return getCurrentSectionOnly()->isBundleLocked();
46 void MCELFStreamer::mergeFragment(MCDataFragment *DF,
48 MCAssembler &Assembler = getAssembler();
50 if (Assembler.isBundlingEnabled() && Assembler.getRelaxAll()) {
51 uint64_t FSize = EF->getContents().size();
53 if (FSize > Assembler.getBundleAlignSize())
54 report_fatal_error("Fragment can't be larger than a bundle size");
56 uint64_t RequiredBundlePadding = computeBundlePadding(
57 Assembler, EF, DF->getContents().size(), FSize);
59 if (RequiredBundlePadding > UINT8_MAX)
60 report_fatal_error("Padding cannot exceed 255 bytes");
62 if (RequiredBundlePadding > 0) {
63 SmallString<256> Code;
64 raw_svector_ostream VecOS(Code);
65 MCObjectWriter *OW = Assembler.getBackend().createObjectWriter(VecOS);
67 EF->setBundlePadding(static_cast<uint8_t>(RequiredBundlePadding));
69 Assembler.writeFragmentPadding(*EF, FSize, OW);
72 DF->getContents().append(Code.begin(), Code.end());
76 flushPendingLabels(DF, DF->getContents().size());
78 for (unsigned i = 0, e = EF->getFixups().size(); i != e; ++i) {
79 EF->getFixups()[i].setOffset(EF->getFixups()[i].getOffset() +
80 DF->getContents().size());
81 DF->getFixups().push_back(EF->getFixups()[i]);
83 DF->setHasInstructions(true);
84 DF->getContents().append(EF->getContents().begin(), EF->getContents().end());
87 void MCELFStreamer::InitSections(bool NoExecStack) {
88 MCContext &Ctx = getContext();
89 SwitchSection(Ctx.getObjectFileInfo()->getTextSection());
93 SwitchSection(Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx));
96 void MCELFStreamer::EmitLabel(MCSymbol *S, SMLoc Loc) {
97 auto *Symbol = cast<MCSymbolELF>(S);
98 MCObjectStreamer::EmitLabel(Symbol, Loc);
100 const MCSectionELF &Section =
101 static_cast<const MCSectionELF &>(*getCurrentSectionOnly());
102 if (Section.getFlags() & ELF::SHF_TLS)
103 Symbol->setType(ELF::STT_TLS);
106 void MCELFStreamer::EmitLabel(MCSymbol *S, SMLoc Loc, MCFragment *F) {
107 auto *Symbol = cast<MCSymbolELF>(S);
108 MCObjectStreamer::EmitLabel(Symbol, Loc, F);
110 const MCSectionELF &Section =
111 static_cast<const MCSectionELF &>(*getCurrentSectionOnly());
112 if (Section.getFlags() & ELF::SHF_TLS)
113 Symbol->setType(ELF::STT_TLS);
116 void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
117 // Let the target do whatever target specific stuff it needs to do.
118 getAssembler().getBackend().handleAssemblerFlag(Flag);
119 // Do any generic stuff we need to do.
121 case MCAF_SyntaxUnified: return; // no-op here.
122 case MCAF_Code16: return; // Change parsing mode; no-op here.
123 case MCAF_Code32: return; // Change parsing mode; no-op here.
124 case MCAF_Code64: return; // Change parsing mode; no-op here.
125 case MCAF_SubsectionsViaSymbols:
126 getAssembler().setSubsectionsViaSymbols(true);
130 llvm_unreachable("invalid assembler flag!");
133 // If bundle alignment is used and there are any instructions in the section, it
134 // needs to be aligned to at least the bundle size.
135 static void setSectionAlignmentForBundling(const MCAssembler &Assembler,
136 MCSection *Section) {
137 if (Section && Assembler.isBundlingEnabled() && Section->hasInstructions() &&
138 Section->getAlignment() < Assembler.getBundleAlignSize())
139 Section->setAlignment(Assembler.getBundleAlignSize());
142 void MCELFStreamer::ChangeSection(MCSection *Section,
143 const MCExpr *Subsection) {
144 MCSection *CurSection = getCurrentSectionOnly();
145 if (CurSection && isBundleLocked())
146 report_fatal_error("Unterminated .bundle_lock when changing a section");
148 MCAssembler &Asm = getAssembler();
149 // Ensure the previous section gets aligned if necessary.
150 setSectionAlignmentForBundling(Asm, CurSection);
151 auto *SectionELF = static_cast<const MCSectionELF *>(Section);
152 const MCSymbol *Grp = SectionELF->getGroup();
154 Asm.registerSymbol(*Grp);
156 changeSectionImpl(Section, Subsection);
157 Asm.registerSymbol(*Section->getBeginSymbol());
160 void MCELFStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {
161 getAssembler().registerSymbol(*Symbol);
162 const MCExpr *Value = MCSymbolRefExpr::create(
163 Symbol, MCSymbolRefExpr::VK_WEAKREF, getContext());
164 Alias->setVariableValue(Value);
167 // When GNU as encounters more than one .type declaration for an object it seems
168 // to use a mechanism similar to the one below to decide which type is actually
169 // used in the object file. The greater of T1 and T2 is selected based on the
170 // following ordering:
171 // STT_NOTYPE < STT_OBJECT < STT_FUNC < STT_GNU_IFUNC < STT_TLS < anything else
172 // If neither T1 < T2 nor T2 < T1 according to this ordering, use T2 (the user
174 static unsigned CombineSymbolTypes(unsigned T1, unsigned T2) {
175 for (unsigned Type : {ELF::STT_NOTYPE, ELF::STT_OBJECT, ELF::STT_FUNC,
176 ELF::STT_GNU_IFUNC, ELF::STT_TLS}) {
186 bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) {
187 auto *Symbol = cast<MCSymbolELF>(S);
188 // Indirect symbols are handled differently, to match how 'as' handles
189 // them. This makes writing matching .o files easier.
190 if (Attribute == MCSA_IndirectSymbol) {
191 // Note that we intentionally cannot use the symbol data here; this is
192 // important for matching the string table that 'as' generates.
193 IndirectSymbolData ISD;
195 ISD.Section = getCurrentSectionOnly();
196 getAssembler().getIndirectSymbols().push_back(ISD);
200 // Adding a symbol attribute always introduces the symbol, note that an
201 // important side effect of calling registerSymbol here is to register
202 // the symbol with the assembler.
203 getAssembler().registerSymbol(*Symbol);
205 // The implementation of symbol attributes is designed to match 'as', but it
206 // leaves much to desired. It doesn't really make sense to arbitrarily add and
207 // remove flags, but 'as' allows this (in particular, see .desc).
209 // In the future it might be worth trying to make these operations more well
212 case MCSA_LazyReference:
214 case MCSA_SymbolResolver:
215 case MCSA_PrivateExtern:
216 case MCSA_WeakDefinition:
217 case MCSA_WeakDefAutoPrivate:
219 case MCSA_IndirectSymbol:
222 case MCSA_NoDeadStrip:
226 case MCSA_ELF_TypeGnuUniqueObject:
227 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT));
228 Symbol->setBinding(ELF::STB_GNU_UNIQUE);
229 Symbol->setExternal(true);
233 Symbol->setBinding(ELF::STB_GLOBAL);
234 Symbol->setExternal(true);
237 case MCSA_WeakReference:
239 Symbol->setBinding(ELF::STB_WEAK);
240 Symbol->setExternal(true);
244 Symbol->setBinding(ELF::STB_LOCAL);
245 Symbol->setExternal(false);
248 case MCSA_ELF_TypeFunction:
249 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_FUNC));
252 case MCSA_ELF_TypeIndFunction:
253 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_GNU_IFUNC));
256 case MCSA_ELF_TypeObject:
257 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT));
260 case MCSA_ELF_TypeTLS:
261 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_TLS));
264 case MCSA_ELF_TypeCommon:
265 // TODO: Emit these as a common symbol.
266 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT));
269 case MCSA_ELF_TypeNoType:
270 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_NOTYPE));
274 Symbol->setVisibility(ELF::STV_PROTECTED);
278 Symbol->setVisibility(ELF::STV_HIDDEN);
282 Symbol->setVisibility(ELF::STV_INTERNAL);
286 llvm_unreachable("ELF doesn't support the .alt_entry attribute");
292 void MCELFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size,
293 unsigned ByteAlignment) {
294 auto *Symbol = cast<MCSymbolELF>(S);
295 getAssembler().registerSymbol(*Symbol);
297 if (!Symbol->isBindingSet()) {
298 Symbol->setBinding(ELF::STB_GLOBAL);
299 Symbol->setExternal(true);
302 Symbol->setType(ELF::STT_OBJECT);
304 if (Symbol->getBinding() == ELF::STB_LOCAL) {
305 MCSection &Section = *getAssembler().getContext().getELFSection(
306 ".bss", ELF::SHT_NOBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
307 MCSectionSubPair P = getCurrentSection();
308 SwitchSection(&Section);
310 EmitValueToAlignment(ByteAlignment, 0, 1, 0);
314 // Update the maximum alignment of the section if necessary.
315 if (ByteAlignment > Section.getAlignment())
316 Section.setAlignment(ByteAlignment);
318 SwitchSection(P.first, P.second);
320 if(Symbol->declareCommon(Size, ByteAlignment))
321 report_fatal_error("Symbol: " + Symbol->getName() +
322 " redeclared as different type");
325 cast<MCSymbolELF>(Symbol)
326 ->setSize(MCConstantExpr::create(Size, getContext()));
329 void MCELFStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
330 cast<MCSymbolELF>(Symbol)->setSize(Value);
333 void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *S, uint64_t Size,
334 unsigned ByteAlignment) {
335 auto *Symbol = cast<MCSymbolELF>(S);
336 // FIXME: Should this be caught and done earlier?
337 getAssembler().registerSymbol(*Symbol);
338 Symbol->setBinding(ELF::STB_LOCAL);
339 Symbol->setExternal(false);
340 EmitCommonSymbol(Symbol, Size, ByteAlignment);
343 void MCELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
345 if (isBundleLocked())
346 report_fatal_error("Emitting values inside a locked bundle is forbidden");
347 fixSymbolsInTLSFixups(Value);
348 MCObjectStreamer::EmitValueImpl(Value, Size, Loc);
351 void MCELFStreamer::EmitValueToAlignment(unsigned ByteAlignment,
354 unsigned MaxBytesToEmit) {
355 if (isBundleLocked())
356 report_fatal_error("Emitting values inside a locked bundle is forbidden");
357 MCObjectStreamer::EmitValueToAlignment(ByteAlignment, Value,
358 ValueSize, MaxBytesToEmit);
361 void MCELFStreamer::EmitIdent(StringRef IdentString) {
362 MCSection *Comment = getAssembler().getContext().getELFSection(
363 ".comment", ELF::SHT_PROGBITS, ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
365 SwitchSection(Comment);
370 EmitBytes(IdentString);
375 void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
376 switch (expr->getKind()) {
378 cast<MCTargetExpr>(expr)->fixELFSymbolsInTLSFixups(getAssembler());
380 case MCExpr::Constant:
383 case MCExpr::Binary: {
384 const MCBinaryExpr *be = cast<MCBinaryExpr>(expr);
385 fixSymbolsInTLSFixups(be->getLHS());
386 fixSymbolsInTLSFixups(be->getRHS());
390 case MCExpr::SymbolRef: {
391 const MCSymbolRefExpr &symRef = *cast<MCSymbolRefExpr>(expr);
392 switch (symRef.getKind()) {
395 case MCSymbolRefExpr::VK_GOTTPOFF:
396 case MCSymbolRefExpr::VK_INDNTPOFF:
397 case MCSymbolRefExpr::VK_NTPOFF:
398 case MCSymbolRefExpr::VK_GOTNTPOFF:
399 case MCSymbolRefExpr::VK_TLSGD:
400 case MCSymbolRefExpr::VK_TLSLD:
401 case MCSymbolRefExpr::VK_TLSLDM:
402 case MCSymbolRefExpr::VK_TPOFF:
403 case MCSymbolRefExpr::VK_TPREL:
404 case MCSymbolRefExpr::VK_DTPOFF:
405 case MCSymbolRefExpr::VK_DTPREL:
406 case MCSymbolRefExpr::VK_PPC_DTPMOD:
407 case MCSymbolRefExpr::VK_PPC_TPREL_LO:
408 case MCSymbolRefExpr::VK_PPC_TPREL_HI:
409 case MCSymbolRefExpr::VK_PPC_TPREL_HA:
410 case MCSymbolRefExpr::VK_PPC_TPREL_HIGHER:
411 case MCSymbolRefExpr::VK_PPC_TPREL_HIGHERA:
412 case MCSymbolRefExpr::VK_PPC_TPREL_HIGHEST:
413 case MCSymbolRefExpr::VK_PPC_TPREL_HIGHESTA:
414 case MCSymbolRefExpr::VK_PPC_DTPREL_LO:
415 case MCSymbolRefExpr::VK_PPC_DTPREL_HI:
416 case MCSymbolRefExpr::VK_PPC_DTPREL_HA:
417 case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHER:
418 case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHERA:
419 case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHEST:
420 case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHESTA:
421 case MCSymbolRefExpr::VK_PPC_GOT_TPREL:
422 case MCSymbolRefExpr::VK_PPC_GOT_TPREL_LO:
423 case MCSymbolRefExpr::VK_PPC_GOT_TPREL_HI:
424 case MCSymbolRefExpr::VK_PPC_GOT_TPREL_HA:
425 case MCSymbolRefExpr::VK_PPC_GOT_DTPREL:
426 case MCSymbolRefExpr::VK_PPC_GOT_DTPREL_LO:
427 case MCSymbolRefExpr::VK_PPC_GOT_DTPREL_HI:
428 case MCSymbolRefExpr::VK_PPC_GOT_DTPREL_HA:
429 case MCSymbolRefExpr::VK_PPC_TLS:
430 case MCSymbolRefExpr::VK_PPC_GOT_TLSGD:
431 case MCSymbolRefExpr::VK_PPC_GOT_TLSGD_LO:
432 case MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HI:
433 case MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HA:
434 case MCSymbolRefExpr::VK_PPC_TLSGD:
435 case MCSymbolRefExpr::VK_PPC_GOT_TLSLD:
436 case MCSymbolRefExpr::VK_PPC_GOT_TLSLD_LO:
437 case MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HI:
438 case MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HA:
439 case MCSymbolRefExpr::VK_PPC_TLSLD:
442 getAssembler().registerSymbol(symRef.getSymbol());
443 cast<MCSymbolELF>(symRef.getSymbol()).setType(ELF::STT_TLS);
448 fixSymbolsInTLSFixups(cast<MCUnaryExpr>(expr)->getSubExpr());
453 void MCELFStreamer::EmitInstToFragment(const MCInst &Inst,
454 const MCSubtargetInfo &STI) {
455 this->MCObjectStreamer::EmitInstToFragment(Inst, STI);
456 MCRelaxableFragment &F = *cast<MCRelaxableFragment>(getCurrentFragment());
458 for (unsigned i = 0, e = F.getFixups().size(); i != e; ++i)
459 fixSymbolsInTLSFixups(F.getFixups()[i].getValue());
462 void MCELFStreamer::EmitInstToData(const MCInst &Inst,
463 const MCSubtargetInfo &STI) {
464 MCAssembler &Assembler = getAssembler();
465 SmallVector<MCFixup, 4> Fixups;
466 SmallString<256> Code;
467 raw_svector_ostream VecOS(Code);
468 Assembler.getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
470 for (unsigned i = 0, e = Fixups.size(); i != e; ++i)
471 fixSymbolsInTLSFixups(Fixups[i].getValue());
473 // There are several possibilities here:
475 // If bundling is disabled, append the encoded instruction to the current data
476 // fragment (or create a new such fragment if the current fragment is not a
479 // If bundling is enabled:
480 // - If we're not in a bundle-locked group, emit the instruction into a
481 // fragment of its own. If there are no fixups registered for the
482 // instruction, emit a MCCompactEncodedInstFragment. Otherwise, emit a
484 // - If we're in a bundle-locked group, append the instruction to the current
485 // data fragment because we want all the instructions in a group to get into
486 // the same fragment. Be careful not to do that for the first instruction in
487 // the group, though.
490 if (Assembler.isBundlingEnabled()) {
491 MCSection &Sec = *getCurrentSectionOnly();
492 if (Assembler.getRelaxAll() && isBundleLocked())
493 // If the -mc-relax-all flag is used and we are bundle-locked, we re-use
494 // the current bundle group.
495 DF = BundleGroups.back();
496 else if (Assembler.getRelaxAll() && !isBundleLocked())
497 // When not in a bundle-locked group and the -mc-relax-all flag is used,
498 // we create a new temporary fragment which will be later merged into
499 // the current fragment.
500 DF = new MCDataFragment();
501 else if (isBundleLocked() && !Sec.isBundleGroupBeforeFirstInst())
502 // If we are bundle-locked, we re-use the current fragment.
503 // The bundle-locking directive ensures this is a new data fragment.
504 DF = cast<MCDataFragment>(getCurrentFragment());
505 else if (!isBundleLocked() && Fixups.size() == 0) {
506 // Optimize memory usage by emitting the instruction to a
507 // MCCompactEncodedInstFragment when not in a bundle-locked group and
508 // there are no fixups registered.
509 MCCompactEncodedInstFragment *CEIF = new MCCompactEncodedInstFragment();
511 CEIF->getContents().append(Code.begin(), Code.end());
514 DF = new MCDataFragment();
517 if (Sec.getBundleLockState() == MCSection::BundleLockedAlignToEnd) {
518 // If this fragment is for a group marked "align_to_end", set a flag
519 // in the fragment. This can happen after the fragment has already been
520 // created if there are nested bundle_align groups and an inner one
521 // is the one marked align_to_end.
522 DF->setAlignToBundleEnd(true);
525 // We're now emitting an instruction in a bundle group, so this flag has
527 Sec.setBundleGroupBeforeFirstInst(false);
529 DF = getOrCreateDataFragment();
532 // Add the fixups and data.
533 for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
534 Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size());
535 DF->getFixups().push_back(Fixups[i]);
537 DF->setHasInstructions(true);
538 DF->getContents().append(Code.begin(), Code.end());
540 if (Assembler.isBundlingEnabled() && Assembler.getRelaxAll()) {
541 if (!isBundleLocked()) {
542 mergeFragment(getOrCreateDataFragment(), DF);
548 void MCELFStreamer::EmitBundleAlignMode(unsigned AlignPow2) {
549 assert(AlignPow2 <= 30 && "Invalid bundle alignment");
550 MCAssembler &Assembler = getAssembler();
551 if (AlignPow2 > 0 && (Assembler.getBundleAlignSize() == 0 ||
552 Assembler.getBundleAlignSize() == 1U << AlignPow2))
553 Assembler.setBundleAlignSize(1U << AlignPow2);
555 report_fatal_error(".bundle_align_mode cannot be changed once set");
558 void MCELFStreamer::EmitBundleLock(bool AlignToEnd) {
559 MCSection &Sec = *getCurrentSectionOnly();
563 if (!getAssembler().isBundlingEnabled())
564 report_fatal_error(".bundle_lock forbidden when bundling is disabled");
566 if (!isBundleLocked())
567 Sec.setBundleGroupBeforeFirstInst(true);
569 if (getAssembler().getRelaxAll() && !isBundleLocked()) {
570 // TODO: drop the lock state and set directly in the fragment
571 MCDataFragment *DF = new MCDataFragment();
572 BundleGroups.push_back(DF);
575 Sec.setBundleLockState(AlignToEnd ? MCSection::BundleLockedAlignToEnd
576 : MCSection::BundleLocked);
579 void MCELFStreamer::EmitBundleUnlock() {
580 MCSection &Sec = *getCurrentSectionOnly();
583 if (!getAssembler().isBundlingEnabled())
584 report_fatal_error(".bundle_unlock forbidden when bundling is disabled");
585 else if (!isBundleLocked())
586 report_fatal_error(".bundle_unlock without matching lock");
587 else if (Sec.isBundleGroupBeforeFirstInst())
588 report_fatal_error("Empty bundle-locked group is forbidden");
590 // When the -mc-relax-all flag is used, we emit instructions to fragments
591 // stored on a stack. When the bundle unlock is emitted, we pop a fragment
592 // from the stack a merge it to the one below.
593 if (getAssembler().getRelaxAll()) {
594 assert(!BundleGroups.empty() && "There are no bundle groups");
595 MCDataFragment *DF = BundleGroups.back();
597 // FIXME: Use BundleGroups to track the lock state instead.
598 Sec.setBundleLockState(MCSection::NotBundleLocked);
600 // FIXME: Use more separate fragments for nested groups.
601 if (!isBundleLocked()) {
602 mergeFragment(getOrCreateDataFragment(), DF);
603 BundleGroups.pop_back();
607 if (Sec.getBundleLockState() != MCSection::BundleLockedAlignToEnd)
608 getOrCreateDataFragment()->setAlignToBundleEnd(false);
610 Sec.setBundleLockState(MCSection::NotBundleLocked);
613 void MCELFStreamer::FinishImpl() {
614 // Ensure the last section gets aligned if necessary.
615 MCSection *CurSection = getCurrentSectionOnly();
616 setSectionAlignmentForBundling(getAssembler(), CurSection);
620 this->MCObjectStreamer::FinishImpl();
623 void MCELFStreamer::EmitThumbFunc(MCSymbol *Func) {
624 llvm_unreachable("Generic ELF doesn't support this directive");
627 void MCELFStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
628 llvm_unreachable("ELF doesn't support this directive");
631 void MCELFStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
632 uint64_t Size, unsigned ByteAlignment) {
633 llvm_unreachable("ELF doesn't support this directive");
636 void MCELFStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
637 uint64_t Size, unsigned ByteAlignment) {
638 llvm_unreachable("ELF doesn't support this directive");
641 MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB,
642 raw_pwrite_stream &OS, MCCodeEmitter *CE,
644 MCELFStreamer *S = new MCELFStreamer(Context, MAB, OS, CE);
646 S->getAssembler().setRelaxAll(true);