LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCELFStreamer.cpp
Go to the documentation of this file.
1 //===- lib/MC/MCELFStreamer.cpp - ELF Object Output -----------------------===//
2 //
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 
14 #include "llvm/MC/MCELFStreamer.h"
15 #include "llvm/ADT/SmallPtrSet.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/MC/MCAssembler.h"
18 #include "llvm/MC/MCCodeEmitter.h"
19 #include "llvm/MC/MCContext.h"
20 #include "llvm/MC/MCELF.h"
22 #include "llvm/MC/MCExpr.h"
23 #include "llvm/MC/MCInst.h"
25 #include "llvm/MC/MCSection.h"
26 #include "llvm/MC/MCSectionELF.h"
27 #include "llvm/MC/MCSymbol.h"
28 #include "llvm/MC/MCValue.h"
29 #include "llvm/Support/Debug.h"
30 #include "llvm/Support/ELF.h"
33 
34 using namespace llvm;
35 
36 
37 inline void MCELFStreamer::SetSection(StringRef Section, unsigned Type,
38  unsigned Flags, SectionKind Kind) {
39  SwitchSection(getContext().getELFSection(Section, Type, Flags, Kind));
40 }
41 
42 inline void MCELFStreamer::SetSectionData() {
43  SetSection(".data",
44  ELF::SHT_PROGBITS,
45  ELF::SHF_WRITE | ELF::SHF_ALLOC,
47  EmitCodeAlignment(4, 0);
48 }
49 
50 inline void MCELFStreamer::SetSectionText() {
51  SetSection(".text",
52  ELF::SHT_PROGBITS,
53  ELF::SHF_EXECINSTR | ELF::SHF_ALLOC,
55  EmitCodeAlignment(4, 0);
56 }
57 
58 inline void MCELFStreamer::SetSectionBss() {
59  SetSection(".bss",
60  ELF::SHT_NOBITS,
61  ELF::SHF_WRITE | ELF::SHF_ALLOC,
63  EmitCodeAlignment(4, 0);
64 }
65 
67 }
68 
70  SetSectionText();
71 }
72 
74  // This emulates the same behavior of GNU as. This makes it easier
75  // to compare the output as the major sections are in the same order.
76  SetSectionText();
77  SetSectionData();
78  SetSectionBss();
79  SetSectionText();
80 }
81 
83  assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
84 
86 
87  const MCSectionELF &Section =
88  static_cast<const MCSectionELF&>(Symbol->getSection());
89  MCSymbolData &SD = getAssembler().getSymbolData(*Symbol);
90  if (Section.getFlags() & ELF::SHF_TLS)
92 }
93 
95  EmitLabel(Symbol);
96 }
97 
99  switch (Flag) {
100  case MCAF_SyntaxUnified: return; // no-op here.
101  case MCAF_Code16: return; // Change parsing mode; no-op here.
102  case MCAF_Code32: return; // Change parsing mode; no-op here.
103  case MCAF_Code64: return; // Change parsing mode; no-op here.
106  return;
107  }
108 
109  llvm_unreachable("invalid assembler flag!");
110 }
111 
113  const MCExpr *Subsection) {
114  MCSectionData *CurSection = getCurrentSectionData();
115  if (CurSection && CurSection->isBundleLocked())
116  report_fatal_error("Unterminated .bundle_lock when changing a section");
117  const MCSymbol *Grp = static_cast<const MCSectionELF *>(Section)->getGroup();
118  if (Grp)
120  this->MCObjectStreamer::ChangeSection(Section, Subsection);
121 }
122 
125  MCSymbolData &AliasSD = getAssembler().getOrCreateSymbolData(*Alias);
126  AliasSD.setFlags(AliasSD.getFlags() | ELF_Other_Weakref);
127  const MCExpr *Value = MCSymbolRefExpr::Create(Symbol, getContext());
128  Alias->setVariableValue(Value);
129 }
130 
131 // When GNU as encounters more than one .type declaration for an object it seems
132 // to use a mechanism similar to the one below to decide which type is actually
133 // used in the object file. The greater of T1 and T2 is selected based on the
134 // following ordering:
135 // STT_NOTYPE < STT_OBJECT < STT_FUNC < STT_GNU_IFUNC < STT_TLS < anything else
136 // If neither T1 < T2 nor T2 < T1 according to this ordering, use T2 (the user
137 // provided type).
138 static unsigned CombineSymbolTypes(unsigned T1, unsigned T2) {
139  unsigned TypeOrdering[] = {ELF::STT_NOTYPE, ELF::STT_OBJECT, ELF::STT_FUNC,
141  for (unsigned i = 0; i != array_lengthof(TypeOrdering); ++i) {
142  if (T1 == TypeOrdering[i])
143  return T2;
144  if (T2 == TypeOrdering[i])
145  return T1;
146  }
147 
148  return T2;
149 }
150 
153  // Indirect symbols are handled differently, to match how 'as' handles
154  // them. This makes writing matching .o files easier.
155  if (Attribute == MCSA_IndirectSymbol) {
156  // Note that we intentionally cannot use the symbol data here; this is
157  // important for matching the string table that 'as' generates.
158  IndirectSymbolData ISD;
159  ISD.Symbol = Symbol;
161  getAssembler().getIndirectSymbols().push_back(ISD);
162  return true;
163  }
164 
165  // Adding a symbol attribute always introduces the symbol, note that an
166  // important side effect of calling getOrCreateSymbolData here is to register
167  // the symbol with the assembler.
169 
170  // The implementation of symbol attributes is designed to match 'as', but it
171  // leaves much to desired. It doesn't really make sense to arbitrarily add and
172  // remove flags, but 'as' allows this (in particular, see .desc).
173  //
174  // In the future it might be worth trying to make these operations more well
175  // defined.
176  switch (Attribute) {
177  case MCSA_LazyReference:
178  case MCSA_Reference:
179  case MCSA_SymbolResolver:
180  case MCSA_PrivateExtern:
181  case MCSA_WeakDefinition:
183  case MCSA_Invalid:
184  case MCSA_IndirectSymbol:
185  return false;
186 
187  case MCSA_NoDeadStrip:
189  // Ignore for now.
190  break;
191 
192  case MCSA_Global:
194  SD.setExternal(true);
195  BindingExplicitlySet.insert(Symbol);
196  break;
197 
198  case MCSA_WeakReference:
199  case MCSA_Weak:
201  SD.setExternal(true);
202  BindingExplicitlySet.insert(Symbol);
203  break;
204 
205  case MCSA_Local:
207  SD.setExternal(false);
208  BindingExplicitlySet.insert(Symbol);
209  break;
210 
213  ELF::STT_FUNC));
214  break;
215 
219  break;
220 
221  case MCSA_ELF_TypeObject:
223  ELF::STT_OBJECT));
224  break;
225 
226  case MCSA_ELF_TypeTLS:
228  ELF::STT_TLS));
229  break;
230 
231  case MCSA_ELF_TypeCommon:
232  // TODO: Emit these as a common symbol.
234  ELF::STT_OBJECT));
235  break;
236 
237  case MCSA_ELF_TypeNoType:
239  ELF::STT_NOTYPE));
240  break;
241 
242  case MCSA_Protected:
244  break;
245 
246  case MCSA_Hidden:
248  break;
249 
250  case MCSA_Internal:
252  break;
253  }
254 
255  return true;
256 }
257 
259  unsigned ByteAlignment) {
261 
262  if (!BindingExplicitlySet.count(Symbol)) {
264  SD.setExternal(true);
265  }
266 
268 
269  if (MCELF::GetBinding(SD) == ELF_STB_Local) {
270  const MCSection *Section = getAssembler().getContext().getELFSection(".bss",
271  ELF::SHT_NOBITS,
272  ELF::SHF_WRITE |
273  ELF::SHF_ALLOC,
275 
276  AssignSection(Symbol, Section);
277 
278  struct LocalCommon L = {&SD, Size, ByteAlignment};
279  LocalCommons.push_back(L);
280  } else {
281  SD.setCommon(Size, ByteAlignment);
282  }
283 
285 }
286 
289  SD.setSize(Value);
290 }
291 
293  unsigned ByteAlignment) {
294  // FIXME: Should this be caught and done earlier?
297  SD.setExternal(false);
298  BindingExplicitlySet.insert(Symbol);
299  EmitCommonSymbol(Symbol, Size, ByteAlignment);
300 }
301 
302 void MCELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size) {
303  if (getCurrentSectionData()->isBundleLocked())
304  report_fatal_error("Emitting values inside a locked bundle is forbidden");
305  fixSymbolsInTLSFixups(Value);
306  MCObjectStreamer::EmitValueImpl(Value, Size);
307 }
308 
310  int64_t Value,
311  unsigned ValueSize,
312  unsigned MaxBytesToEmit) {
313  if (getCurrentSectionData()->isBundleLocked())
314  report_fatal_error("Emitting values inside a locked bundle is forbidden");
315  MCObjectStreamer::EmitValueToAlignment(ByteAlignment, Value,
316  ValueSize, MaxBytesToEmit);
317 }
318 
319 // Add a symbol for the file name of this module. They start after the
320 // null symbol and don't count as normal symbol, i.e. a non-STT_FILE symbol
321 // with the same name may appear.
323  getAssembler().addFileName(Filename);
324 }
325 
327  const MCSection *Comment = getAssembler().getContext().getELFSection(
328  ".comment", ELF::SHT_PROGBITS, ELF::SHF_MERGE | ELF::SHF_STRINGS,
329  SectionKind::getReadOnly(), 1, "");
330  PushSection();
331  SwitchSection(Comment);
332  if (!SeenIdent) {
333  EmitIntValue(0, 1);
334  SeenIdent = true;
335  }
336  EmitBytes(IdentString);
337  EmitIntValue(0, 1);
338  PopSection();
339 }
340 
341 void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
342  switch (expr->getKind()) {
343  case MCExpr::Target:
344  cast<MCTargetExpr>(expr)->fixELFSymbolsInTLSFixups(getAssembler());
345  break;
346  case MCExpr::Constant:
347  break;
348 
349  case MCExpr::Binary: {
350  const MCBinaryExpr *be = cast<MCBinaryExpr>(expr);
351  fixSymbolsInTLSFixups(be->getLHS());
352  fixSymbolsInTLSFixups(be->getRHS());
353  break;
354  }
355 
356  case MCExpr::SymbolRef: {
357  const MCSymbolRefExpr &symRef = *cast<MCSymbolRefExpr>(expr);
358  switch (symRef.getKind()) {
359  default:
360  return;
413  break;
414  }
417  break;
418  }
419 
420  case MCExpr::Unary:
421  fixSymbolsInTLSFixups(cast<MCUnaryExpr>(expr)->getSubExpr());
422  break;
423  }
424 }
425 
426 void MCELFStreamer::EmitInstToFragment(const MCInst &Inst) {
428  MCRelaxableFragment &F = *cast<MCRelaxableFragment>(getCurrentFragment());
429 
430  for (unsigned i = 0, e = F.getFixups().size(); i != e; ++i)
431  fixSymbolsInTLSFixups(F.getFixups()[i].getValue());
432 }
433 
434 void MCELFStreamer::EmitInstToData(const MCInst &Inst) {
435  MCAssembler &Assembler = getAssembler();
438  raw_svector_ostream VecOS(Code);
439  Assembler.getEmitter().EncodeInstruction(Inst, VecOS, Fixups);
440  VecOS.flush();
441 
442  for (unsigned i = 0, e = Fixups.size(); i != e; ++i)
443  fixSymbolsInTLSFixups(Fixups[i].getValue());
444 
445  // There are several possibilities here:
446  //
447  // If bundling is disabled, append the encoded instruction to the current data
448  // fragment (or create a new such fragment if the current fragment is not a
449  // data fragment).
450  //
451  // If bundling is enabled:
452  // - If we're not in a bundle-locked group, emit the instruction into a
453  // fragment of its own. If there are no fixups registered for the
454  // instruction, emit a MCCompactEncodedInstFragment. Otherwise, emit a
455  // MCDataFragment.
456  // - If we're in a bundle-locked group, append the instruction to the current
457  // data fragment because we want all the instructions in a group to get into
458  // the same fragment. Be careful not to do that for the first instruction in
459  // the group, though.
461 
462  if (Assembler.isBundlingEnabled()) {
464  if (SD->isBundleLocked() && !SD->isBundleGroupBeforeFirstInst())
465  // If we are bundle-locked, we re-use the current fragment.
466  // The bundle-locking directive ensures this is a new data fragment.
467  DF = cast<MCDataFragment>(getCurrentFragment());
468  else if (!SD->isBundleLocked() && Fixups.size() == 0) {
469  // Optimize memory usage by emitting the instruction to a
470  // MCCompactEncodedInstFragment when not in a bundle-locked group and
471  // there are no fixups registered.
473  insert(CEIF);
474  CEIF->getContents().append(Code.begin(), Code.end());
475  return;
476  } else {
477  DF = new MCDataFragment();
478  insert(DF);
480  // If this is a new fragment created for a bundle-locked group, and the
481  // group was marked as "align_to_end", set a flag in the fragment.
482  DF->setAlignToBundleEnd(true);
483  }
484  }
485 
486  // We're now emitting an instruction in a bundle group, so this flag has
487  // to be turned off.
489  } else {
491  }
492 
493  // Add the fixups and data.
494  for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
495  Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size());
496  DF->getFixups().push_back(Fixups[i]);
497  }
498  DF->setHasInstructions(true);
499  DF->getContents().append(Code.begin(), Code.end());
500 }
501 
502 void MCELFStreamer::EmitBundleAlignMode(unsigned AlignPow2) {
503  assert(AlignPow2 <= 30 && "Invalid bundle alignment");
504  MCAssembler &Assembler = getAssembler();
505  if (Assembler.getBundleAlignSize() == 0 && AlignPow2 > 0)
506  Assembler.setBundleAlignSize(1 << AlignPow2);
507  else
508  report_fatal_error(".bundle_align_mode should be only set once per file");
509 }
510 
511 void MCELFStreamer::EmitBundleLock(bool AlignToEnd) {
513 
514  // Sanity checks
515  //
516  if (!getAssembler().isBundlingEnabled())
517  report_fatal_error(".bundle_lock forbidden when bundling is disabled");
518  else if (SD->isBundleLocked())
519  report_fatal_error("Nesting of .bundle_lock is forbidden");
520 
524 }
525 
526 void MCELFStreamer::EmitBundleUnlock() {
528 
529  // Sanity checks
530  if (!getAssembler().isBundlingEnabled())
531  report_fatal_error(".bundle_unlock forbidden when bundling is disabled");
532  else if (!SD->isBundleLocked())
533  report_fatal_error(".bundle_unlock without matching lock");
534  else if (SD->isBundleGroupBeforeFirstInst())
535  report_fatal_error("Empty bundle-locked group is forbidden");
536 
538 }
539 
541  for (std::vector<LocalCommon>::const_iterator i = LocalCommons.begin(),
542  e = LocalCommons.end();
543  i != e; ++i) {
544  MCSymbolData *SD = i->SD;
545  uint64_t Size = i->Size;
546  unsigned ByteAlignment = i->ByteAlignment;
547  const MCSymbol &Symbol = SD->getSymbol();
548  const MCSection &Section = Symbol.getSection();
549 
550  MCSectionData &SectData = getAssembler().getOrCreateSectionData(Section);
551  new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &SectData);
552 
553  MCFragment *F = new MCFillFragment(0, 0, Size, &SectData);
554  SD->setFragment(F);
555 
556  // Update the maximum alignment of the section if necessary.
557  if (ByteAlignment > SectData.getAlignment())
558  SectData.setAlignment(ByteAlignment);
559  }
560 
561  LocalCommons.clear();
562 }
563 
565  EmitFrames(NULL, true);
566 
567  Flush();
568 
570 }
571 
573  MCTargetStreamer *Streamer,
574  MCAsmBackend &MAB, raw_ostream &OS,
575  MCCodeEmitter *CE, bool RelaxAll,
576  bool NoExecStack) {
577  MCELFStreamer *S = new MCELFStreamer(Context, Streamer, MAB, OS, CE);
578  if (RelaxAll)
579  S->getAssembler().setRelaxAll(true);
580  if (NoExecStack)
581  S->getAssembler().setNoExecStack(true);
582  return S;
583 }
584 
586  llvm_unreachable("Generic ELF doesn't support this directive");
587 }
588 
590  return getAssembler().getOrCreateSymbolData(*Symbol);
591 }
592 
593 void MCELFStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
594  llvm_unreachable("ELF doesn't support this directive");
595 }
596 
598  llvm_unreachable("ELF doesn't support this directive");
599 }
600 
602  llvm_unreachable("ELF doesn't support this directive");
603 }
604 
606  llvm_unreachable("ELF doesn't support this directive");
607 }
608 
610  llvm_unreachable("ELF doesn't support this directive");
611 }
612 
614  uint64_t Size, unsigned ByteAlignment) {
615  llvm_unreachable("ELF doesn't support this directive");
616 }
617 
619  uint64_t Size, unsigned ByteAlignment) {
620  llvm_unreachable("ELF doesn't support this directive");
621 }
void setExternal(bool Value)
Definition: MCAssembler.h:731
void setFlags(uint32_t Value)
setFlags - Set the (implementation defined) symbol flags.
Definition: MCAssembler.h:773
const MCSymbol & getSymbol() const
Definition: MCExpr.h:283
virtual void InitToTextSection()
InitToTextSection - Create a text section and switch the streamer to it.
bool isBundleLocked() const
Definition: MCAssembler.h:643
.type _foo, STT_OBJECT # aka
Definition: MCDirectives.h:25
static const MCConstantExpr * Create(int64_t Value, MCContext &Ctx)
Definition: MCExpr.cpp:152
void setBundleLockState(BundleLockStateType NewState)
Definition: MCAssembler.h:651
Not a valid directive.
Definition: MCDirectives.h:20
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size)
const MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags, SectionKind Kind)
Definition: MCContext.cpp:244
static SectionKind getDataRel()
Definition: SectionKind.h:229
unsigned getBundleAlignSize() const
Definition: MCAssembler.h:1023
ExprKind getKind() const
Definition: MCExpr.h:61
unsigned getFlags() const
Definition: MCSectionELF.h:68
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)
void EmitFrames(MCAsmBackend *MAB, bool usingCFI)
Definition: MCStreamer.cpp:587
MCCodeEmitter & getEmitter() const
Definition: MCAssembler.h:996
void PushSection()
Definition: MCStreamer.h:252
F(f)
virtual SmallVectorImpl< char > & getContents()
Definition: MCAssembler.h:221
void setBundleGroupBeforeFirstInst(bool IsFirst)
Definition: MCAssembler.h:659
virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol)
static void SetType(MCSymbolData &SD, unsigned Type)
Definition: MCELF.cpp:36
std::vector< IndirectSymbolData > & getIndirectSymbols()
Definition: MCAssembler.h:1069
.type _foo, STT_NOTYPE # aka
Definition: MCDirectives.h:28
virtual void ChangeSection(const MCSection *Section, const MCExpr *Subsection)
COFF::SymbolStorageClass StorageClass
Definition: COFFYAML.cpp:204
MCContext & getContext() const
Definition: MCAssembler.h:992
static unsigned CombineSymbolTypes(unsigned T1, unsigned T2)
virtual void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned)
const MCSymbol & getSymbol() const
Definition: MCAssembler.h:718
MCStreamer * createELFStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer, MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *CE, bool RelaxAll, bool NoExecStack)
static void SetVisibility(MCSymbolData &SD, unsigned Visibility)
Definition: MCELF.cpp:56
BundleLockStateType getBundleLockState() const
Definition: MCAssembler.h:647
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size)
MCFragment * getCurrentFragment() const
virtual void EmitCOFFSymbolStorageClass(int StorageClass)
SmallVectorImpl< MCFixup > & getFixups()
Definition: MCAssembler.h:224
static SectionKind getBSS()
Definition: SectionKind.h:225
void insert(MCFragment *F) const
const MCSection & getSection() const
Definition: MCSymbol.h:111
virtual void FinishImpl()
FinishImpl - Streamer specific finalization.
#define llvm_unreachable(msg)
void AssignSection(MCSymbol *Symbol, const MCSection *Section)
Definition: MCStreamer.cpp:201
void setRelaxAll(bool Value)
Definition: MCAssembler.h:1014
.local (ELF)
Definition: MCDirectives.h:35
virtual void ChangeSection(const MCSection *Section, const MCExpr *Subsection)
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol=0, uint64_t Size=0, unsigned ByteAlignment=0)
virtual void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit=0)
.no_dead_strip (MachO)
Definition: MCDirectives.h:36
static unsigned GetType(const MCSymbolData &SD)
Definition: MCELF.cpp:46
MCContext & getContext() const
Definition: MCStreamer.h:168
virtual void EmitAssemblerFlag(MCAssemblerFlag Flag)
EmitAssemblerFlag - Note in the output the specified Flag.
void setSubsectionsViaSymbols(bool Value)
Definition: MCAssembler.h:1009
void SwitchSection(const MCSection *Section, const MCExpr *Subsection=0)
Definition: MCStreamer.h:284
size_t array_lengthof(T(&)[N])
Find the length of an array.
Definition: STLExtras.h:250
.code16 (X86) / .code 16 (ARM)
Definition: MCDirectives.h:50
MCDataFragment * getOrCreateDataFragment() const
.type _foo, STT_GNU_IFUNC
Definition: MCDirectives.h:24
virtual void EncodeInstruction(const MCInst &Inst, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups) const =0
.protected (ELF)
Definition: MCDirectives.h:39
void setBundleAlignSize(unsigned Size)
Definition: MCAssembler.h:1027
.lazy_reference (MachO)
Definition: MCDirectives.h:34
virtual void EmitIntValue(uint64_t Value, unsigned Size)
Definition: MCStreamer.cpp:104
.reference (MachO)
Definition: MCDirectives.h:40
Unary expressions.
Definition: MCExpr.h:37
virtual void EmitIdent(StringRef IdentString)
static const MCSymbolRefExpr * Create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:270
static void SetBinding(MCSymbolData &SD, unsigned Binding)
Definition: MCELF.cpp:22
.hidden (ELF)
Definition: MCDirectives.h:31
const MCExpr * getLHS() const
getLHS - Get the left-hand side expression of the binary operator.
Definition: MCExpr.h:477
.weak_def_can_be_hidden (MachO)
Definition: MCDirectives.h:44
void setNoExecStack(bool Value)
Definition: MCAssembler.h:1017
virtual void InitSections()
InitSections - Create the default sections and set the initial one.
virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment=0)
MCAssembler & getAssembler()
uint32_t getFlags() const
getFlags - Get the (implementation defined) symbol flags.
Definition: MCAssembler.h:770
void setCommon(uint64_t Size, unsigned Align)
Definition: MCAssembler.h:743
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:22
virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value)
virtual void setHasInstructions(bool V)
Definition: MCAssembler.h:233
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol)
.subsections_via_symbols (MachO)
Definition: MCDirectives.h:49
virtual SmallVectorImpl< char > & getContents()
Definition: MCAssembler.h:271
.weak_reference (MachO)
Definition: MCDirectives.h:43
void append(in_iter in_start, in_iter in_end)
Definition: SmallVector.h:445
MCBinaryExpr - Binary assembler expressions.
Definition: MCExpr.h:356
virtual void EmitInstToFragment(const MCInst &Inst)
Emit an instruction to a special fragment, because this instruction can change its size during relaxa...
MCSymbolData & getOrCreateSymbolData(const MCSymbol &Symbol, bool *Created=0)
Definition: MCAssembler.h:1151
virtual void EmitBytes(StringRef Data)
virtual void EmitFileDirective(StringRef Filename)
MCSymbolData & getSymbolData(const MCSymbol &Symbol) const
Definition: MCAssembler.h:1145
virtual void EndCOFFSymbolDef()
EndCOFFSymbolDef - Marks the end of the symbol definition.
virtual void EmitCOFFSymbolType(int Type)
virtual void setAlignToBundleEnd(bool V)
Definition: MCAssembler.h:236
bool isBundlingEnabled() const
Definition: MCAssembler.h:1019
unsigned getAlignment() const
Definition: MCAssembler.h:607
.indirect_symbol (MachO)
Definition: MCDirectives.h:32
.type _foo, STT_TLS # aka
Definition: MCDirectives.h:26
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue)
virtual void EmitLabel(MCSymbol *Symbol)
virtual bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)
EmitSymbolAttribute - Add the given Attribute to Symbol.
void setVariableValue(const MCExpr *Value)
Definition: MCSymbol.cpp:54
MCSymbolAttr
Definition: MCDirectives.h:19
void addFileName(StringRef FileName)
Definition: MCAssembler.h:1170
virtual void EmitDebugLabel(MCSymbol *Symbol)
.syntax (ARM/ELF)
Definition: MCDirectives.h:48
virtual void EmitLabel(MCSymbol *Symbol)
.internal (ELF)
Definition: MCDirectives.h:33
void setSize(const MCExpr *SS)
Definition: MCAssembler.h:754
.code32 (X86) / .code 32 (ARM)
Definition: MCDirectives.h:51
const MCExpr * getRHS() const
getRHS - Get the right-hand side expression of the binary operator.
Definition: MCExpr.h:480
.type _foo, STT_COMMON # aka
Definition: MCDirectives.h:27
.code64 (X86)
Definition: MCDirectives.h:52
MCSectionData * SectionData
Definition: MCAssembler.h:794
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)
MCSectionData & getOrCreateSectionData(const MCSection &Section, bool *Created=0)
Definition: MCAssembler.h:1134
.symbol_resolver (MachO)
Definition: MCDirectives.h:37
static unsigned GetBinding(const MCSymbolData &SD)
Definition: MCELF.cpp:29
virtual MCSymbolData & getOrCreateSymbolData(MCSymbol *Symbol)
getOrCreateSymbolData - Get symbol data for given symbol.
virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)
.type _foo,
Definition: MCDirectives.h:30
virtual void FinishImpl()
FinishImpl - Streamer specific finalization.
MCAssemblerFlag
Definition: MCDirectives.h:47
.type _foo, STT_FUNC # aka
Definition: MCDirectives.h:23
void setFragment(MCFragment *Value)
Definition: MCAssembler.h:721
References to labels and assigned expressions.
Definition: MCExpr.h:36
void setAlignment(unsigned Value)
Definition: MCAssembler.h:608
.weak_definition (MachO)
Definition: MCDirectives.h:42
VariantKind getKind() const
Definition: MCExpr.h:285
.private_extern (MachO)
Definition: MCDirectives.h:38
LLVM Value Representation.
Definition: Value.h:66
MCAsmBackend - Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:34
Constant expressions.
Definition: MCExpr.h:35
virtual void Flush()
Flush - Causes any cached state to be written out.
Binary expressions.
Definition: MCExpr.h:34
cl::opt< bool > RelaxAll("mc-relax-all", cl::desc("When used with filetype=obj, ""relax all fixups in the emitted object file"))
MCSectionData * getCurrentSectionData() const
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
Definition: MCSymbol.h:100
virtual void EmitThumbFunc(MCSymbol *Func)
Target specific expression.
Definition: MCExpr.h:38
static SectionKind getReadOnly()
Definition: SectionKind.h:209
#define T1
SmallVectorImpl< MCFixup > & getFixups()
Definition: MCAssembler.h:308
bool isBundleGroupBeforeFirstInst() const
Definition: MCAssembler.h:655
static SectionKind getText()
Definition: SectionKind.h:208