LLVM  4.0.0
MCObjectWriter.cpp
Go to the documentation of this file.
1 //===- lib/MC/MCObjectWriter.cpp - MCObjectWriter implementation ----------===//
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 #include "llvm/MC/MCAssembler.h"
11 #include "llvm/MC/MCExpr.h"
12 #include "llvm/MC/MCObjectWriter.h"
13 #include "llvm/MC/MCSymbol.h"
14 
15 using namespace llvm;
16 
18 }
19 
21  const MCAssembler &Asm, const MCSymbolRefExpr *A, const MCSymbolRefExpr *B,
22  bool InSet) const {
23  // Modified symbol references cannot be resolved.
24  if (A->getKind() != MCSymbolRefExpr::VK_None ||
26  return false;
27 
28  const MCSymbol &SA = A->getSymbol();
29  const MCSymbol &SB = B->getSymbol();
30  if (SA.isUndefined() || SB.isUndefined())
31  return false;
32 
33  if (!SA.getFragment() || !SB.getFragment())
34  return false;
35 
36  return isSymbolRefDifferenceFullyResolvedImpl(Asm, SA, SB, InSet);
37 }
38 
40  const MCAssembler &Asm, const MCSymbol &A, const MCSymbol &B,
41  bool InSet) const {
42  return isSymbolRefDifferenceFullyResolvedImpl(Asm, A, *B.getFragment(), InSet,
43  false);
44 }
45 
47  const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB,
48  bool InSet, bool IsPCRel) const {
49  const MCSection &SecA = SymA.getSection();
50  const MCSection &SecB = *FB.getParent();
51  // On ELF and COFF A - B is absolute if A and B are in the same section.
52  return &SecA == &SecB;
53 }
54 
55 bool MCObjectWriter::isWeak(const MCSymbol &) const { return false; }
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:40
virtual bool isWeak(const MCSymbol &Sym) const
True if this symbol (which is a variable) is weak.
const MCSymbol & getSymbol() const
Definition: MCExpr.h:311
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
bool isSymbolRefDifferenceFullyResolved(const MCAssembler &Asm, const MCSymbolRefExpr *A, const MCSymbolRefExpr *B, bool InSet) const
Check whether the difference (A - B) between two symbol references is fully resolved.
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:161
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
INITIALIZE_PASS(HexagonEarlyIfConversion,"hexagon-eif","Hexagon early if conversion", false, false) bool HexagonEarlyIfConversion MachineBasicBlock * SB
virtual bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbol &A, const MCSymbol &B, bool InSet) const
MCSection * getParent() const
Definition: MCFragment.h:97
MCSection & getSection(bool SetUsed=true) const
Get the section associated with a defined, non-absolute symbol.
Definition: MCSymbol.h:264
MCFragment * getFragment(bool SetUsed=true) const
Definition: MCSymbol.h:377
VariantKind getKind() const
Definition: MCExpr.h:313
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
Definition: MCSymbol.h:256