MCObjectWriter.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #include "llvm/MC/MCAssembler.h"
  10. #include "llvm/MC/MCExpr.h"
  11. #include "llvm/MC/MCObjectWriter.h"
  12. #include "llvm/MC/MCSymbol.h"
  13. using namespace llvm;
  14. MCObjectWriter::~MCObjectWriter() {
  15. }
  16. bool MCObjectWriter::isSymbolRefDifferenceFullyResolved(
  17. const MCAssembler &Asm, const MCSymbolRefExpr *A, const MCSymbolRefExpr *B,
  18. bool InSet) const {
  19. // Modified symbol references cannot be resolved.
  20. if (A->getKind() != MCSymbolRefExpr::VK_None ||
  21. B->getKind() != MCSymbolRefExpr::VK_None)
  22. return false;
  23. const MCSymbol &SA = A->getSymbol();
  24. const MCSymbol &SB = B->getSymbol();
  25. if (SA.isUndefined() || SB.isUndefined())
  26. return false;
  27. if (!SA.getFragment() || !SB.getFragment())
  28. return false;
  29. return isSymbolRefDifferenceFullyResolvedImpl(Asm, SA, *SB.getFragment(),
  30. InSet, false);
  31. }
  32. bool MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
  33. const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB,
  34. bool InSet, bool IsPCRel) const {
  35. const MCSection &SecA = SymA.getSection();
  36. const MCSection &SecB = *FB.getParent();
  37. // On ELF and COFF A - B is absolute if A and B are in the same section.
  38. return &SecA == &SecB;
  39. }
  40. bool MCObjectWriter::isWeak(const MCSymbol &) const { return false; }