Small refactoring so that RelocNeedsGOT can stay in the target independent

side when the target specific bits are moved to the Target directory.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147053 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2011-12-21 14:26:29 +00:00
parent 9a31fb0c38
commit c677e790e5
2 changed files with 16 additions and 24 deletions

View File

@ -447,6 +447,10 @@ void ELFObjectWriter::RecordRelocation(const MCAssembler &Asm,
FixedValue = Value; FixedValue = Value;
unsigned Type = GetRelocType(Target, Fixup, IsPCRel, unsigned Type = GetRelocType(Target, Fixup, IsPCRel,
(RelocSymbol != 0), Addend); (RelocSymbol != 0), Addend);
MCSymbolRefExpr::VariantKind Modifier = Target.isAbsolute() ?
MCSymbolRefExpr::VK_None : Target.getSymA()->getKind();
if (RelocNeedsGOT(Modifier))
NeedsGOT = true;
uint64_t RelocOffset = Layout.getFragmentOffset(Fragment) + uint64_t RelocOffset = Layout.getFragmentOffset(Fragment) +
Fixup.getOffset(); Fixup.getOffset();
@ -1385,16 +1389,8 @@ unsigned ARMELFObjectWriter::GetRelocType(const MCValue &Target,
const MCFixup &Fixup, const MCFixup &Fixup,
bool IsPCRel, bool IsPCRel,
bool IsRelocWithSymbol, bool IsRelocWithSymbol,
int64_t Addend) { int64_t Addend) const {
MCSymbolRefExpr::VariantKind Modifier = Target.isAbsolute() ? return GetRelocTypeInner(Target, Fixup, IsPCRel);
MCSymbolRefExpr::VK_None : Target.getSymA()->getKind();
unsigned Type = GetRelocTypeInner(Target, Fixup, IsPCRel);
if (RelocNeedsGOT(Modifier))
NeedsGOT = true;
return Type;
} }
unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target, unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target,
@ -1536,7 +1532,7 @@ unsigned PPCELFObjectWriter::GetRelocType(const MCValue &Target,
const MCFixup &Fixup, const MCFixup &Fixup,
bool IsPCRel, bool IsPCRel,
bool IsRelocWithSymbol, bool IsRelocWithSymbol,
int64_t Addend) { int64_t Addend) const {
// determine the type of the relocation // determine the type of the relocation
unsigned Type; unsigned Type;
if (IsPCRel) { if (IsPCRel) {
@ -1606,7 +1602,7 @@ unsigned MBlazeELFObjectWriter::GetRelocType(const MCValue &Target,
const MCFixup &Fixup, const MCFixup &Fixup,
bool IsPCRel, bool IsPCRel,
bool IsRelocWithSymbol, bool IsRelocWithSymbol,
int64_t Addend) { int64_t Addend) const {
// determine the type of the relocation // determine the type of the relocation
unsigned Type; unsigned Type;
if (IsPCRel) { if (IsPCRel) {
@ -1652,7 +1648,7 @@ unsigned X86ELFObjectWriter::GetRelocType(const MCValue &Target,
const MCFixup &Fixup, const MCFixup &Fixup,
bool IsPCRel, bool IsPCRel,
bool IsRelocWithSymbol, bool IsRelocWithSymbol,
int64_t Addend) { int64_t Addend) const {
// determine the type of the relocation // determine the type of the relocation
MCSymbolRefExpr::VariantKind Modifier = Target.isAbsolute() ? MCSymbolRefExpr::VariantKind Modifier = Target.isAbsolute() ?
@ -1822,9 +1818,6 @@ unsigned X86ELFObjectWriter::GetRelocType(const MCValue &Target,
} }
} }
if (RelocNeedsGOT(Modifier))
NeedsGOT = true;
return Type; return Type;
} }
@ -1862,7 +1855,7 @@ unsigned MipsELFObjectWriter::GetRelocType(const MCValue &Target,
const MCFixup &Fixup, const MCFixup &Fixup,
bool IsPCRel, bool IsPCRel,
bool IsRelocWithSymbol, bool IsRelocWithSymbol,
int64_t Addend) { int64_t Addend) const {
// determine the type of the relocation // determine the type of the relocation
unsigned Type = (unsigned)ELF::R_MIPS_NONE; unsigned Type = (unsigned)ELF::R_MIPS_NONE;
unsigned Kind = (unsigned)Fixup.getKind(); unsigned Kind = (unsigned)Fixup.getKind();

View File

@ -351,7 +351,7 @@ class ELFObjectWriter : public MCObjectWriter {
protected: protected:
virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
bool IsPCRel, bool IsRelocWithSymbol, bool IsPCRel, bool IsRelocWithSymbol,
int64_t Addend) = 0; int64_t Addend) const = 0;
virtual void adjustFixupOffset(const MCFixup &Fixup, virtual void adjustFixupOffset(const MCFixup &Fixup,
uint64_t &RelocOffset) {} uint64_t &RelocOffset) {}
}; };
@ -368,7 +368,7 @@ class ELFObjectWriter : public MCObjectWriter {
protected: protected:
virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
bool IsPCRel, bool IsRelocWithSymbol, bool IsPCRel, bool IsRelocWithSymbol,
int64_t Addend); int64_t Addend) const;
}; };
@ -395,11 +395,10 @@ class ELFObjectWriter : public MCObjectWriter {
virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
bool IsPCRel, bool IsRelocWithSymbol, bool IsPCRel, bool IsRelocWithSymbol,
int64_t Addend); int64_t Addend) const;
private: private:
unsigned GetRelocTypeInner(const MCValue &Target, unsigned GetRelocTypeInner(const MCValue &Target,
const MCFixup &Fixup, bool IsPCRel) const; const MCFixup &Fixup, bool IsPCRel) const;
}; };
//===- PPCELFObjectWriter -------------------------------------------===// //===- PPCELFObjectWriter -------------------------------------------===//
@ -414,7 +413,7 @@ class ELFObjectWriter : public MCObjectWriter {
protected: protected:
virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
bool IsPCRel, bool IsRelocWithSymbol, bool IsPCRel, bool IsRelocWithSymbol,
int64_t Addend); int64_t Addend) const;
virtual void adjustFixupOffset(const MCFixup &Fixup, uint64_t &RelocOffset); virtual void adjustFixupOffset(const MCFixup &Fixup, uint64_t &RelocOffset);
}; };
@ -430,7 +429,7 @@ class ELFObjectWriter : public MCObjectWriter {
protected: protected:
virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
bool IsPCRel, bool IsRelocWithSymbol, bool IsPCRel, bool IsRelocWithSymbol,
int64_t Addend); int64_t Addend) const;
}; };
//===- MipsELFObjectWriter -------------------------------------------===// //===- MipsELFObjectWriter -------------------------------------------===//
@ -453,7 +452,7 @@ class ELFObjectWriter : public MCObjectWriter {
virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup, virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
bool IsPCRel, bool IsRelocWithSymbol, bool IsPCRel, bool IsRelocWithSymbol,
int64_t Addend); int64_t Addend) const;
}; };
} }