LLVM  5.0.0
X86MachObjectWriter.cpp
Go to the documentation of this file.
1 //===-- X86MachObjectWriter.cpp - X86 Mach-O Writer -----------------------===//
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 
12 #include "llvm/ADT/Twine.h"
14 #include "llvm/MC/MCAsmInfo.h"
15 #include "llvm/MC/MCAsmLayout.h"
16 #include "llvm/MC/MCAssembler.h"
17 #include "llvm/MC/MCContext.h"
19 #include "llvm/MC/MCSectionMachO.h"
20 #include "llvm/MC/MCValue.h"
22 #include "llvm/Support/Format.h"
23 
24 using namespace llvm;
25 
26 namespace {
27 class X86MachObjectWriter : public MCMachObjectTargetWriter {
28  bool recordScatteredRelocation(MachObjectWriter *Writer,
29  const MCAssembler &Asm,
30  const MCAsmLayout &Layout,
31  const MCFragment *Fragment,
32  const MCFixup &Fixup,
34  unsigned Log2Size,
35  uint64_t &FixedValue);
36  void recordTLVPRelocation(MachObjectWriter *Writer,
37  const MCAssembler &Asm,
38  const MCAsmLayout &Layout,
39  const MCFragment *Fragment,
40  const MCFixup &Fixup,
42  uint64_t &FixedValue);
43 
44  void RecordX86Relocation(MachObjectWriter *Writer,
45  const MCAssembler &Asm,
46  const MCAsmLayout &Layout,
47  const MCFragment *Fragment,
48  const MCFixup &Fixup,
50  uint64_t &FixedValue);
51  void RecordX86_64Relocation(MachObjectWriter *Writer, MCAssembler &Asm,
52  const MCAsmLayout &Layout,
53  const MCFragment *Fragment, const MCFixup &Fixup,
54  MCValue Target, uint64_t &FixedValue);
55 
56 public:
57  X86MachObjectWriter(bool Is64Bit, uint32_t CPUType, uint32_t CPUSubtype)
58  : MCMachObjectTargetWriter(Is64Bit, CPUType, CPUSubtype) {}
59 
60  void recordRelocation(MachObjectWriter *Writer, MCAssembler &Asm,
61  const MCAsmLayout &Layout, const MCFragment *Fragment,
62  const MCFixup &Fixup, MCValue Target,
63  uint64_t &FixedValue) override {
64  if (Writer->is64Bit())
65  RecordX86_64Relocation(Writer, Asm, Layout, Fragment, Fixup, Target,
66  FixedValue);
67  else
68  RecordX86Relocation(Writer, Asm, Layout, Fragment, Fixup, Target,
69  FixedValue);
70  }
71 };
72 }
73 
74 static bool isFixupKindRIPRel(unsigned Kind) {
75  return Kind == X86::reloc_riprel_4byte ||
79 }
80 
81 static unsigned getFixupKindLog2Size(unsigned Kind) {
82  switch (Kind) {
83  default:
84  llvm_unreachable("invalid fixup kind!");
85  case FK_PCRel_1:
86  case FK_Data_1: return 0;
87  case FK_PCRel_2:
88  case FK_Data_2: return 1;
89  case FK_PCRel_4:
90  // FIXME: Remove these!!!
97  case FK_Data_4: return 2;
98  case FK_Data_8: return 3;
99  }
100 }
101 
102 void X86MachObjectWriter::RecordX86_64Relocation(
103  MachObjectWriter *Writer, MCAssembler &Asm, const MCAsmLayout &Layout,
104  const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target,
105  uint64_t &FixedValue) {
106  unsigned IsPCRel = Writer->isFixupKindPCRel(Asm, Fixup.getKind());
107  unsigned IsRIPRel = isFixupKindRIPRel(Fixup.getKind());
108  unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind());
109 
110  // See <reloc.h>.
111  uint32_t FixupOffset =
112  Layout.getFragmentOffset(Fragment) + Fixup.getOffset();
113  uint32_t FixupAddress =
114  Writer->getFragmentAddress(Fragment, Layout) + Fixup.getOffset();
115  int64_t Value = 0;
116  unsigned Index = 0;
117  unsigned IsExtern = 0;
118  unsigned Type = 0;
119  const MCSymbol *RelSymbol = nullptr;
120 
121  Value = Target.getConstant();
122 
123  if (IsPCRel) {
124  // Compensate for the relocation offset, Darwin x86_64 relocations only have
125  // the addend and appear to have attempted to define it to be the actual
126  // expression addend without the PCrel bias. However, instructions with data
127  // following the relocation are not accommodated for (see comment below
128  // regarding SIGNED{1,2,4}), so it isn't exactly that either.
129  Value += 1LL << Log2Size;
130  }
131 
132  if (Target.isAbsolute()) { // constant
133  // SymbolNum of 0 indicates the absolute section.
135 
136  // FIXME: I believe this is broken, I don't think the linker can understand
137  // it. I think it would require a local relocation, but I'm not sure if that
138  // would work either. The official way to get an absolute PCrel relocation
139  // is to use an absolute symbol (which we don't support yet).
140  if (IsPCRel) {
141  IsExtern = 1;
143  }
144  } else if (Target.getSymB()) { // A - B + constant
145  const MCSymbol *A = &Target.getSymA()->getSymbol();
146  if (A->isTemporary())
147  A = &Writer->findAliasedSymbol(*A);
148  const MCSymbol *A_Base = Asm.getAtom(*A);
149 
150  const MCSymbol *B = &Target.getSymB()->getSymbol();
151  if (B->isTemporary())
152  B = &Writer->findAliasedSymbol(*B);
153  const MCSymbol *B_Base = Asm.getAtom(*B);
154 
155  // Neither symbol can be modified.
156  if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None) {
157  Asm.getContext().reportError(Fixup.getLoc(),
158  "unsupported relocation of modified symbol");
159  return;
160  }
161 
162  // We don't support PCrel relocations of differences. Darwin 'as' doesn't
163  // implement most of these correctly.
164  if (IsPCRel) {
165  Asm.getContext().reportError(
166  Fixup.getLoc(), "unsupported pc-relative relocation of difference");
167  return;
168  }
169 
170  // The support for the situation where one or both of the symbols would
171  // require a local relocation is handled just like if the symbols were
172  // external. This is certainly used in the case of debug sections where the
173  // section has only temporary symbols and thus the symbols don't have base
174  // symbols. This is encoded using the section ordinal and non-extern
175  // relocation entries.
176 
177  // Darwin 'as' doesn't emit correct relocations for this (it ends up with a
178  // single SIGNED relocation); reject it for now. Except the case where both
179  // symbols don't have a base, equal but both NULL.
180  if (A_Base == B_Base && A_Base) {
181  Asm.getContext().reportError(
182  Fixup.getLoc(), "unsupported relocation with identical base");
183  return;
184  }
185 
186  // A subtraction expression where either symbol is undefined is a
187  // non-relocatable expression.
188  if (A->isUndefined() || B->isUndefined()) {
189  StringRef Name = A->isUndefined() ? A->getName() : B->getName();
190  Asm.getContext().reportError(Fixup.getLoc(),
191  "unsupported relocation with subtraction expression, symbol '" +
192  Name + "' can not be undefined in a subtraction expression");
193  return;
194  }
195 
196  Value += Writer->getSymbolAddress(*A, Layout) -
197  (!A_Base ? 0 : Writer->getSymbolAddress(*A_Base, Layout));
198  Value -= Writer->getSymbolAddress(*B, Layout) -
199  (!B_Base ? 0 : Writer->getSymbolAddress(*B_Base, Layout));
200 
201  if (!A_Base)
202  Index = A->getFragment()->getParent()->getOrdinal() + 1;
204 
206  MRE.r_word0 = FixupOffset;
207  MRE.r_word1 =
208  (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
209  Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
210 
211  if (B_Base)
212  RelSymbol = B_Base;
213  else
214  Index = B->getFragment()->getParent()->getOrdinal() + 1;
216  } else {
217  const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
218  if (Symbol->isTemporary() && Value) {
219  const MCSection &Sec = Symbol->getSection();
221  Symbol->setUsedInReloc();
222  }
223  RelSymbol = Asm.getAtom(*Symbol);
224 
225  // Relocations inside debug sections always use local relocations when
226  // possible. This seems to be done because the debugger doesn't fully
227  // understand x86_64 relocation entries, and expects to find values that
228  // have already been fixed up.
229  if (Symbol->isInSection()) {
230  const MCSectionMachO &Section =
231  static_cast<const MCSectionMachO &>(*Fragment->getParent());
232  if (Section.hasAttribute(MachO::S_ATTR_DEBUG))
233  RelSymbol = nullptr;
234  }
235 
236  // x86_64 almost always uses external relocations, except when there is no
237  // symbol to use as a base address (a local symbol with no preceding
238  // non-local symbol).
239  if (RelSymbol) {
240  // Add the local offset, if needed.
241  if (RelSymbol != Symbol)
242  Value += Layout.getSymbolOffset(*Symbol) -
243  Layout.getSymbolOffset(*RelSymbol);
244  } else if (Symbol->isInSection() && !Symbol->isVariable()) {
245  // The index is the section ordinal (1-based).
246  Index = Symbol->getFragment()->getParent()->getOrdinal() + 1;
247  Value += Writer->getSymbolAddress(*Symbol, Layout);
248 
249  if (IsPCRel)
250  Value -= FixupAddress + (1 << Log2Size);
251  } else if (Symbol->isVariable()) {
252  const MCExpr *Value = Symbol->getVariableValue();
253  int64_t Res;
254  bool isAbs = Value->evaluateAsAbsolute(Res, Layout,
255  Writer->getSectionAddressMap());
256  if (isAbs) {
257  FixedValue = Res;
258  return;
259  } else {
260  Asm.getContext().reportError(Fixup.getLoc(),
261  "unsupported relocation of variable '" +
262  Symbol->getName() + "'");
263  return;
264  }
265  } else {
266  Asm.getContext().reportError(
267  Fixup.getLoc(), "unsupported relocation of undefined symbol '" +
268  Symbol->getName() + "'");
269  return;
270  }
271 
272  MCSymbolRefExpr::VariantKind Modifier = Target.getSymA()->getKind();
273  if (IsPCRel) {
274  if (IsRIPRel) {
275  if (Modifier == MCSymbolRefExpr::VK_GOTPCREL) {
276  // x86_64 distinguishes movq foo@GOTPCREL so that the linker can
277  // rewrite the movq to an leaq at link time if the symbol ends up in
278  // the same linkage unit.
279  if (unsigned(Fixup.getKind()) == X86::reloc_riprel_4byte_movq_load)
281  else
283  } else if (Modifier == MCSymbolRefExpr::VK_TLVP) {
285  } else if (Modifier != MCSymbolRefExpr::VK_None) {
286  Asm.getContext().reportError(
287  Fixup.getLoc(), "unsupported symbol modifier in relocation");
288  return;
289  } else {
291 
292  // The Darwin x86_64 relocation format has a problem where it cannot
293  // encode an address (L<foo> + <constant>) which is outside the atom
294  // containing L<foo>. Generally, this shouldn't occur but it does
295  // happen when we have a RIPrel instruction with data following the
296  // relocation entry (e.g., movb $012, L0(%rip)). Even with the PCrel
297  // adjustment Darwin x86_64 uses, the offset is still negative and the
298  // linker has no way to recognize this.
299  //
300  // To work around this, Darwin uses several special relocation types
301  // to indicate the offsets. However, the specification or
302  // implementation of these seems to also be incomplete; they should
303  // adjust the addend as well based on the actual encoded instruction
304  // (the additional bias), but instead appear to just look at the final
305  // offset.
306  switch (-(Target.getConstant() + (1LL << Log2Size))) {
307  case 1: Type = MachO::X86_64_RELOC_SIGNED_1; break;
308  case 2: Type = MachO::X86_64_RELOC_SIGNED_2; break;
309  case 4: Type = MachO::X86_64_RELOC_SIGNED_4; break;
310  }
311  }
312  } else {
313  if (Modifier != MCSymbolRefExpr::VK_None) {
314  Asm.getContext().reportError(
315  Fixup.getLoc(),
316  "unsupported symbol modifier in branch relocation");
317  return;
318  }
319 
321  }
322  } else {
323  if (Modifier == MCSymbolRefExpr::VK_GOT) {
325  } else if (Modifier == MCSymbolRefExpr::VK_GOTPCREL) {
326  // GOTPCREL is allowed as a modifier on non-PCrel instructions, in which
327  // case all we do is set the PCrel bit in the relocation entry; this is
328  // used with exception handling, for example. The source is required to
329  // include any necessary offset directly.
331  IsPCRel = 1;
332  } else if (Modifier == MCSymbolRefExpr::VK_TLVP) {
333  Asm.getContext().reportError(
334  Fixup.getLoc(), "TLVP symbol modifier should have been rip-rel");
335  return;
336  } else if (Modifier != MCSymbolRefExpr::VK_None) {
337  Asm.getContext().reportError(
338  Fixup.getLoc(), "unsupported symbol modifier in relocation");
339  return;
340  } else {
342  unsigned Kind = Fixup.getKind();
343  if (Kind == X86::reloc_signed_4byte) {
344  Asm.getContext().reportError(
345  Fixup.getLoc(),
346  "32-bit absolute addressing is not supported in 64-bit mode");
347  return;
348  }
349  }
350  }
351  }
352 
353  // x86_64 always writes custom values into the fixups.
354  FixedValue = Value;
355 
356  // struct relocation_info (8 bytes)
358  MRE.r_word0 = FixupOffset;
359  MRE.r_word1 = (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) |
360  (IsExtern << 27) | (Type << 28);
361  Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
362 }
363 
364 bool X86MachObjectWriter::recordScatteredRelocation(MachObjectWriter *Writer,
365  const MCAssembler &Asm,
366  const MCAsmLayout &Layout,
367  const MCFragment *Fragment,
368  const MCFixup &Fixup,
369  MCValue Target,
370  unsigned Log2Size,
371  uint64_t &FixedValue) {
372  uint64_t OriginalFixedValue = FixedValue;
373  uint32_t FixupOffset = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
374  unsigned IsPCRel = Writer->isFixupKindPCRel(Asm, Fixup.getKind());
375  unsigned Type = MachO::GENERIC_RELOC_VANILLA;
376 
377  // See <reloc.h>.
378  const MCSymbol *A = &Target.getSymA()->getSymbol();
379 
380  if (!A->getFragment()) {
381  Asm.getContext().reportError(
382  Fixup.getLoc(),
383  "symbol '" + A->getName() +
384  "' can not be undefined in a subtraction expression");
385  return false;
386  }
387 
388  uint32_t Value = Writer->getSymbolAddress(*A, Layout);
389  uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
390  FixedValue += SecAddr;
391  uint32_t Value2 = 0;
392 
393  if (const MCSymbolRefExpr *B = Target.getSymB()) {
394  const MCSymbol *SB = &B->getSymbol();
395 
396  if (!SB->getFragment()) {
397  Asm.getContext().reportError(
398  Fixup.getLoc(),
399  "symbol '" + SB->getName() +
400  "' can not be undefined in a subtraction expression");
401  return false;
402  }
403 
404  // Select the appropriate difference relocation type.
405  //
406  // Note that there is no longer any semantic difference between these two
407  // relocation types from the linkers point of view, this is done solely for
408  // pedantic compatibility with 'as'.
411  Value2 = Writer->getSymbolAddress(*SB, Layout);
412  FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
413  }
414 
415  // Relocations are written out in reverse order, so the PAIR comes first.
416  if (Type == MachO::GENERIC_RELOC_SECTDIFF ||
418  // If the offset is too large to fit in a scattered relocation,
419  // we're hosed. It's an unfortunate limitation of the MachO format.
420  if (FixupOffset > 0xffffff) {
421  char Buffer[32];
422  format("0x%x", FixupOffset).print(Buffer, sizeof(Buffer));
423  Asm.getContext().reportError(Fixup.getLoc(),
424  Twine("Section too large, can't encode "
425  "r_address (") + Buffer +
426  ") into 24 bits of scattered "
427  "relocation entry.");
428  return false;
429  }
430 
432  MRE.r_word0 = ((0 << 0) | // r_address
433  (MachO::GENERIC_RELOC_PAIR << 24) | // r_type
434  (Log2Size << 28) |
435  (IsPCRel << 30) |
437  MRE.r_word1 = Value2;
438  Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
439  } else {
440  // If the offset is more than 24-bits, it won't fit in a scattered
441  // relocation offset field, so we fall back to using a non-scattered
442  // relocation. This is a bit risky, as if the offset reaches out of
443  // the block and the linker is doing scattered loading on this
444  // symbol, things can go badly.
445  //
446  // Required for 'as' compatibility.
447  if (FixupOffset > 0xffffff) {
448  FixedValue = OriginalFixedValue;
449  return false;
450  }
451  }
452 
454  MRE.r_word0 = ((FixupOffset << 0) |
455  (Type << 24) |
456  (Log2Size << 28) |
457  (IsPCRel << 30) |
459  MRE.r_word1 = Value;
460  Writer->addRelocation(nullptr, Fragment->getParent(), MRE);
461  return true;
462 }
463 
464 void X86MachObjectWriter::recordTLVPRelocation(MachObjectWriter *Writer,
465  const MCAssembler &Asm,
466  const MCAsmLayout &Layout,
467  const MCFragment *Fragment,
468  const MCFixup &Fixup,
469  MCValue Target,
470  uint64_t &FixedValue) {
471  const MCSymbolRefExpr *SymA = Target.getSymA();
472  assert(SymA->getKind() == MCSymbolRefExpr::VK_TLVP && !is64Bit() &&
473  "Should only be called with a 32-bit TLVP relocation!");
474 
475  unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind());
476  uint32_t Value = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
477  unsigned IsPCRel = 0;
478 
479  // We're only going to have a second symbol in pic mode and it'll be a
480  // subtraction from the picbase. For 32-bit pic the addend is the difference
481  // between the picbase and the next address. For 32-bit static the addend is
482  // zero.
483  if (auto *SymB = Target.getSymB()) {
484  // If this is a subtraction then we're pcrel.
485  uint32_t FixupAddress =
486  Writer->getFragmentAddress(Fragment, Layout) + Fixup.getOffset();
487  IsPCRel = 1;
488  FixedValue = FixupAddress -
489  Writer->getSymbolAddress(SymB->getSymbol(), Layout) +
490  Target.getConstant();
491  FixedValue += 1ULL << Log2Size;
492  } else {
493  FixedValue = 0;
494  }
495 
496  // struct relocation_info (8 bytes)
498  MRE.r_word0 = Value;
499  MRE.r_word1 =
500  (IsPCRel << 24) | (Log2Size << 25) | (MachO::GENERIC_RELOC_TLV << 28);
501  Writer->addRelocation(&SymA->getSymbol(), Fragment->getParent(), MRE);
502 }
503 
504 void X86MachObjectWriter::RecordX86Relocation(MachObjectWriter *Writer,
505  const MCAssembler &Asm,
506  const MCAsmLayout &Layout,
507  const MCFragment *Fragment,
508  const MCFixup &Fixup,
509  MCValue Target,
510  uint64_t &FixedValue) {
511  unsigned IsPCRel = Writer->isFixupKindPCRel(Asm, Fixup.getKind());
512  unsigned Log2Size = getFixupKindLog2Size(Fixup.getKind());
513 
514  // If this is a 32-bit TLVP reloc it's handled a bit differently.
515  if (Target.getSymA() &&
516  Target.getSymA()->getKind() == MCSymbolRefExpr::VK_TLVP) {
517  recordTLVPRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
518  FixedValue);
519  return;
520  }
521 
522  // If this is a difference or a defined symbol plus an offset, then we need a
523  // scattered relocation entry. Differences always require scattered
524  // relocations.
525  if (Target.getSymB()) {
526  recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup,
527  Target, Log2Size, FixedValue);
528  return;
529  }
530 
531  // Get the symbol data, if any.
532  const MCSymbol *A = nullptr;
533  if (Target.getSymA())
534  A = &Target.getSymA()->getSymbol();
535 
536  // If this is an internal relocation with an offset, it also needs a scattered
537  // relocation entry.
538  uint32_t Offset = Target.getConstant();
539  if (IsPCRel)
540  Offset += 1 << Log2Size;
541  // Try to record the scattered relocation if needed. Fall back to non
542  // scattered if necessary (see comments in recordScatteredRelocation()
543  // for details).
544  if (Offset && A && !Writer->doesSymbolRequireExternRelocation(*A) &&
545  recordScatteredRelocation(Writer, Asm, Layout, Fragment, Fixup, Target,
546  Log2Size, FixedValue))
547  return;
548 
549  // See <reloc.h>.
550  uint32_t FixupOffset = Layout.getFragmentOffset(Fragment)+Fixup.getOffset();
551  unsigned Index = 0;
552  unsigned Type = 0;
553  const MCSymbol *RelSymbol = nullptr;
554 
555  if (Target.isAbsolute()) { // constant
556  // SymbolNum of 0 indicates the absolute section.
557  //
558  // FIXME: Currently, these are never generated (see code below). I cannot
559  // find a case where they are actually emitted.
561  } else {
562  // Resolve constant variables.
563  if (A->isVariable()) {
564  int64_t Res;
565  if (A->getVariableValue()->evaluateAsAbsolute(
566  Res, Layout, Writer->getSectionAddressMap())) {
567  FixedValue = Res;
568  return;
569  }
570  }
571 
572  // Check whether we need an external or internal relocation.
573  if (Writer->doesSymbolRequireExternRelocation(*A)) {
574  RelSymbol = A;
575  // For external relocations, make sure to offset the fixup value to
576  // compensate for the addend of the symbol address, if it was
577  // undefined. This occurs with weak definitions, for example.
578  if (!A->isUndefined())
579  FixedValue -= Layout.getSymbolOffset(*A);
580  } else {
581  // The index is the section ordinal (1-based).
582  const MCSection &Sec = A->getSection();
583  Index = Sec.getOrdinal() + 1;
584  FixedValue += Writer->getSectionAddress(&Sec);
585  }
586  if (IsPCRel)
587  FixedValue -= Writer->getSectionAddress(Fragment->getParent());
588 
590  }
591 
592  // struct relocation_info (8 bytes)
594  MRE.r_word0 = FixupOffset;
595  MRE.r_word1 =
596  (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
597  Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
598 }
599 
601  bool Is64Bit, uint32_t CPUType,
602  uint32_t CPUSubtype) {
603  return createMachObjectWriter(new X86MachObjectWriter(Is64Bit,
604  CPUType,
605  CPUSubtype),
606  OS, /*IsLittleEndian=*/true);
607 }
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:283
This represents a section on a Mach-O system (used by Mac OS X).
const MCSymbol & getSymbol() const
Definition: MCExpr.h:318
SMLoc getLoc() const
Definition: MCFixup.h:112
bool doesSymbolRequireExternRelocation(const MCSymbol &S)
This represents an "assembler immediate".
Definition: MCValue.h:40
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
uint64_t getSectionAddress(const MCSection *Sec) const
bool getSymbolOffset(const MCSymbol &S, uint64_t &Val) const
Get the offset of the given symbol, as computed in the current layout.
Definition: MCFragment.cpp:129
virtual bool isSectionAtomizableBySymbols(const MCSection &Section) const
True if the section is atomized using the symbols in it.
Definition: MCAsmInfo.cpp:63
static bool isFixupKindRIPRel(unsigned Kind)
bool isExternal() const
Definition: MCSymbol.h:392
MCContext & getContext() const
Definition: MCAssembler.h:257
Defines the object file and target independent interfaces used by the assembler backend to write nati...
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:66
A one-byte pc relative fixup.
Definition: MCFixup.h:28
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
Encapsulates the layout of an assembly file at a particular point in time.
Definition: MCAsmLayout.h:29
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:165
A four-byte fixup.
Definition: MCFixup.h:26
bool isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind)
void addRelocation(const MCSymbol *RelSymbol, const MCSection *Sec, MachO::any_relocation_info &MRE)
bool isAbsolute() const
Is this an absolute (as opposed to relocatable) value.
Definition: MCValue.h:52
const MCSymbol * getAtom(const MCSymbol &S) const
Find the symbol which defines the atom containing the given symbol, or null if there is no such symbo...
uint32_t getOffset() const
Definition: MCFixup.h:95
SectionAddrMap & getSectionAddressMap()
const char * Name
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:124
INITIALIZE_PASS(HexagonEarlyIfConversion,"hexagon-eif","Hexagon early if conversion", false, false) bool HexagonEarlyIfConversion MachineBasicBlock * SB
MCObjectWriter * createX86MachObjectWriter(raw_pwrite_stream &OS, bool Is64Bit, uint32_t CPUType, uint32_t CPUSubtype)
Construct an X86 Mach-O object writer.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
static bool is64Bit(const char *name)
bool hasAttribute(unsigned Value) const
void setUsedInReloc() const
Definition: MCSymbol.h:213
#define A
Definition: LargeTest.cpp:12
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:608
unsigned getOrdinal() const
Definition: MCSection.h:120
bool isInSection(bool SetUsed=true) const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
Definition: MCSymbol.h:255
MCFixupKind getKind() const
Definition: MCFixup.h:93
const MCSymbolRefExpr * getSymB() const
Definition: MCValue.h:48
A one-byte fixup.
Definition: MCFixup.h:24
S_ATTR_DEBUG - A debug section.
Definition: MachO.h:197
static unsigned getFixupKindLog2Size(unsigned Kind)
A two-byte pc relative fixup.
Definition: MCFixup.h:29
#define B
Definition: LargeTest.cpp:24
const MCSymbolRefExpr * getSymA() const
Definition: MCValue.h:47
A four-byte pc relative fixup.
Definition: MCFixup.h:30
uint64_t getFragmentAddress(const MCFragment *Fragment, const MCAsmLayout &Layout) const
MCSection * getParent() const
Definition: MCFragment.h:102
Target - Wrapper for Target specific information.
const MCExpr * getVariableValue(bool SetUsed=true) const
getVariableValue - Get the value for variable symbols.
Definition: MCSymbol.h:300
MCObjectWriter * createMachObjectWriter(MCMachObjectTargetWriter *MOTW, raw_pwrite_stream &OS, bool IsLittleEndian)
Construct a new Mach-O writer instance.
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
Definition: MCSymbol.h:220
MCSection & getSection(bool SetUsed=true) const
Get the section associated with a defined, non-absolute symbol.
Definition: MCSymbol.h:268
llvm_unreachable("Unknown RegBank!")
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:203
A eight-byte fixup.
Definition: MCFixup.h:27
uint64_t getFragmentOffset(const MCFragment *F) const
Get the offset of the given fragment inside its containing section.
Definition: MCFragment.cpp:77
bool isVariable() const
isVariable - Check if this is a variable symbol.
Definition: MCSymbol.h:295
MCFragment * getFragment(bool SetUsed=true) const
Definition: MCSymbol.h:383
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:333
const unsigned Kind
VariantKind getKind() const
Definition: MCExpr.h:320
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
int64_t getConstant() const
Definition: MCValue.h:46
LLVM Value Representation.
Definition: Value.h:73
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
uint64_t getSymbolAddress(const MCSymbol &S, const MCAsmLayout &Layout) const
A two-byte fixup.
Definition: MCFixup.h:25
const MCSymbol & findAliasedSymbol(const MCSymbol &Sym) const
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
Definition: MCSymbol.h:260