blob: de0791281d29ec7954020012d566774a50111594 [file] [log] [blame]
Nick Lewyckyc1f96942013-03-09 09:31:44 +00001//===- lib/MC/MCELFStreamer.cpp - ELF Object Output -----------------------===//
Matt Fleming6c1ad482010-08-16 18:57:57 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file assembles .s files and emits ELF .o object files.
11//
12//===----------------------------------------------------------------------===//
13
Eugene Zelenko1d435522017-02-07 23:02:00 +000014#include "llvm/ADT/SmallString.h"
15#include "llvm/ADT/SmallVector.h"
David Peixotto72667312013-11-25 19:11:13 +000016#include "llvm/MC/MCAsmBackend.h"
Rafael Espindola7b61ddf2014-10-15 16:12:52 +000017#include "llvm/MC/MCAsmInfo.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000018#include "llvm/MC/MCAssembler.h"
Matt Fleming6c1ad482010-08-16 18:57:57 +000019#include "llvm/MC/MCCodeEmitter.h"
Rafael Espindola81a62742012-01-07 23:18:39 +000020#include "llvm/MC/MCContext.h"
Eugene Zelenko1d435522017-02-07 23:02:00 +000021#include "llvm/MC/MCELFStreamer.h"
Matt Fleming6c1ad482010-08-16 18:57:57 +000022#include "llvm/MC/MCExpr.h"
Eugene Zelenko1d435522017-02-07 23:02:00 +000023#include "llvm/MC/MCFixup.h"
24#include "llvm/MC/MCFragment.h"
Rafael Espindolae308c0c2014-01-23 22:49:25 +000025#include "llvm/MC/MCObjectFileInfo.h"
Reid Kleckner0801d122016-06-22 23:25:26 +000026#include "llvm/MC/MCObjectWriter.h"
Matt Fleming6c1ad482010-08-16 18:57:57 +000027#include "llvm/MC/MCSection.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000028#include "llvm/MC/MCSectionELF.h"
Eugene Zelenko1d435522017-02-07 23:02:00 +000029#include "llvm/MC/MCStreamer.h"
Rafael Espindolaa8695762015-06-02 00:25:12 +000030#include "llvm/MC/MCSymbolELF.h"
Matt Fleming6c1ad482010-08-16 18:57:57 +000031#include "llvm/MC/MCSymbol.h"
Eugene Zelenko1d435522017-02-07 23:02:00 +000032#include "llvm/Support/Casting.h"
Matt Fleming6c1ad482010-08-16 18:57:57 +000033#include "llvm/Support/ELF.h"
34#include "llvm/Support/ErrorHandling.h"
Rafael Espindolacd584a82015-03-19 01:50:16 +000035#include "llvm/Support/TargetRegistry.h"
Matt Fleming6c1ad482010-08-16 18:57:57 +000036#include "llvm/Support/raw_ostream.h"
Eugene Zelenko1d435522017-02-07 23:02:00 +000037#include <cassert>
38#include <cstdint>
Matt Fleming6c1ad482010-08-16 18:57:57 +000039
40using namespace llvm;
41
Rafael Espindolac1cd9442015-05-25 14:57:35 +000042bool MCELFStreamer::isBundleLocked() const {
Rafael Espindola983bec62015-05-27 21:04:14 +000043 return getCurrentSectionOnly()->isBundleLocked();
Rafael Espindolac1cd9442015-05-25 14:57:35 +000044}
45
Petr Hosek9e0c8902015-04-12 23:42:25 +000046void MCELFStreamer::mergeFragment(MCDataFragment *DF,
Pete Coopere0d40372015-06-17 22:01:28 +000047 MCDataFragment *EF) {
Petr Hosek9e0c8902015-04-12 23:42:25 +000048 MCAssembler &Assembler = getAssembler();
49
50 if (Assembler.isBundlingEnabled() && Assembler.getRelaxAll()) {
51 uint64_t FSize = EF->getContents().size();
52
53 if (FSize > Assembler.getBundleAlignSize())
54 report_fatal_error("Fragment can't be larger than a bundle size");
55
56 uint64_t RequiredBundlePadding = computeBundlePadding(
57 Assembler, EF, DF->getContents().size(), FSize);
58
59 if (RequiredBundlePadding > UINT8_MAX)
60 report_fatal_error("Padding cannot exceed 255 bytes");
61
62 if (RequiredBundlePadding > 0) {
63 SmallString<256> Code;
64 raw_svector_ostream VecOS(Code);
65 MCObjectWriter *OW = Assembler.getBackend().createObjectWriter(VecOS);
66
67 EF->setBundlePadding(static_cast<uint8_t>(RequiredBundlePadding));
68
69 Assembler.writeFragmentPadding(*EF, FSize, OW);
Petr Hosek9e0c8902015-04-12 23:42:25 +000070 delete OW;
71
72 DF->getContents().append(Code.begin(), Code.end());
73 }
74 }
75
76 flushPendingLabels(DF, DF->getContents().size());
77
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]);
82 }
83 DF->setHasInstructions(true);
84 DF->getContents().append(EF->getContents().begin(), EF->getContents().end());
85}
86
Rafael Espindola7b61ddf2014-10-15 16:12:52 +000087void MCELFStreamer::InitSections(bool NoExecStack) {
Rafael Espindola7b61ddf2014-10-15 16:12:52 +000088 MCContext &Ctx = getContext();
89 SwitchSection(Ctx.getObjectFileInfo()->getTextSection());
Rafael Espindola7b514962014-02-04 18:34:04 +000090 EmitCodeAlignment(4);
Rafael Espindola247f9512014-01-24 02:18:40 +000091
Rafael Espindola7b61ddf2014-10-15 16:12:52 +000092 if (NoExecStack)
93 SwitchSection(Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx));
Rafael Espindolaf667d922010-09-15 21:48:40 +000094}
95
Rafael Espindolabe991572017-02-10 15:13:12 +000096void MCELFStreamer::EmitLabel(MCSymbol *S, SMLoc Loc) {
Rafael Espindola95fb9b92015-06-02 20:38:46 +000097 auto *Symbol = cast<MCSymbolELF>(S);
Rafael Espindolabe991572017-02-10 15:13:12 +000098 MCObjectStreamer::EmitLabel(Symbol, Loc);
Rafael Espindola75d65b92010-09-25 05:42:19 +000099
Rafael Espindola84d03182010-11-11 19:04:55 +0000100 const MCSectionELF &Section =
Rafael Espindolae3a20f52015-10-05 12:07:05 +0000101 static_cast<const MCSectionELF &>(*getCurrentSectionOnly());
Rafael Espindola0e7e34e2011-01-23 04:43:11 +0000102 if (Section.getFlags() & ELF::SHF_TLS)
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000103 Symbol->setType(ELF::STT_TLS);
Matt Fleming6c1ad482010-08-16 18:57:57 +0000104}
105
106void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
David Peixotto72667312013-11-25 19:11:13 +0000107 // Let the target do whatever target specific stuff it needs to do.
108 getAssembler().getBackend().handleAssemblerFlag(Flag);
109 // Do any generic stuff we need to do.
Matt Fleming6c1ad482010-08-16 18:57:57 +0000110 switch (Flag) {
Jim Grosbach5a2c68d2010-11-05 22:08:08 +0000111 case MCAF_SyntaxUnified: return; // no-op here.
Evan Cheng481ebb02011-07-27 00:38:12 +0000112 case MCAF_Code16: return; // Change parsing mode; no-op here.
113 case MCAF_Code32: return; // Change parsing mode; no-op here.
114 case MCAF_Code64: return; // Change parsing mode; no-op here.
Matt Fleming6c1ad482010-08-16 18:57:57 +0000115 case MCAF_SubsectionsViaSymbols:
116 getAssembler().setSubsectionsViaSymbols(true);
117 return;
118 }
119
Craig Toppera2886c22012-02-07 05:05:23 +0000120 llvm_unreachable("invalid assembler flag!");
Matt Fleming6c1ad482010-08-16 18:57:57 +0000121}
122
Benjamin Kramerdf005cb2015-08-08 18:27:36 +0000123// If bundle alignment is used and there are any instructions in the section, it
Derek Schuff2a1678a2015-04-21 00:14:25 +0000124// needs to be aligned to at least the bundle size.
Rafael Espindolacd625182015-05-25 18:34:26 +0000125static void setSectionAlignmentForBundling(const MCAssembler &Assembler,
Rafael Espindolae6e287d2015-05-26 14:42:52 +0000126 MCSection *Section) {
127 if (Section && Assembler.isBundlingEnabled() && Section->hasInstructions() &&
128 Section->getAlignment() < Assembler.getBundleAlignSize())
129 Section->setAlignment(Assembler.getBundleAlignSize());
Derek Schuff2a1678a2015-04-21 00:14:25 +0000130}
131
Rafael Espindola0709a7b2015-05-21 19:20:38 +0000132void MCELFStreamer::ChangeSection(MCSection *Section,
Peter Collingbourne2f495b92013-04-17 21:18:16 +0000133 const MCExpr *Subsection) {
Rafael Espindola983bec62015-05-27 21:04:14 +0000134 MCSection *CurSection = getCurrentSectionOnly();
Rafael Espindolac1cd9442015-05-25 14:57:35 +0000135 if (CurSection && isBundleLocked())
Eli Benderskyf483ff92012-12-20 19:05:53 +0000136 report_fatal_error("Unterminated .bundle_lock when changing a section");
Rafael Espindolab6613022014-10-17 01:48:58 +0000137
138 MCAssembler &Asm = getAssembler();
Derek Schuff2a1678a2015-04-21 00:14:25 +0000139 // Ensure the previous section gets aligned if necessary.
140 setSectionAlignmentForBundling(Asm, CurSection);
Rafael Espindolab6613022014-10-17 01:48:58 +0000141 auto *SectionELF = static_cast<const MCSectionELF *>(Section);
142 const MCSymbol *Grp = SectionELF->getGroup();
Rafael Espindola7d0ba342010-11-14 04:17:37 +0000143 if (Grp)
Rafael Espindolab5d316b2015-05-29 20:21:02 +0000144 Asm.registerSymbol(*Grp);
Rafael Espindolab6613022014-10-17 01:48:58 +0000145
David Blaikie618d3422017-03-16 00:43:19 +0000146 changeSectionImpl(Section, Subsection);
Rafael Espindola13a79bb2017-02-02 21:26:06 +0000147 Asm.registerSymbol(*Section->getBeginSymbol());
Rafael Espindola7d0ba342010-11-14 04:17:37 +0000148}
149
Rafael Espindola16145972010-11-01 14:28:48 +0000150void MCELFStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {
Rafael Espindolab5d316b2015-05-29 20:21:02 +0000151 getAssembler().registerSymbol(*Symbol);
Jim Grosbach13760bd2015-05-30 01:25:56 +0000152 const MCExpr *Value = MCSymbolRefExpr::create(
Rafael Espindola7fadc0e2014-03-20 02:12:01 +0000153 Symbol, MCSymbolRefExpr::VK_WEAKREF, getContext());
Rafael Espindola16145972010-11-01 14:28:48 +0000154 Alias->setVariableValue(Value);
155}
156
Peter Collingbourneadac4072013-04-10 16:52:15 +0000157// When GNU as encounters more than one .type declaration for an object it seems
158// to use a mechanism similar to the one below to decide which type is actually
159// used in the object file. The greater of T1 and T2 is selected based on the
160// following ordering:
161// STT_NOTYPE < STT_OBJECT < STT_FUNC < STT_GNU_IFUNC < STT_TLS < anything else
162// If neither T1 < T2 nor T2 < T1 according to this ordering, use T2 (the user
163// provided type).
164static unsigned CombineSymbolTypes(unsigned T1, unsigned T2) {
Benjamin Kramer867bfc52015-03-07 17:41:00 +0000165 for (unsigned Type : {ELF::STT_NOTYPE, ELF::STT_OBJECT, ELF::STT_FUNC,
166 ELF::STT_GNU_IFUNC, ELF::STT_TLS}) {
167 if (T1 == Type)
Peter Collingbourneadac4072013-04-10 16:52:15 +0000168 return T2;
Benjamin Kramer867bfc52015-03-07 17:41:00 +0000169 if (T2 == Type)
Peter Collingbourneadac4072013-04-10 16:52:15 +0000170 return T1;
171 }
172
173 return T2;
174}
175
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000176bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) {
177 auto *Symbol = cast<MCSymbolELF>(S);
Matt Fleming6c1ad482010-08-16 18:57:57 +0000178 // Indirect symbols are handled differently, to match how 'as' handles
179 // them. This makes writing matching .o files easier.
180 if (Attribute == MCSA_IndirectSymbol) {
181 // Note that we intentionally cannot use the symbol data here; this is
182 // important for matching the string table that 'as' generates.
183 IndirectSymbolData ISD;
184 ISD.Symbol = Symbol;
Rafael Espindola983bec62015-05-27 21:04:14 +0000185 ISD.Section = getCurrentSectionOnly();
Matt Fleming6c1ad482010-08-16 18:57:57 +0000186 getAssembler().getIndirectSymbols().push_back(ISD);
Saleem Abdulrasool4208b612013-08-09 01:52:03 +0000187 return true;
Matt Fleming6c1ad482010-08-16 18:57:57 +0000188 }
189
190 // Adding a symbol attribute always introduces the symbol, note that an
Rafael Espindolab5d316b2015-05-29 20:21:02 +0000191 // important side effect of calling registerSymbol here is to register
Matt Fleming6c1ad482010-08-16 18:57:57 +0000192 // the symbol with the assembler.
Rafael Espindolab5d316b2015-05-29 20:21:02 +0000193 getAssembler().registerSymbol(*Symbol);
Matt Fleming6c1ad482010-08-16 18:57:57 +0000194
195 // The implementation of symbol attributes is designed to match 'as', but it
196 // leaves much to desired. It doesn't really make sense to arbitrarily add and
197 // remove flags, but 'as' allows this (in particular, see .desc).
198 //
199 // In the future it might be worth trying to make these operations more well
200 // defined.
201 switch (Attribute) {
202 case MCSA_LazyReference:
203 case MCSA_Reference:
Kevin Enderby8be14412010-11-19 18:39:33 +0000204 case MCSA_SymbolResolver:
Matt Fleming6c1ad482010-08-16 18:57:57 +0000205 case MCSA_PrivateExtern:
Matt Fleming6c1ad482010-08-16 18:57:57 +0000206 case MCSA_WeakDefinition:
Eli Friedmanb20b5242010-08-16 19:15:06 +0000207 case MCSA_WeakDefAutoPrivate:
Matt Fleming6c1ad482010-08-16 18:57:57 +0000208 case MCSA_Invalid:
Matt Fleming6c1ad482010-08-16 18:57:57 +0000209 case MCSA_IndirectSymbol:
Saleem Abdulrasool4208b612013-08-09 01:52:03 +0000210 return false;
Matt Fleming6c1ad482010-08-16 18:57:57 +0000211
Jim Grosbachb7b750d2012-09-13 23:11:31 +0000212 case MCSA_NoDeadStrip:
Rafael Espindolaeba90222010-11-14 01:34:31 +0000213 // Ignore for now.
214 break;
215
Rafael Espindola5fa925e2015-01-23 04:44:35 +0000216 case MCSA_ELF_TypeGnuUniqueObject:
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000217 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT));
218 Symbol->setBinding(ELF::STB_GNU_UNIQUE);
Rafael Espindola4d37b2a2015-05-29 21:45:01 +0000219 Symbol->setExternal(true);
Rafael Espindola5fa925e2015-01-23 04:44:35 +0000220 break;
221
Matt Fleming6c1ad482010-08-16 18:57:57 +0000222 case MCSA_Global:
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000223 Symbol->setBinding(ELF::STB_GLOBAL);
Rafael Espindola4d37b2a2015-05-29 21:45:01 +0000224 Symbol->setExternal(true);
Matt Fleming6c1ad482010-08-16 18:57:57 +0000225 break;
226
Benjamin Kramer5af02b02010-09-02 17:18:32 +0000227 case MCSA_WeakReference:
Matt Fleming6c1ad482010-08-16 18:57:57 +0000228 case MCSA_Weak:
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000229 Symbol->setBinding(ELF::STB_WEAK);
Rafael Espindola4d37b2a2015-05-29 21:45:01 +0000230 Symbol->setExternal(true);
Matt Fleming6c1ad482010-08-16 18:57:57 +0000231 break;
232
233 case MCSA_Local:
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000234 Symbol->setBinding(ELF::STB_LOCAL);
Rafael Espindola4d37b2a2015-05-29 21:45:01 +0000235 Symbol->setExternal(false);
Matt Fleming6c1ad482010-08-16 18:57:57 +0000236 break;
237
238 case MCSA_ELF_TypeFunction:
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000239 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_FUNC));
Matt Fleming6c1ad482010-08-16 18:57:57 +0000240 break;
241
Roman Divacky735cb8b2011-12-12 17:34:04 +0000242 case MCSA_ELF_TypeIndFunction:
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000243 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_GNU_IFUNC));
Roman Divacky735cb8b2011-12-12 17:34:04 +0000244 break;
245
Matt Fleming6c1ad482010-08-16 18:57:57 +0000246 case MCSA_ELF_TypeObject:
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000247 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT));
Matt Fleming6c1ad482010-08-16 18:57:57 +0000248 break;
249
250 case MCSA_ELF_TypeTLS:
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000251 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_TLS));
Matt Fleming6c1ad482010-08-16 18:57:57 +0000252 break;
253
254 case MCSA_ELF_TypeCommon:
Peter Collingbourneadac4072013-04-10 16:52:15 +0000255 // TODO: Emit these as a common symbol.
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000256 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT));
Matt Fleming6c1ad482010-08-16 18:57:57 +0000257 break;
258
259 case MCSA_ELF_TypeNoType:
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000260 Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_NOTYPE));
Matt Fleming6c1ad482010-08-16 18:57:57 +0000261 break;
262
263 case MCSA_Protected:
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000264 Symbol->setVisibility(ELF::STV_PROTECTED);
Matt Fleming6c1ad482010-08-16 18:57:57 +0000265 break;
266
267 case MCSA_Hidden:
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000268 Symbol->setVisibility(ELF::STV_HIDDEN);
Matt Fleming6c1ad482010-08-16 18:57:57 +0000269 break;
270
271 case MCSA_Internal:
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000272 Symbol->setVisibility(ELF::STV_INTERNAL);
Matt Fleming6c1ad482010-08-16 18:57:57 +0000273 break;
Lang Hames1b640e02016-03-15 01:43:05 +0000274
275 case MCSA_AltEntry:
Lang Hamesf9033bb2016-04-11 18:33:45 +0000276 llvm_unreachable("ELF doesn't support the .alt_entry attribute");
Matt Fleming6c1ad482010-08-16 18:57:57 +0000277 }
Saleem Abdulrasool4208b612013-08-09 01:52:03 +0000278
279 return true;
Matt Fleming6c1ad482010-08-16 18:57:57 +0000280}
281
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000282void MCELFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size,
Rafael Espindolab5d316b2015-05-29 20:21:02 +0000283 unsigned ByteAlignment) {
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000284 auto *Symbol = cast<MCSymbolELF>(S);
Rafael Espindolab5d316b2015-05-29 20:21:02 +0000285 getAssembler().registerSymbol(*Symbol);
Matt Fleming6c1ad482010-08-16 18:57:57 +0000286
Rafael Espindolaf6dcd2a2015-06-03 21:18:03 +0000287 if (!Symbol->isBindingSet()) {
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000288 Symbol->setBinding(ELF::STB_GLOBAL);
Rafael Espindola4d37b2a2015-05-29 21:45:01 +0000289 Symbol->setExternal(true);
Rafael Espindolaf0591c12010-09-21 00:24:38 +0000290 }
291
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000292 Symbol->setType(ELF::STT_OBJECT);
Rafael Espindolaa7d0bed2010-11-14 21:11:16 +0000293
Rafael Espindolaf8794ff2015-06-04 00:47:43 +0000294 if (Symbol->getBinding() == ELF::STB_LOCAL) {
Rafael Espindolae7fe1a42015-11-03 18:50:51 +0000295 MCSection &Section = *getAssembler().getContext().getELFSection(
296 ".bss", ELF::SHT_NOBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
297 MCSectionSubPair P = getCurrentSection();
298 SwitchSection(&Section);
299
300 EmitValueToAlignment(ByteAlignment, 0, 1, 0);
301 EmitLabel(Symbol);
302 EmitZeros(Size);
303
304 // Update the maximum alignment of the section if necessary.
305 if (ByteAlignment > Section.getAlignment())
306 Section.setAlignment(ByteAlignment);
307
308 SwitchSection(P.first, P.second);
Rafael Espindolaf0591c12010-09-21 00:24:38 +0000309 } else {
Colin LeMahieu1c8c2132015-06-06 20:12:40 +0000310 if(Symbol->declareCommon(Size, ByteAlignment))
311 report_fatal_error("Symbol: " + Symbol->getName() +
312 " redeclared as different type");
Matt Fleming6c1ad482010-08-16 18:57:57 +0000313 }
314
Rafael Espindolaa8695762015-06-02 00:25:12 +0000315 cast<MCSymbolELF>(Symbol)
316 ->setSize(MCConstantExpr::create(Size, getContext()));
Matt Fleming6c1ad482010-08-16 18:57:57 +0000317}
318
Dan Gohman734c59d2016-12-01 23:39:08 +0000319void MCELFStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
320 cast<MCSymbolELF>(Symbol)->setSize(Value);
Logan Chien59ff0702012-12-07 15:50:40 +0000321}
322
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000323void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *S, uint64_t Size,
Benjamin Kramer63970512011-09-01 23:04:27 +0000324 unsigned ByteAlignment) {
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000325 auto *Symbol = cast<MCSymbolELF>(S);
Jason W Kim4c1386a2010-12-16 03:12:17 +0000326 // FIXME: Should this be caught and done earlier?
Rafael Espindolab5d316b2015-05-29 20:21:02 +0000327 getAssembler().registerSymbol(*Symbol);
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000328 Symbol->setBinding(ELF::STB_LOCAL);
Rafael Espindola4d37b2a2015-05-29 21:45:01 +0000329 Symbol->setExternal(false);
Benjamin Kramer63970512011-09-01 23:04:27 +0000330 EmitCommonSymbol(Symbol, Size, ByteAlignment);
Jason W Kim4c1386a2010-12-16 03:12:17 +0000331}
332
Kevin Enderby96918bc2014-04-22 17:27:29 +0000333void MCELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
Craig Topper3c76c522015-09-20 23:35:59 +0000334 SMLoc Loc) {
Rafael Espindolac1cd9442015-05-25 14:57:35 +0000335 if (isBundleLocked())
Eli Benderskyf483ff92012-12-20 19:05:53 +0000336 report_fatal_error("Emitting values inside a locked bundle is forbidden");
David Meyer44ec69e2012-02-15 15:09:06 +0000337 fixSymbolsInTLSFixups(Value);
Kevin Enderby96918bc2014-04-22 17:27:29 +0000338 MCObjectStreamer::EmitValueImpl(Value, Size, Loc);
David Meyer44ec69e2012-02-15 15:09:06 +0000339}
340
Eli Benderskyf483ff92012-12-20 19:05:53 +0000341void MCELFStreamer::EmitValueToAlignment(unsigned ByteAlignment,
342 int64_t Value,
343 unsigned ValueSize,
344 unsigned MaxBytesToEmit) {
Rafael Espindolac1cd9442015-05-25 14:57:35 +0000345 if (isBundleLocked())
Eli Benderskyf483ff92012-12-20 19:05:53 +0000346 report_fatal_error("Emitting values inside a locked bundle is forbidden");
347 MCObjectStreamer::EmitValueToAlignment(ByteAlignment, Value,
348 ValueSize, MaxBytesToEmit);
349}
350
Rafael Espindola5645bad2013-10-16 01:05:45 +0000351void MCELFStreamer::EmitIdent(StringRef IdentString) {
Rafael Espindola0709a7b2015-05-21 19:20:38 +0000352 MCSection *Comment = getAssembler().getContext().getELFSection(
Rafael Espindolaba31e272015-01-29 17:33:21 +0000353 ".comment", ELF::SHT_PROGBITS, ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
Rafael Espindola5645bad2013-10-16 01:05:45 +0000354 PushSection();
355 SwitchSection(Comment);
356 if (!SeenIdent) {
357 EmitIntValue(0, 1);
358 SeenIdent = true;
359 }
360 EmitBytes(IdentString);
361 EmitIntValue(0, 1);
362 PopSection();
363}
364
365void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
Rafael Espindola4e70ac72010-11-24 02:19:40 +0000366 switch (expr->getKind()) {
Tim Northovere0e3aef2013-01-31 12:12:40 +0000367 case MCExpr::Target:
368 cast<MCTargetExpr>(expr)->fixELFSymbolsInTLSFixups(getAssembler());
369 break;
Rafael Espindola4e70ac72010-11-24 02:19:40 +0000370 case MCExpr::Constant:
371 break;
372
373 case MCExpr::Binary: {
374 const MCBinaryExpr *be = cast<MCBinaryExpr>(expr);
375 fixSymbolsInTLSFixups(be->getLHS());
376 fixSymbolsInTLSFixups(be->getRHS());
377 break;
378 }
379
380 case MCExpr::SymbolRef: {
381 const MCSymbolRefExpr &symRef = *cast<MCSymbolRefExpr>(expr);
Rafael Espindolae98d4832010-11-24 18:51:21 +0000382 switch (symRef.getKind()) {
383 default:
Rafael Espindola4e70ac72010-11-24 02:19:40 +0000384 return;
Joerg Sonnenberger07de07e2011-03-17 00:35:10 +0000385 case MCSymbolRefExpr::VK_GOTTPOFF:
386 case MCSymbolRefExpr::VK_INDNTPOFF:
Rafael Espindolae98d4832010-11-24 18:51:21 +0000387 case MCSymbolRefExpr::VK_NTPOFF:
388 case MCSymbolRefExpr::VK_GOTNTPOFF:
389 case MCSymbolRefExpr::VK_TLSGD:
Joerg Sonnenberger07de07e2011-03-17 00:35:10 +0000390 case MCSymbolRefExpr::VK_TLSLD:
Rafael Espindolae98d4832010-11-24 18:51:21 +0000391 case MCSymbolRefExpr::VK_TLSLDM:
392 case MCSymbolRefExpr::VK_TPOFF:
Colin LeMahieu0e051922016-02-10 18:32:01 +0000393 case MCSymbolRefExpr::VK_TPREL:
Rafael Espindolae98d4832010-11-24 18:51:21 +0000394 case MCSymbolRefExpr::VK_DTPOFF:
Colin LeMahieu0e051922016-02-10 18:32:01 +0000395 case MCSymbolRefExpr::VK_DTPREL:
Ulrich Weigandf11efe72013-07-01 23:33:29 +0000396 case MCSymbolRefExpr::VK_PPC_DTPMOD:
Ulrich Weigandd51c09f2013-06-21 14:42:20 +0000397 case MCSymbolRefExpr::VK_PPC_TPREL_LO:
Ulrich Weigand876a0d02013-06-21 14:44:15 +0000398 case MCSymbolRefExpr::VK_PPC_TPREL_HI:
Ulrich Weigandd51c09f2013-06-21 14:42:20 +0000399 case MCSymbolRefExpr::VK_PPC_TPREL_HA:
Ulrich Weigand876a0d02013-06-21 14:44:15 +0000400 case MCSymbolRefExpr::VK_PPC_TPREL_HIGHER:
401 case MCSymbolRefExpr::VK_PPC_TPREL_HIGHERA:
402 case MCSymbolRefExpr::VK_PPC_TPREL_HIGHEST:
403 case MCSymbolRefExpr::VK_PPC_TPREL_HIGHESTA:
Ulrich Weigandd51c09f2013-06-21 14:42:20 +0000404 case MCSymbolRefExpr::VK_PPC_DTPREL_LO:
Ulrich Weigand876a0d02013-06-21 14:44:15 +0000405 case MCSymbolRefExpr::VK_PPC_DTPREL_HI:
Ulrich Weigandd51c09f2013-06-21 14:42:20 +0000406 case MCSymbolRefExpr::VK_PPC_DTPREL_HA:
Ulrich Weigand876a0d02013-06-21 14:44:15 +0000407 case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHER:
408 case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHERA:
409 case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHEST:
410 case MCSymbolRefExpr::VK_PPC_DTPREL_HIGHESTA:
411 case MCSymbolRefExpr::VK_PPC_GOT_TPREL:
Ulrich Weigandd51c09f2013-06-21 14:42:20 +0000412 case MCSymbolRefExpr::VK_PPC_GOT_TPREL_LO:
Ulrich Weigand876a0d02013-06-21 14:44:15 +0000413 case MCSymbolRefExpr::VK_PPC_GOT_TPREL_HI:
Ulrich Weigandd51c09f2013-06-21 14:42:20 +0000414 case MCSymbolRefExpr::VK_PPC_GOT_TPREL_HA:
Ulrich Weigand876a0d02013-06-21 14:44:15 +0000415 case MCSymbolRefExpr::VK_PPC_GOT_DTPREL:
416 case MCSymbolRefExpr::VK_PPC_GOT_DTPREL_LO:
417 case MCSymbolRefExpr::VK_PPC_GOT_DTPREL_HI:
418 case MCSymbolRefExpr::VK_PPC_GOT_DTPREL_HA:
Bill Schmidt441907d2013-02-26 16:41:03 +0000419 case MCSymbolRefExpr::VK_PPC_TLS:
Ulrich Weigand876a0d02013-06-21 14:44:15 +0000420 case MCSymbolRefExpr::VK_PPC_GOT_TLSGD:
Ulrich Weigandd51c09f2013-06-21 14:42:20 +0000421 case MCSymbolRefExpr::VK_PPC_GOT_TLSGD_LO:
Ulrich Weigand876a0d02013-06-21 14:44:15 +0000422 case MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HI:
Ulrich Weigandd51c09f2013-06-21 14:42:20 +0000423 case MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HA:
Ulrich Weigand52cf8e42013-07-09 16:41:09 +0000424 case MCSymbolRefExpr::VK_PPC_TLSGD:
Ulrich Weigand876a0d02013-06-21 14:44:15 +0000425 case MCSymbolRefExpr::VK_PPC_GOT_TLSLD:
Ulrich Weigandd51c09f2013-06-21 14:42:20 +0000426 case MCSymbolRefExpr::VK_PPC_GOT_TLSLD_LO:
Ulrich Weigand876a0d02013-06-21 14:44:15 +0000427 case MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HI:
Ulrich Weigandd51c09f2013-06-21 14:42:20 +0000428 case MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HA:
Ulrich Weigand52cf8e42013-07-09 16:41:09 +0000429 case MCSymbolRefExpr::VK_PPC_TLSLD:
Rafael Espindolae98d4832010-11-24 18:51:21 +0000430 break;
431 }
Rafael Espindolab5d316b2015-05-29 20:21:02 +0000432 getAssembler().registerSymbol(symRef.getSymbol());
Rafael Espindola95fb9b92015-06-02 20:38:46 +0000433 cast<MCSymbolELF>(symRef.getSymbol()).setType(ELF::STT_TLS);
Rafael Espindola4e70ac72010-11-24 02:19:40 +0000434 break;
435 }
436
437 case MCExpr::Unary:
438 fixSymbolsInTLSFixups(cast<MCUnaryExpr>(expr)->getSubExpr());
439 break;
440 }
441}
442
David Woodhouse6f3c73f2014-01-28 23:12:49 +0000443void MCELFStreamer::EmitInstToFragment(const MCInst &Inst,
444 const MCSubtargetInfo &STI) {
445 this->MCObjectStreamer::EmitInstToFragment(Inst, STI);
Eli Bendersky4d9ada02013-01-08 00:22:56 +0000446 MCRelaxableFragment &F = *cast<MCRelaxableFragment>(getCurrentFragment());
Benjamin Kramer1f601242010-08-27 10:40:51 +0000447
Rafael Espindola3fa6fc12010-12-02 05:44:06 +0000448 for (unsigned i = 0, e = F.getFixups().size(); i != e; ++i)
449 fixSymbolsInTLSFixups(F.getFixups()[i].getValue());
Benjamin Kramer1f601242010-08-27 10:40:51 +0000450}
451
David Woodhouse6f3c73f2014-01-28 23:12:49 +0000452void MCELFStreamer::EmitInstToData(const MCInst &Inst,
453 const MCSubtargetInfo &STI) {
Eli Benderskyf483ff92012-12-20 19:05:53 +0000454 MCAssembler &Assembler = getAssembler();
Benjamin Kramer1f601242010-08-27 10:40:51 +0000455 SmallVector<MCFixup, 4> Fixups;
456 SmallString<256> Code;
457 raw_svector_ostream VecOS(Code);
Jim Grosbach91df21f2015-05-15 19:13:16 +0000458 Assembler.getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
Benjamin Kramer1f601242010-08-27 10:40:51 +0000459
Rafael Espindola4e70ac72010-11-24 02:19:40 +0000460 for (unsigned i = 0, e = Fixups.size(); i != e; ++i)
461 fixSymbolsInTLSFixups(Fixups[i].getValue());
462
Eli Benderskyf483ff92012-12-20 19:05:53 +0000463 // There are several possibilities here:
464 //
465 // If bundling is disabled, append the encoded instruction to the current data
466 // fragment (or create a new such fragment if the current fragment is not a
467 // data fragment).
468 //
469 // If bundling is enabled:
Eli Benderskycf6009b2013-01-15 23:22:09 +0000470 // - If we're not in a bundle-locked group, emit the instruction into a
471 // fragment of its own. If there are no fixups registered for the
472 // instruction, emit a MCCompactEncodedInstFragment. Otherwise, emit a
473 // MCDataFragment.
Eli Benderskyf483ff92012-12-20 19:05:53 +0000474 // - If we're in a bundle-locked group, append the instruction to the current
475 // data fragment because we want all the instructions in a group to get into
476 // the same fragment. Be careful not to do that for the first instruction in
477 // the group, though.
478 MCDataFragment *DF;
479
480 if (Assembler.isBundlingEnabled()) {
Rafael Espindola983bec62015-05-27 21:04:14 +0000481 MCSection &Sec = *getCurrentSectionOnly();
Rafael Espindolac1cd9442015-05-25 14:57:35 +0000482 if (Assembler.getRelaxAll() && isBundleLocked())
Petr Hosek9e0c8902015-04-12 23:42:25 +0000483 // If the -mc-relax-all flag is used and we are bundle-locked, we re-use
484 // the current bundle group.
485 DF = BundleGroups.back();
Rafael Espindolac1cd9442015-05-25 14:57:35 +0000486 else if (Assembler.getRelaxAll() && !isBundleLocked())
Petr Hosek9e0c8902015-04-12 23:42:25 +0000487 // When not in a bundle-locked group and the -mc-relax-all flag is used,
488 // we create a new temporary fragment which will be later merged into
489 // the current fragment.
490 DF = new MCDataFragment();
Rafael Espindolab028cc82015-05-25 15:04:26 +0000491 else if (isBundleLocked() && !Sec.isBundleGroupBeforeFirstInst())
Derek Schuff8878bcc92013-02-15 22:50:52 +0000492 // If we are bundle-locked, we re-use the current fragment.
493 // The bundle-locking directive ensures this is a new data fragment.
494 DF = cast<MCDataFragment>(getCurrentFragment());
Rafael Espindolac1cd9442015-05-25 14:57:35 +0000495 else if (!isBundleLocked() && Fixups.size() == 0) {
Eli Benderskycf6009b2013-01-15 23:22:09 +0000496 // Optimize memory usage by emitting the instruction to a
497 // MCCompactEncodedInstFragment when not in a bundle-locked group and
498 // there are no fixups registered.
Peter Collingbourne2f495b92013-04-17 21:18:16 +0000499 MCCompactEncodedInstFragment *CEIF = new MCCompactEncodedInstFragment();
500 insert(CEIF);
Eli Benderskycf6009b2013-01-15 23:22:09 +0000501 CEIF->getContents().append(Code.begin(), Code.end());
502 return;
Derek Schuff8878bcc92013-02-15 22:50:52 +0000503 } else {
Peter Collingbourne2f495b92013-04-17 21:18:16 +0000504 DF = new MCDataFragment();
505 insert(DF);
Derek Schuff05fb7352014-10-15 17:10:04 +0000506 }
Rafael Espindolab028cc82015-05-25 15:04:26 +0000507 if (Sec.getBundleLockState() == MCSection::BundleLockedAlignToEnd) {
Derek Schuff05fb7352014-10-15 17:10:04 +0000508 // If this fragment is for a group marked "align_to_end", set a flag
509 // in the fragment. This can happen after the fragment has already been
510 // created if there are nested bundle_align groups and an inner one
511 // is the one marked align_to_end.
512 DF->setAlignToBundleEnd(true);
Eli Bendersky802b6282013-01-07 21:51:08 +0000513 }
Eli Benderskyf483ff92012-12-20 19:05:53 +0000514
515 // We're now emitting an instruction in a bundle group, so this flag has
516 // to be turned off.
Rafael Espindolab028cc82015-05-25 15:04:26 +0000517 Sec.setBundleGroupBeforeFirstInst(false);
Eli Benderskyf483ff92012-12-20 19:05:53 +0000518 } else {
519 DF = getOrCreateDataFragment();
520 }
521
Benjamin Kramer1f601242010-08-27 10:40:51 +0000522 // Add the fixups and data.
523 for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
524 Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size());
Eli Benderskya31a8942012-12-07 19:13:57 +0000525 DF->getFixups().push_back(Fixups[i]);
Benjamin Kramer1f601242010-08-27 10:40:51 +0000526 }
Eli Benderskyf483ff92012-12-20 19:05:53 +0000527 DF->setHasInstructions(true);
Benjamin Kramer1f601242010-08-27 10:40:51 +0000528 DF->getContents().append(Code.begin(), Code.end());
Petr Hosek9e0c8902015-04-12 23:42:25 +0000529
530 if (Assembler.isBundlingEnabled() && Assembler.getRelaxAll()) {
Rafael Espindolac1cd9442015-05-25 14:57:35 +0000531 if (!isBundleLocked()) {
Petr Hosek9e0c8902015-04-12 23:42:25 +0000532 mergeFragment(getOrCreateDataFragment(), DF);
533 delete DF;
534 }
535 }
Benjamin Kramer1f601242010-08-27 10:40:51 +0000536}
537
Eli Benderskyf483ff92012-12-20 19:05:53 +0000538void MCELFStreamer::EmitBundleAlignMode(unsigned AlignPow2) {
539 assert(AlignPow2 <= 30 && "Invalid bundle alignment");
540 MCAssembler &Assembler = getAssembler();
Derek Schuff05fb7352014-10-15 17:10:04 +0000541 if (AlignPow2 > 0 && (Assembler.getBundleAlignSize() == 0 ||
542 Assembler.getBundleAlignSize() == 1U << AlignPow2))
543 Assembler.setBundleAlignSize(1U << AlignPow2);
Eli Benderskyf483ff92012-12-20 19:05:53 +0000544 else
Derek Schuff05fb7352014-10-15 17:10:04 +0000545 report_fatal_error(".bundle_align_mode cannot be changed once set");
Eli Benderskyf483ff92012-12-20 19:05:53 +0000546}
547
Eli Bendersky802b6282013-01-07 21:51:08 +0000548void MCELFStreamer::EmitBundleLock(bool AlignToEnd) {
Rafael Espindola983bec62015-05-27 21:04:14 +0000549 MCSection &Sec = *getCurrentSectionOnly();
Eli Benderskyf483ff92012-12-20 19:05:53 +0000550
551 // Sanity checks
552 //
553 if (!getAssembler().isBundlingEnabled())
554 report_fatal_error(".bundle_lock forbidden when bundling is disabled");
Derek Schuff05fb7352014-10-15 17:10:04 +0000555
Rafael Espindolac1cd9442015-05-25 14:57:35 +0000556 if (!isBundleLocked())
Rafael Espindolab028cc82015-05-25 15:04:26 +0000557 Sec.setBundleGroupBeforeFirstInst(true);
Eli Benderskyf483ff92012-12-20 19:05:53 +0000558
Rafael Espindolac1cd9442015-05-25 14:57:35 +0000559 if (getAssembler().getRelaxAll() && !isBundleLocked()) {
Petr Hosek9e0c8902015-04-12 23:42:25 +0000560 // TODO: drop the lock state and set directly in the fragment
561 MCDataFragment *DF = new MCDataFragment();
562 BundleGroups.push_back(DF);
563 }
564
Rafael Espindolab028cc82015-05-25 15:04:26 +0000565 Sec.setBundleLockState(AlignToEnd ? MCSection::BundleLockedAlignToEnd
566 : MCSection::BundleLocked);
Eli Benderskyf483ff92012-12-20 19:05:53 +0000567}
568
569void MCELFStreamer::EmitBundleUnlock() {
Rafael Espindola983bec62015-05-27 21:04:14 +0000570 MCSection &Sec = *getCurrentSectionOnly();
Eli Benderskyf483ff92012-12-20 19:05:53 +0000571
572 // Sanity checks
573 if (!getAssembler().isBundlingEnabled())
574 report_fatal_error(".bundle_unlock forbidden when bundling is disabled");
Rafael Espindolac1cd9442015-05-25 14:57:35 +0000575 else if (!isBundleLocked())
Eli Benderskyf483ff92012-12-20 19:05:53 +0000576 report_fatal_error(".bundle_unlock without matching lock");
Rafael Espindolab028cc82015-05-25 15:04:26 +0000577 else if (Sec.isBundleGroupBeforeFirstInst())
Eli Benderskyf483ff92012-12-20 19:05:53 +0000578 report_fatal_error("Empty bundle-locked group is forbidden");
579
Petr Hosek9e0c8902015-04-12 23:42:25 +0000580 // When the -mc-relax-all flag is used, we emit instructions to fragments
Benjamin Kramerdf005cb2015-08-08 18:27:36 +0000581 // stored on a stack. When the bundle unlock is emitted, we pop a fragment
Petr Hosek9e0c8902015-04-12 23:42:25 +0000582 // from the stack a merge it to the one below.
583 if (getAssembler().getRelaxAll()) {
584 assert(!BundleGroups.empty() && "There are no bundle groups");
585 MCDataFragment *DF = BundleGroups.back();
586
587 // FIXME: Use BundleGroups to track the lock state instead.
Rafael Espindolab028cc82015-05-25 15:04:26 +0000588 Sec.setBundleLockState(MCSection::NotBundleLocked);
Petr Hosek9e0c8902015-04-12 23:42:25 +0000589
Rafael Espindolac1cd9442015-05-25 14:57:35 +0000590 // FIXME: Use more separate fragments for nested groups.
591 if (!isBundleLocked()) {
Petr Hosek9e0c8902015-04-12 23:42:25 +0000592 mergeFragment(getOrCreateDataFragment(), DF);
593 BundleGroups.pop_back();
594 delete DF;
595 }
596
Rafael Espindolab028cc82015-05-25 15:04:26 +0000597 if (Sec.getBundleLockState() != MCSection::BundleLockedAlignToEnd)
Petr Hosek9e0c8902015-04-12 23:42:25 +0000598 getOrCreateDataFragment()->setAlignToBundleEnd(false);
599 } else
Rafael Espindolab028cc82015-05-25 15:04:26 +0000600 Sec.setBundleLockState(MCSection::NotBundleLocked);
Eli Benderskyf483ff92012-12-20 19:05:53 +0000601}
602
Richard Mitton21101b32013-09-19 23:21:01 +0000603void MCELFStreamer::FinishImpl() {
Derek Schuff2a1678a2015-04-21 00:14:25 +0000604 // Ensure the last section gets aligned if necessary.
Rafael Espindola983bec62015-05-27 21:04:14 +0000605 MCSection *CurSection = getCurrentSectionOnly();
Rafael Espindolae6e287d2015-05-26 14:42:52 +0000606 setSectionAlignmentForBundling(getAssembler(), CurSection);
Derek Schuff2a1678a2015-04-21 00:14:25 +0000607
Rafael Espindola7f4ccce2014-05-12 13:30:10 +0000608 EmitFrames(nullptr);
Richard Mitton21101b32013-09-19 23:21:01 +0000609
Rafael Espindola07082092012-01-07 03:13:18 +0000610 this->MCObjectStreamer::FinishImpl();
Matt Fleming6c1ad482010-08-16 18:57:57 +0000611}
Richard Mitton21101b32013-09-19 23:21:01 +0000612
Tim Northover5cc3dc82012-12-07 16:50:23 +0000613void MCELFStreamer::EmitThumbFunc(MCSymbol *Func) {
614 llvm_unreachable("Generic ELF doesn't support this directive");
615}
616
Logan Chien59ff0702012-12-07 15:50:40 +0000617void MCELFStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
618 llvm_unreachable("ELF doesn't support this directive");
619}
620
Rafael Espindola0709a7b2015-05-21 19:20:38 +0000621void MCELFStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
Logan Chien59ff0702012-12-07 15:50:40 +0000622 uint64_t Size, unsigned ByteAlignment) {
623 llvm_unreachable("ELF doesn't support this directive");
624}
625
Rafael Espindola0709a7b2015-05-21 19:20:38 +0000626void MCELFStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
Logan Chien59ff0702012-12-07 15:50:40 +0000627 uint64_t Size, unsigned ByteAlignment) {
628 llvm_unreachable("ELF doesn't support this directive");
629}
Eugene Zelenko1d435522017-02-07 23:02:00 +0000630
631MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB,
632 raw_pwrite_stream &OS, MCCodeEmitter *CE,
633 bool RelaxAll) {
634 MCELFStreamer *S = new MCELFStreamer(Context, MAB, OS, CE);
635 if (RelaxAll)
636 S->getAssembler().setRelaxAll(true);
637 return S;
638}