[lld] r357140 - Inline a trivial function. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 27 18:37:48 PDT 2019
Author: ruiu
Date: Wed Mar 27 18:37:48 2019
New Revision: 357140
URL: http://llvm.org/viewvc/llvm-project?rev=357140&view=rev
Log:
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.
Modified:
lld/trunk/ELF/Arch/SPARCV9.cpp
lld/trunk/ELF/Arch/X86.cpp
lld/trunk/ELF/Arch/X86_64.cpp
lld/trunk/ELF/Relocations.cpp
lld/trunk/ELF/Target.h
Modified: lld/trunk/ELF/Arch/SPARCV9.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/SPARCV9.cpp?rev=357140&r1=357139&r2=357140&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/SPARCV9.cpp (original)
+++ lld/trunk/ELF/Arch/SPARCV9.cpp Wed Mar 27 18:37:48 2019
@@ -139,7 +139,7 @@ void SPARCV9::writePlt(uint8_t *Buf, uin
};
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));
}
Modified: lld/trunk/ELF/Arch/X86.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/X86.cpp?rev=357140&r1=357139&r2=357140&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/X86.cpp (original)
+++ lld/trunk/ELF/Arch/X86.cpp Wed Mar 27 18:37:48 2019
@@ -234,7 +234,7 @@ void X86::writePlt(uint8_t *Buf, uint64_
}
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
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 *B
};
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);
Modified: lld/trunk/ELF/Arch/X86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/X86_64.cpp?rev=357140&r1=357139&r2=357140&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/X86_64.cpp (original)
+++ lld/trunk/ELF/Arch/X86_64.cpp Wed Mar 27 18:37:48 2019
@@ -171,7 +171,7 @@ void X86_64<ELFT>::writePlt(uint8_t *Buf
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 <class ELFT> RelType X86_64<ELFT>::getDynRel(RelType Type) const {
@@ -632,7 +632,7 @@ void Retpoline<ELFT>::writePlt(uint8_t *
};
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<ELFT>::writePlt(uint8
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 <class ELFT> static TargetInfo *getTargetInfo() {
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=357140&r1=357139&r2=357140&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Mar 27 18:37:48 2019
@@ -979,7 +979,9 @@ static void processRelocAux(InputSection
if (!Sym.isInPlt())
addPltEntry<ELFT>(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;
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=357140&r1=357139&r2=357140&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Wed Mar 27 18:37:48 2019
@@ -201,10 +201,6 @@ static inline void reportRangeError(uint
", " + 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))
More information about the llvm-commits
mailing list