LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
20 bool
22  const MCSymbolRefExpr *A,
23  const MCSymbolRefExpr *B,
24  bool InSet) const {
25  // Modified symbol references cannot be resolved.
26  if (A->getKind() != MCSymbolRefExpr::VK_None ||
28  return false;
29 
30  const MCSymbol &SA = A->getSymbol();
31  const MCSymbol &SB = B->getSymbol();
33  return false;
34 
35  const MCSymbolData &DataA = Asm.getSymbolData(SA);
36  const MCSymbolData &DataB = Asm.getSymbolData(SB);
37  if(!DataA.getFragment() || !DataB.getFragment())
38  return false;
39 
41  *DataB.getFragment(),
42  InSet,
43  false);
44 }
45 
46 bool
48  const MCSymbolData &DataA,
49  const MCFragment &FB,
50  bool InSet,
51  bool IsPCRel) const {
52  const MCSection &SecA = DataA.getSymbol().AliasedSymbol().getSection();
53  const MCSection &SecB = FB.getParent()->getSection();
54  // On ELF and COFF A - B is absolute if A and B are in the same section.
55  return &SecA == &SecB;
56 }
const MCSymbol & getSymbol() const
Definition: MCExpr.h:283
const MCSymbol & getSymbol() const
Definition: MCAssembler.h:718
const MCSection & getSection() const
Definition: MCSymbol.h:111
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.
virtual bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbolData &DataA, const MCFragment &FB, bool InSet, bool IsPCRel) const
MCFragment * getFragment() const
Definition: MCAssembler.h:720
const MCSection & getSection() const
Definition: MCAssembler.h:605
MCSectionData * getParent() const
Definition: MCAssembler.h:95
MCSymbolData & getSymbolData(const MCSymbol &Symbol) const
Definition: MCAssembler.h:1145
const MCSymbol & AliasedSymbol() const
Definition: MCSymbol.cpp:42
VariantKind getKind() const
Definition: MCExpr.h:285
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
Definition: MCSymbol.h:100