From a0a50a7a5b0ca4ad83b3f2a963b2e67e4254ed30 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 28 Mar 2019 01:37:48 +0000 Subject: [PATCH] Inline a trivial function. NFC. I found that hiding this particular actual expression doesn't help readers understand the code. So I remove and inline that function. llvm-svn: 357140 --- lld/ELF/Arch/SPARCV9.cpp | 2 +- lld/ELF/Arch/X86.cpp | 6 +++--- lld/ELF/Arch/X86_64.cpp | 6 +++--- lld/ELF/Relocations.cpp | 4 +++- lld/ELF/Target.h | 4 ---- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lld/ELF/Arch/SPARCV9.cpp b/lld/ELF/Arch/SPARCV9.cpp index 556cd81..591810f 100644 --- a/lld/ELF/Arch/SPARCV9.cpp +++ b/lld/ELF/Arch/SPARCV9.cpp @@ -139,7 +139,7 @@ void SPARCV9::writePlt(uint8_t *Buf, uint64_t GotEntryAddr, }; memcpy(Buf, PltData, sizeof(PltData)); - uint64_t Off = getPltEntryOffset(Index); + uint64_t Off = PltHeaderSize + PltEntrySize * Index; relocateOne(Buf, R_SPARC_22, Off); relocateOne(Buf + 4, R_SPARC_WDISP19, -(Off + 4 - PltEntrySize)); } diff --git a/lld/ELF/Arch/X86.cpp b/lld/ELF/Arch/X86.cpp index b110abc..ff35362 100644 --- a/lld/ELF/Arch/X86.cpp +++ b/lld/ELF/Arch/X86.cpp @@ -234,7 +234,7 @@ void X86::writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, } write32le(Buf + 7, RelOff); - write32le(Buf + 12, -getPltEntryOffset(Index) - 16); + write32le(Buf + 12, -PltHeaderSize - PltEntrySize * Index - 16); } int64_t X86::getImplicitAddend(const uint8_t *Buf, RelType Type) const { @@ -474,7 +474,7 @@ void RetpolinePic::writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, memcpy(Buf, Insn, sizeof(Insn)); uint32_t Ebx = In.GotPlt->getVA(); - unsigned Off = getPltEntryOffset(Index); + unsigned Off = PltHeaderSize + PltEntrySize * Index; write32le(Buf + 3, GotPltEntryAddr - Ebx); write32le(Buf + 8, -Off - 12 + 32); write32le(Buf + 13, -Off - 17 + 18); @@ -532,7 +532,7 @@ void RetpolineNoPic::writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, }; memcpy(Buf, Insn, sizeof(Insn)); - unsigned Off = getPltEntryOffset(Index); + unsigned Off = PltHeaderSize + PltEntrySize * Index; write32le(Buf + 2, GotPltEntryAddr); write32le(Buf + 7, -Off - 11 + 32); write32le(Buf + 12, -Off - 16 + 17); diff --git a/lld/ELF/Arch/X86_64.cpp b/lld/ELF/Arch/X86_64.cpp index f9c731d..1f6f0af 100644 --- a/lld/ELF/Arch/X86_64.cpp +++ b/lld/ELF/Arch/X86_64.cpp @@ -171,7 +171,7 @@ void X86_64::writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, write32le(Buf + 2, GotPltEntryAddr - PltEntryAddr - 6); write32le(Buf + 7, Index); - write32le(Buf + 12, -getPltEntryOffset(Index) - 16); + write32le(Buf + 12, -this->PltHeaderSize - this->PltEntrySize * Index - 16); } template RelType X86_64::getDynRel(RelType Type) const { @@ -632,7 +632,7 @@ void Retpoline::writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, }; memcpy(Buf, Insn, sizeof(Insn)); - uint64_t Off = getPltEntryOffset(Index); + uint64_t Off = this->PltHeaderSize + this->PltEntrySize * Index; write32le(Buf + 3, GotPltEntryAddr - PltEntryAddr - 7); write32le(Buf + 8, -Off - 12 + 32); @@ -675,7 +675,7 @@ void RetpolineZNow::writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, memcpy(Buf, Insn, sizeof(Insn)); write32le(Buf + 3, GotPltEntryAddr - PltEntryAddr - 7); - write32le(Buf + 8, -getPltEntryOffset(Index) - 12); + write32le(Buf + 8, -this->PltHeaderSize - this->PltEntrySize * Index - 12); } template static TargetInfo *getTargetInfo() { diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 3545335..ada625c 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -979,7 +979,9 @@ static void processRelocAux(InputSectionBase &Sec, RelExpr Expr, RelType Type, if (!Sym.isInPlt()) addPltEntry(In.Plt, In.GotPlt, In.RelaPlt, Target->PltRel, Sym); if (!Sym.isDefined()) - replaceWithDefined(Sym, In.Plt, getPltEntryOffset(Sym.PltIndex), 0); + replaceWithDefined( + Sym, In.Plt, + Target->PltHeaderSize + Target->PltEntrySize * Sym.PltIndex, 0); Sym.NeedsPltAddr = true; Sec.Relocations.push_back({Expr, Type, Offset, Addend, &Sym}); return; diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h index c7d29b6..5f5f7b5 100644 --- a/lld/ELF/Target.h +++ b/lld/ELF/Target.h @@ -201,10 +201,6 @@ static inline void reportRangeError(uint8_t *Loc, RelType Type, const Twine &V, ", " + Twine(Max).str() + "]" + Hint); } -inline unsigned getPltEntryOffset(unsigned Idx) { - return Target->PltHeaderSize + Target->PltEntrySize * Idx; -} - // Make sure that V can be represented as an N bit signed integer. inline void checkInt(uint8_t *Loc, int64_t V, int N, RelType Type) { if (V != llvm::SignExtend64(V, N)) -- 2.7.4