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.

llvm-svn: 237498
This commit is contained in:
Duncan P. N. Exon Smith 2015-05-16 01:01:55 +00:00
parent 09bfa58edd
commit d81ba532ed
7 changed files with 23 additions and 25 deletions

View File

@ -263,9 +263,8 @@ public:
const MCAsmLayout &Layout) override; const MCAsmLayout &Layout) override;
bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
const MCSymbolData &DataA, const MCSymbol &SymA,
const MCFragment &FB, const MCFragment &FB, bool InSet,
bool InSet,
bool IsPCRel) const override; bool IsPCRel) const override;
void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout) override; void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;

View File

@ -93,7 +93,7 @@ public:
bool InSet) const; bool InSet) const;
virtual bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, virtual bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
const MCSymbolData &DataA, const MCSymbol &SymA,
const MCFragment &FB, const MCFragment &FB,
bool InSet, bool InSet,
bool IsPCRel) const; bool IsPCRel) const;

View File

@ -244,12 +244,11 @@ class ELFObjectWriter : public MCObjectWriter {
void writeRelocations(const MCAssembler &Asm, const MCSectionELF &Sec); void writeRelocations(const MCAssembler &Asm, const MCSectionELF &Sec);
bool bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbol &SymA,
const MCSymbolData &DataA, const MCFragment &FB,
const MCFragment &FB, bool InSet,
bool InSet, bool IsPCRel) const override;
bool IsPCRel) const override;
bool isWeak(const MCSymbolData &SD) const override; bool isWeak(const MCSymbolData &SD) const override;
@ -1469,14 +1468,14 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm,
} }
bool ELFObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( 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 { bool InSet, bool IsPCRel) const {
if (IsPCRel) { if (IsPCRel) {
assert(!InSet); assert(!InSet);
if (::isWeak(DataA)) if (::isWeak(SymA.getData()))
return false; return false;
} }
return MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(Asm, DataA, FB, return MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(Asm, SymA, FB,
InSet, IsPCRel); InSet, IsPCRel);
} }

View File

@ -506,9 +506,8 @@ bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
if (A->getKind() != MCSymbolRefExpr::VK_None || SA.isUndefined()) { if (A->getKind() != MCSymbolRefExpr::VK_None || SA.isUndefined()) {
IsResolved = false; IsResolved = false;
} else { } else {
const MCSymbolData &DataA = getSymbolData(SA);
IsResolved = getWriter().IsSymbolRefDifferenceFullyResolvedImpl( IsResolved = getWriter().IsSymbolRefDifferenceFullyResolvedImpl(
*this, DataA, *DF, false, true); *this, SA, *DF, false, true);
} }
} }
} else { } else {

View File

@ -35,14 +35,14 @@ bool MCObjectWriter::IsSymbolRefDifferenceFullyResolved(
if(!DataA.getFragment() || !DataB.getFragment()) if(!DataA.getFragment() || !DataB.getFragment())
return false; return false;
return IsSymbolRefDifferenceFullyResolvedImpl( return IsSymbolRefDifferenceFullyResolvedImpl(Asm, SA, *DataB.getFragment(),
Asm, DataA, *DataB.getFragment(), InSet, false); InSet, false);
} }
bool MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( 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 { bool InSet, bool IsPCRel) const {
const MCSection &SecA = DataA.getSymbol().getSection(); const MCSection &SecA = SymA.getSection();
const MCSection &SecB = FB.getParent()->getSection(); const MCSection &SecB = FB.getParent()->getSection();
// On ELF and COFF A - B is absolute if A and B are in the same section. // On ELF and COFF A - B is absolute if A and B are in the same section.
return &SecA == &SecB; return &SecA == &SecB;

View File

@ -669,7 +669,7 @@ void MachObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm,
} }
bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( 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 { bool InSet, bool IsPCRel) const {
if (InSet) if (InSet)
return true; return true;
@ -679,7 +679,7 @@ bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
// - addr(atom(B)) - offset(B) // - addr(atom(B)) - offset(B)
// and the offsets are not relocatable, so the fixup is fully resolved when // and the offsets are not relocatable, so the fixup is fully resolved when
// addr(atom(A)) - addr(atom(B)) == 0. // 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 &SecA = SA.getSection();
const MCSection &SecB = FB.getParent()->getSection(); const MCSection &SecB = FB.getParent()->getSection();

View File

@ -171,7 +171,7 @@ public:
const MCAsmLayout &Layout) override; const MCAsmLayout &Layout) override;
bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
const MCSymbolData &DataA, const MCSymbol &SymA,
const MCFragment &FB, bool InSet, const MCFragment &FB, bool InSet,
bool IsPCRel) const override; bool IsPCRel) const override;
@ -648,15 +648,16 @@ void WinCOFFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm,
} }
bool WinCOFFObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( 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 { bool InSet, bool IsPCRel) const {
// MS LINK expects to be able to replace all references to a function with a // 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 // thunk to implement their /INCREMENTAL feature. Make sure we don't optimize
// away any relocations to functions. // 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) COFF::SCT_COMPLEX_TYPE_SHIFT) == COFF::IMAGE_SYM_DTYPE_FUNCTION)
return false; return false;
return MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(Asm, DataA, FB, return MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(Asm, SymA, FB,
InSet, IsPCRel); InSet, IsPCRel);
} }