Daniel Dunbar | 79e0e5a | 2010-03-19 10:43:15 +0000 | [diff] [blame] | 1 | //===- lib/MC/MCObjectWriter.cpp - MCObjectWriter implementation ----------===// |
Daniel Dunbar | f027abf | 2010-03-19 09:28:59 +0000 | [diff] [blame] | 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 | |
Rafael Espindola | 0f8abeb | 2010-12-24 21:22:02 +0000 | [diff] [blame] | 10 | #include "llvm/MC/MCAssembler.h" |
Rafael Espindola | b403e09 | 2010-12-18 06:27:54 +0000 | [diff] [blame] | 11 | #include "llvm/MC/MCExpr.h" |
Daniel Dunbar | f027abf | 2010-03-19 09:28:59 +0000 | [diff] [blame] | 12 | #include "llvm/MC/MCObjectWriter.h" |
Rafael Espindola | b403e09 | 2010-12-18 06:27:54 +0000 | [diff] [blame] | 13 | #include "llvm/MC/MCSymbol.h" |
Daniel Dunbar | f027abf | 2010-03-19 09:28:59 +0000 | [diff] [blame] | 14 | |
| 15 | using namespace llvm; |
| 16 | |
| 17 | MCObjectWriter::~MCObjectWriter() { |
| 18 | } |
Kevin Enderby | e46564a | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 19 | |
Rafael Espindola | 59f90b2 | 2015-03-25 19:24:39 +0000 | [diff] [blame] | 20 | bool MCObjectWriter::IsSymbolRefDifferenceFullyResolved( |
| 21 | const MCAssembler &Asm, const MCSymbolRefExpr *A, const MCSymbolRefExpr *B, |
| 22 | bool InSet) const { |
Rafael Espindola | b403e09 | 2010-12-18 06:27:54 +0000 | [diff] [blame] | 23 | // Modified symbol references cannot be resolved. |
| 24 | if (A->getKind() != MCSymbolRefExpr::VK_None || |
| 25 | B->getKind() != MCSymbolRefExpr::VK_None) |
| 26 | return false; |
| 27 | |
| 28 | const MCSymbol &SA = A->getSymbol(); |
| 29 | const MCSymbol &SB = B->getSymbol(); |
Rafael Espindola | 972756b | 2015-04-06 16:10:05 +0000 | [diff] [blame] | 30 | if (SA.isUndefined() || SB.isUndefined()) |
Rafael Espindola | b403e09 | 2010-12-18 06:27:54 +0000 | [diff] [blame] | 31 | return false; |
| 32 | |
Rafael Espindola | 0f8abeb | 2010-12-24 21:22:02 +0000 | [diff] [blame] | 33 | const MCSymbolData &DataA = Asm.getSymbolData(SA); |
| 34 | const MCSymbolData &DataB = Asm.getSymbolData(SB); |
Kevin Enderby | e1a12cf | 2012-01-31 23:02:57 +0000 | [diff] [blame] | 35 | if(!DataA.getFragment() || !DataB.getFragment()) |
| 36 | return false; |
Rafael Espindola | 0f8abeb | 2010-12-24 21:22:02 +0000 | [diff] [blame] | 37 | |
Rafael Espindola | 94a88d7 | 2015-04-06 15:27:57 +0000 | [diff] [blame] | 38 | return IsSymbolRefDifferenceFullyResolvedImpl( |
Rafael Espindola | 35d6189 | 2015-04-17 21:15:17 +0000 | [diff] [blame] | 39 | Asm, DataA, *DataB.getFragment(), InSet, false); |
Rafael Espindola | b403e09 | 2010-12-18 06:27:54 +0000 | [diff] [blame] | 40 | } |
Rafael Espindola | 490d02a | 2011-02-16 03:25:55 +0000 | [diff] [blame] | 41 | |
Rafael Espindola | 94a88d7 | 2015-04-06 15:27:57 +0000 | [diff] [blame] | 42 | bool MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( |
Rafael Espindola | 35d6189 | 2015-04-17 21:15:17 +0000 | [diff] [blame] | 43 | const MCAssembler &Asm, const MCSymbolData &DataA, const MCFragment &FB, |
| 44 | bool InSet, bool IsPCRel) const { |
Rafael Espindola | 972756b | 2015-04-06 16:10:05 +0000 | [diff] [blame] | 45 | const MCSection &SecA = DataA.getSymbol().getSection(); |
Rafael Espindola | 490d02a | 2011-02-16 03:25:55 +0000 | [diff] [blame] | 46 | const MCSection &SecB = FB.getParent()->getSection(); |
| 47 | // On ELF and COFF A - B is absolute if A and B are in the same section. |
| 48 | return &SecA == &SecB; |
| 49 | } |
Rafael Espindola | f275ad8 | 2015-03-25 13:16:53 +0000 | [diff] [blame] | 50 | |
| 51 | bool MCObjectWriter::isWeak(const MCSymbolData &SD) const { return false; } |