From f7ae359d2c8ab309a1556a4365c52fab26281e3c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 23 Feb 2016 18:53:29 +0000 Subject: [PATCH] Simplify. NFC. llvm-svn: 261668 --- lld/ELF/InputSection.cpp | 2 +- lld/ELF/Target.cpp | 33 +++++++++++++-------------------- lld/ELF/Target.h | 1 + lld/ELF/Writer.cpp | 2 +- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index 6086079..ad81780 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -218,7 +218,7 @@ void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd, SymVA = Body->getGotVA(); if (Body->IsTls) Type = Target->getTlsGotRel(Type); - } else if (!Target->needsCopyRel(Type, *Body) && + } else if (!Target->needsCopyRel(Type, *Body) && isa>(*Body)) { continue; } else if (Target->isTlsDynRel(Type, *Body)) { diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 1c5c57d..01baba9 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -275,25 +275,9 @@ template static bool mayNeedCopy(const SymbolBody &S) { return SS->Sym.getType() == STT_OBJECT; } +template bool TargetInfo::needsCopyRel(uint32_t Type, const SymbolBody &S) const { - bool MayNeed; - switch (Config->EKind) { - case ELF32LEKind: - MayNeed = mayNeedCopy(S); - break; - case ELF64LEKind: - MayNeed = mayNeedCopy(S); - break; - case ELF32BEKind: - MayNeed = mayNeedCopy(S); - break; - case ELF64BEKind: - MayNeed = mayNeedCopy(S); - break; - default: - llvm_unreachable("Invalid ELF kind"); - } - return MayNeed && needsCopyRelImpl(Type); + return mayNeedCopy(S) && needsCopyRelImpl(Type); } bool TargetInfo::isTlsDynRel(unsigned Type, const SymbolBody &S) const { @@ -725,7 +709,7 @@ bool X86_64TargetInfo::isTlsDynRel(unsigned Type, const SymbolBody &S) const { TargetInfo::PltNeed X86_64TargetInfo::needsPlt(uint32_t Type, const SymbolBody &S) const { - if (needsCopyRel(Type, S)) + if (needsCopyRel(Type, S)) return Plt_No; if (isGnuIFunc(S)) return Plt_Explicit; @@ -1714,7 +1698,7 @@ bool MipsTargetInfo::needsGot(uint32_t Type, SymbolBody &S) const { template TargetInfo::PltNeed MipsTargetInfo::needsPlt(uint32_t Type, const SymbolBody &S) const { - if (needsCopyRel(Type, S)) + if (needsCopyRel(Type, S)) return Plt_No; if (Type == R_MIPS_26 && canBePreempted(&S, false)) return Plt_Explicit; @@ -1859,5 +1843,14 @@ template uint32_t getMipsGpAddr(); template uint32_t getMipsGpAddr(); template uint64_t getMipsGpAddr(); template uint64_t getMipsGpAddr(); + +template bool TargetInfo::needsCopyRel(uint32_t, + const SymbolBody &) const; +template bool TargetInfo::needsCopyRel(uint32_t, + const SymbolBody &) const; +template bool TargetInfo::needsCopyRel(uint32_t, + const SymbolBody &) const; +template bool TargetInfo::needsCopyRel(uint32_t, + const SymbolBody &) const; } } diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h index 4af596c..92f3e22 100644 --- a/lld/ELF/Target.h +++ b/lld/ELF/Target.h @@ -63,6 +63,7 @@ public: uint8_t *PairedLoc = nullptr) const = 0; virtual bool isGotRelative(uint32_t Type) const; virtual bool canRelaxTls(unsigned Type, const SymbolBody *S) const; + template bool needsCopyRel(uint32_t Type, const SymbolBody &S) const; virtual unsigned relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P, uint64_t SA, const SymbolBody *S) const; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 52741b1..ab844d3 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -335,7 +335,7 @@ void Writer::scanRelocs( if (auto *B = dyn_cast_or_null>(Body)) { if (B->needsCopy()) continue; - if (Target->needsCopyRel(Type, *B)) { + if (Target->needsCopyRel(Type, *B)) { B->NeedsCopyOrPltAddr = true; Out::RelaDyn->addReloc( {Target->CopyRel, DynamicReloc::Off_Bss, B}); -- 2.7.4