Reduce templating. NFC.

llvm-svn: 267018
This commit is contained in:
Rafael Espindola 2016-04-21 17:37:11 +00:00
parent 48d72342ff
commit e26b50e71a
3 changed files with 5 additions and 17 deletions

View File

@ -222,18 +222,16 @@ uint64_t TargetInfo::getVAStart() const { return Config->Pic ? 0 : VAStart; }
bool TargetInfo::needsCopyRelImpl(uint32_t Type) const { return false; }
template <typename ELFT> static bool mayNeedCopy(const SymbolBody &S) {
static bool mayNeedCopy(const SymbolBody &S) {
if (Config->Shared)
return false;
auto *SS = dyn_cast<SharedSymbol<ELFT>>(&S);
if (!SS)
if (!S.isShared())
return false;
return SS->isObject();
return S.isObject();
}
template <class ELFT>
bool TargetInfo::needsCopyRel(uint32_t Type, const SymbolBody &S) const {
return mayNeedCopy<ELFT>(S) && needsCopyRelImpl(Type);
return mayNeedCopy(S) && needsCopyRelImpl(Type);
}
bool TargetInfo::isHintRel(uint32_t Type) const { return false; }
@ -1699,14 +1697,5 @@ template uint32_t getMipsGpAddr<ELF32LE>();
template uint32_t getMipsGpAddr<ELF32BE>();
template uint64_t getMipsGpAddr<ELF64LE>();
template uint64_t getMipsGpAddr<ELF64BE>();
template bool TargetInfo::needsCopyRel<ELF32LE>(uint32_t,
const SymbolBody &) const;
template bool TargetInfo::needsCopyRel<ELF32BE>(uint32_t,
const SymbolBody &) const;
template bool TargetInfo::needsCopyRel<ELF64LE>(uint32_t,
const SymbolBody &) const;
template bool TargetInfo::needsCopyRel<ELF64BE>(uint32_t,
const SymbolBody &) const;
}
}

View File

@ -62,7 +62,6 @@ public:
virtual RelExpr getRelExpr(uint32_t Type, const SymbolBody &S) const = 0;
virtual void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const = 0;
template <class ELFT>
bool needsCopyRel(uint32_t Type, const SymbolBody &S) const;
virtual ~TargetInfo();

View File

@ -558,7 +558,7 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) {
// in a read-only section, we need to create a copy relocation for the
// symbol.
if (auto *B = dyn_cast<SharedSymbol<ELFT>>(&Body)) {
if (IsAlloc && !IsWrite && Target->needsCopyRel<ELFT>(Type, *B)) {
if (IsAlloc && !IsWrite && Target->needsCopyRel(Type, *B)) {
if (!B->needsCopy())
addCopyRelSymbol(B);
C.Relocations.push_back({Expr, Type, Offset, Addend, &Body});