diff options
-rw-r--r-- | lld/ELF/Target.cpp | 9 | ||||
-rw-r--r-- | lld/ELF/Target.h | 1 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 7 |
3 files changed, 5 insertions, 12 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 58ab2268448..8b12d751771 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -120,7 +120,6 @@ public: bool needsPltImpl(uint32_t Type) const override; void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override; bool isRelRelative(uint32_t Type) const override; - bool isSizeRel(uint32_t Type) const override; void relaxTlsGdToIe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override; void relaxTlsGdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override; @@ -282,7 +281,6 @@ bool TargetInfo::needsCopyRel(uint32_t Type, const SymbolBody &S) const { 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; @@ -692,6 +690,9 @@ RelExpr X86_64TargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const { switch (Type) { default: return R_ABS; + case R_X86_64_SIZE32: + case R_X86_64_SIZE64: + return R_SIZE; case R_X86_64_GOTPCREL: case R_X86_64_PLT32: case R_X86_64_PC32: @@ -810,10 +811,6 @@ bool X86_64TargetInfo::isRelRelative(uint32_t Type) const { } } -bool X86_64TargetInfo::isSizeRel(uint32_t Type) const { - return Type == R_X86_64_SIZE32 || Type == R_X86_64_SIZE64; -} - // "Ulrich Drepper, ELF Handling For Thread-Local Storage" (5.5 // x86-x64 linker optimizations, http://www.akkadia.org/drepper/tls.pdf) shows // how GD can be optimized to LE: diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h index 4d90fe23245..ed32faa696a 100644 --- a/lld/ELF/Target.h +++ b/lld/ELF/Target.h @@ -56,7 +56,6 @@ public: // dynamic linker if isRelRelative returns true. virtual bool isRelRelative(uint32_t Type) const; - virtual bool isSizeRel(uint32_t Type) const; virtual bool needsDynRelative(uint32_t Type) const { return false; } virtual bool needsGot(uint32_t Type, const SymbolBody &S) const; virtual bool refersToGotEntry(uint32_t Type) const; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 6bb13912499..d3505aba2ba 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -609,11 +609,8 @@ void Writer<ELFT>::scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) { // We can however do better than just copying the incoming relocation. We // can process some of it and and just ask the dynamic linker to add the // load address. - if (Target->isSizeRel(Type)) { - C.Relocations.push_back({R_SIZE, Type, Offset, Addend, &Body}); - continue; - } - if (!Config->Pic || Target->isRelRelative(Type) || Expr == R_PC) { + if (!Config->Pic || Target->isRelRelative(Type) || Expr == R_PC || + Expr == R_SIZE) { if (Config->EMachine == EM_MIPS && Body.isLocal() && (Type == R_MIPS_GPREL16 || Type == R_MIPS_GPREL32)) Expr = R_MIPS_GP0; |