From 9e6378de5744088759f92a7503c7ca81d815c05d Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sat, 16 May 2015 01:01:55 +0000 Subject: [PATCH] MC: Use MCSymbol in MCObject::IsSymbolRefDifferenceFullyResolvedImpl() Transition one API from `MCSymbolData` to `MCSymbol`. The function needs both, and the backpointer from `MCSymbolData` to `MCSymbol` is going away. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237498 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCMachObjectWriter.h | 5 ++--- include/llvm/MC/MCObjectWriter.h | 2 +- lib/MC/ELFObjectWriter.cpp | 17 ++++++++--------- lib/MC/MCAssembler.cpp | 3 +-- lib/MC/MCObjectWriter.cpp | 8 ++++---- lib/MC/MachObjectWriter.cpp | 4 ++-- lib/MC/WinCOFFObjectWriter.cpp | 9 +++++---- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/include/llvm/MC/MCMachObjectWriter.h b/include/llvm/MC/MCMachObjectWriter.h index b90ac0ac535..0a41ed9f0fd 100644 --- a/include/llvm/MC/MCMachObjectWriter.h +++ b/include/llvm/MC/MCMachObjectWriter.h @@ -263,9 +263,8 @@ public: const MCAsmLayout &Layout) override; bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, - const MCSymbolData &DataA, - const MCFragment &FB, - bool InSet, + const MCSymbol &SymA, + const MCFragment &FB, bool InSet, bool IsPCRel) const override; void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout) override; diff --git a/include/llvm/MC/MCObjectWriter.h b/include/llvm/MC/MCObjectWriter.h index eaf683a3bd4..6113208865a 100644 --- a/include/llvm/MC/MCObjectWriter.h +++ b/include/llvm/MC/MCObjectWriter.h @@ -93,7 +93,7 @@ public: bool InSet) const; virtual bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, - const MCSymbolData &DataA, + const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const; diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 892f1526de8..670e06e22c8 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -244,12 +244,11 @@ class ELFObjectWriter : public MCObjectWriter { void writeRelocations(const MCAssembler &Asm, const MCSectionELF &Sec); - bool - IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, - const MCSymbolData &DataA, - const MCFragment &FB, - bool InSet, - bool IsPCRel) const override; + bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, + const MCSymbol &SymA, + const MCFragment &FB, + bool InSet, + bool IsPCRel) const override; bool isWeak(const MCSymbolData &SD) const override; @@ -1469,14 +1468,14 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm, } bool ELFObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( - const MCAssembler &Asm, const MCSymbolData &DataA, const MCFragment &FB, + const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const { if (IsPCRel) { assert(!InSet); - if (::isWeak(DataA)) + if (::isWeak(SymA.getData())) return false; } - return MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(Asm, DataA, FB, + return MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(Asm, SymA, FB, InSet, IsPCRel); } diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 197b9221b3f..d8d89e3973b 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -506,9 +506,8 @@ bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout, if (A->getKind() != MCSymbolRefExpr::VK_None || SA.isUndefined()) { IsResolved = false; } else { - const MCSymbolData &DataA = getSymbolData(SA); IsResolved = getWriter().IsSymbolRefDifferenceFullyResolvedImpl( - *this, DataA, *DF, false, true); + *this, SA, *DF, false, true); } } } else { diff --git a/lib/MC/MCObjectWriter.cpp b/lib/MC/MCObjectWriter.cpp index e90dea81479..6402a2fed94 100644 --- a/lib/MC/MCObjectWriter.cpp +++ b/lib/MC/MCObjectWriter.cpp @@ -35,14 +35,14 @@ bool MCObjectWriter::IsSymbolRefDifferenceFullyResolved( if(!DataA.getFragment() || !DataB.getFragment()) return false; - return IsSymbolRefDifferenceFullyResolvedImpl( - Asm, DataA, *DataB.getFragment(), InSet, false); + return IsSymbolRefDifferenceFullyResolvedImpl(Asm, SA, *DataB.getFragment(), + InSet, false); } bool MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( - const MCAssembler &Asm, const MCSymbolData &DataA, const MCFragment &FB, + const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const { - const MCSection &SecA = DataA.getSymbol().getSection(); + const MCSection &SecA = SymA.getSection(); const MCSection &SecB = FB.getParent()->getSection(); // On ELF and COFF A - B is absolute if A and B are in the same section. return &SecA == &SecB; diff --git a/lib/MC/MachObjectWriter.cpp b/lib/MC/MachObjectWriter.cpp index 109e908988f..5866d8476cb 100644 --- a/lib/MC/MachObjectWriter.cpp +++ b/lib/MC/MachObjectWriter.cpp @@ -669,7 +669,7 @@ void MachObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm, } bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( - const MCAssembler &Asm, const MCSymbolData &DataA, const MCFragment &FB, + const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const { if (InSet) return true; @@ -679,7 +679,7 @@ bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( // - addr(atom(B)) - offset(B) // and the offsets are not relocatable, so the fixup is fully resolved when // addr(atom(A)) - addr(atom(B)) == 0. - const MCSymbol &SA = findAliasedSymbol(DataA.getSymbol()); + const MCSymbol &SA = findAliasedSymbol(SymA); const MCSection &SecA = SA.getSection(); const MCSection &SecB = FB.getParent()->getSection(); diff --git a/lib/MC/WinCOFFObjectWriter.cpp b/lib/MC/WinCOFFObjectWriter.cpp index 261534ed668..cfeb672b9f2 100644 --- a/lib/MC/WinCOFFObjectWriter.cpp +++ b/lib/MC/WinCOFFObjectWriter.cpp @@ -171,7 +171,7 @@ public: const MCAsmLayout &Layout) override; bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, - const MCSymbolData &DataA, + const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const override; @@ -648,15 +648,16 @@ void WinCOFFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm, } bool WinCOFFObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( - const MCAssembler &Asm, const MCSymbolData &DataA, const MCFragment &FB, + const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB, bool InSet, bool IsPCRel) const { // MS LINK expects to be able to replace all references to a function with a // thunk to implement their /INCREMENTAL feature. Make sure we don't optimize // away any relocations to functions. - if ((((DataA.getFlags() & COFF::SF_TypeMask) >> COFF::SF_TypeShift) >> + if ((((SymA.getData().getFlags() & COFF::SF_TypeMask) >> + COFF::SF_TypeShift) >> COFF::SCT_COMPLEX_TYPE_SHIFT) == COFF::IMAGE_SYM_DTYPE_FUNCTION) return false; - return MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(Asm, DataA, FB, + return MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(Asm, SymA, FB, InSet, IsPCRel); } -- 2.34.1