diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index b5173e4502de..5948568a4f01 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -153,8 +153,6 @@ private: class PPCTargetInfo final : public TargetInfo { public: PPCTargetInfo(); - bool needsGot(uint32_t Type, const SymbolBody &S) const override; - bool needsPlt(uint32_t Type, const SymbolBody &S) const override; void relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P, uint64_t SA, uint64_t ZA = 0, uint8_t *PairedLoc = nullptr) const override; @@ -196,9 +194,7 @@ public: class AMDGPUTargetInfo final : public TargetInfo { public: - AMDGPUTargetInfo(); - bool needsGot(uint32_t Type, const SymbolBody &S) const override; - bool needsPlt(uint32_t Type, const SymbolBody &S) const override; + AMDGPUTargetInfo() {} void relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P, uint64_t SA, uint64_t ZA = 0, uint8_t *PairedLoc = nullptr) const override; @@ -258,14 +254,31 @@ bool TargetInfo::needsCopyRel(uint32_t Type, const SymbolBody &S) const { return false; } +bool TargetInfo::isTlsLocalDynamicRel(unsigned Type) const { + return Type == TlsLocalDynamicRel; +} + +bool TargetInfo::isTlsGlobalDynamicRel(unsigned Type) const { + return Type == TlsGlobalDynamicRel; +} + +bool TargetInfo::isTlsDynRel(unsigned Type, const SymbolBody &S) const { + return false; +} + bool TargetInfo::isGotRelative(uint32_t Type) const { return false; } - bool TargetInfo::isHintRel(uint32_t Type) const { return false; } - bool TargetInfo::isRelRelative(uint32_t Type) const { return true; } - bool TargetInfo::isSizeRel(uint32_t Type) const { return false; } +bool TargetInfo::needsGot(uint32_t Type, const SymbolBody &S) const { + return false; +} + +bool TargetInfo::needsPlt(uint32_t Type, const SymbolBody &S) const { + return false; +} + unsigned TargetInfo::relaxTls(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P, uint64_t SA, const SymbolBody *S) const { @@ -908,12 +921,6 @@ static uint16_t applyPPCHighest(uint64_t V) { return V >> 48; } static uint16_t applyPPCHighesta(uint64_t V) { return (V + 0x8000) >> 48; } PPCTargetInfo::PPCTargetInfo() {} -bool PPCTargetInfo::needsGot(uint32_t Type, const SymbolBody &S) const { - return false; -} -bool PPCTargetInfo::needsPlt(uint32_t Type, const SymbolBody &S) const { - return false; -} bool PPCTargetInfo::isRelRelative(uint32_t Type) const { return false; } void PPCTargetInfo::relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, @@ -1374,16 +1381,6 @@ void AArch64TargetInfo::relocateOne(uint8_t *Loc, uint8_t *BufEnd, } } -AMDGPUTargetInfo::AMDGPUTargetInfo() {} - -bool AMDGPUTargetInfo::needsGot(uint32_t Type, const SymbolBody &S) const { - return false; -} - -bool AMDGPUTargetInfo::needsPlt(uint32_t Type, const SymbolBody &S) const { - return false; -} - // Implementing relocations for AMDGPU is low priority since most // programs don't use relocations now. Thus, this function is not // actually called (relocateOne is called for each relocation). diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h index c000e5e40269..06f034a909d6 100644 --- a/lld/ELF/Target.h +++ b/lld/ELF/Target.h @@ -22,23 +22,11 @@ class SymbolBody; class TargetInfo { public: uint64_t getVAStart() const; - - bool isTlsLocalDynamicRel(unsigned Type) const { - return Type == TlsLocalDynamicRel; - } - - bool isTlsGlobalDynamicRel(unsigned Type) const { - return Type == TlsGlobalDynamicRel; - } - + bool isTlsLocalDynamicRel(unsigned Type) const; + bool isTlsGlobalDynamicRel(unsigned Type) const; virtual unsigned getDynRel(unsigned Type) const { return Type; } - - virtual bool isTlsDynRel(unsigned Type, const SymbolBody &S) const { - return false; - } - + virtual bool isTlsDynRel(unsigned Type, const SymbolBody &S) const; virtual unsigned getTlsGotRel(unsigned Type = -1) const { return TlsGotRel; } - virtual void writeGotHeader(uint8_t *Buf) const {} virtual void writeGotPltHeader(uint8_t *Buf) const {} virtual void writeGotPlt(uint8_t *Buf, uint64_t Plt) const {}; @@ -66,8 +54,8 @@ public: virtual bool isSizeRel(uint32_t Type) const; virtual bool needsDynRelative(unsigned Type) const { return false; } - virtual bool needsGot(uint32_t Type, const SymbolBody &S) const = 0; - virtual bool needsPlt(uint32_t Type, const SymbolBody &S) const = 0; + virtual bool needsGot(uint32_t Type, const SymbolBody &S) const; + virtual bool needsPlt(uint32_t Type, const SymbolBody &S) const; virtual void relocateOne(uint8_t *Loc, uint8_t *BufEnd, uint32_t Type, uint64_t P, uint64_t SA, uint64_t ZA = 0, uint8_t *PairedLoc = nullptr) const = 0;