Index: ELF/Arch/SPARCV9.cpp =================================================================== --- ELF/Arch/SPARCV9.cpp +++ ELF/Arch/SPARCV9.cpp @@ -138,7 +138,7 @@ }; memcpy(Buf, PltData, sizeof(PltData)); - uint64_t Off = getPltEntryOffset(Index); + uint64_t Off = PltHeaderSize + Index * PltEntrySize; relocateOne(Buf, R_SPARC_22, Off); relocateOne(Buf + 4, R_SPARC_WDISP19, -(Off + 4 - PltEntrySize)); } Index: ELF/Arch/X86.cpp =================================================================== --- ELF/Arch/X86.cpp +++ ELF/Arch/X86.cpp @@ -228,7 +228,7 @@ } write32le(Buf + 7, RelOff); - write32le(Buf + 12, -getPltEntryOffset(Index) - 16); + write32le(Buf + 12, -(PltHeaderSize + Index * PltEntrySize + 16)); } int64_t X86::getImplicitAddend(const uint8_t *Buf, RelType Type) const { @@ -473,7 +473,7 @@ memcpy(Buf, Insn, sizeof(Insn)); uint32_t Ebx = In.Got->getVA() + In.Got->getSize(); - unsigned Off = getPltEntryOffset(Index); + unsigned Off = PltHeaderSize + Index * PltEntrySize; write32le(Buf + 3, GotPltEntryAddr - Ebx); write32le(Buf + 8, -Off - 12 + 32); write32le(Buf + 13, -Off - 17 + 18); @@ -531,7 +531,7 @@ }; memcpy(Buf, Insn, sizeof(Insn)); - unsigned Off = getPltEntryOffset(Index); + unsigned Off = PltHeaderSize + Index * PltEntrySize; write32le(Buf + 2, GotPltEntryAddr); write32le(Buf + 7, -Off - 11 + 32); write32le(Buf + 12, -Off - 16 + 17); Index: ELF/Arch/X86_64.cpp =================================================================== --- ELF/Arch/X86_64.cpp +++ ELF/Arch/X86_64.cpp @@ -160,7 +160,7 @@ write32le(Buf + 2, GotPltEntryAddr - PltEntryAddr - 6); write32le(Buf + 7, Index); - write32le(Buf + 12, -getPltEntryOffset(Index) - 16); + write32le(Buf + 12, -(PltHeaderSize + Index * PltEntrySize + 16)); } template RelType X86_64::getDynRel(RelType Type) const { @@ -592,7 +592,7 @@ }; memcpy(Buf, Insn, sizeof(Insn)); - uint64_t Off = TargetInfo::getPltEntryOffset(Index); + uint64_t Off = TargetInfo::PltHeaderSize + Index * TargetInfo::PltEntrySize; write32le(Buf + 3, GotPltEntryAddr - PltEntryAddr - 7); write32le(Buf + 8, -Off - 12 + 32); @@ -635,7 +635,8 @@ memcpy(Buf, Insn, sizeof(Insn)); write32le(Buf + 3, GotPltEntryAddr - PltEntryAddr - 7); - write32le(Buf + 8, -TargetInfo::getPltEntryOffset(Index) - 12); + write32le(Buf + 8, -(TargetInfo::PltHeaderSize + + Index * TargetInfo::PltEntrySize + 12)); } template static TargetInfo *getTargetInfo() { Index: ELF/Symbols.cpp =================================================================== --- ELF/Symbols.cpp +++ ELF/Symbols.cpp @@ -144,17 +144,13 @@ } uint64_t Symbol::getPltVA() const { - if (this->IsInIplt) { - if (Config->ZRetpolineplt) - return In.Iplt->getVA() + Target->getPltEntryOffset(PltIndex); - return In.Iplt->getVA() + PltIndex * Target->PltEntrySize; - } - return In.Plt->getVA() + Target->getPltEntryOffset(PltIndex); + PltSection *Plt = IsInIplt ? In.Iplt : In.Plt; + return Plt->getVA() + Plt->HeaderSize + PltIndex * Target->PltEntrySize; } uint64_t Symbol::getPltOffset() const { assert(!this->IsInIplt); - return Target->getPltEntryOffset(PltIndex); + return Target->PltHeaderSize + PltIndex * Target->PltEntrySize; } uint64_t Symbol::getPPC64LongBranchTableVA() const { Index: ELF/SyntheticSections.h =================================================================== --- ELF/SyntheticSections.h +++ ELF/SyntheticSections.h @@ -662,10 +662,11 @@ template void addEntry(Symbol &Sym); + size_t HeaderSize; + private: unsigned getPltRelocOff() const; std::vector> Entries; - size_t HeaderSize; bool IsIplt; }; Index: ELF/Target.h =================================================================== --- ELF/Target.h +++ ELF/Target.h @@ -45,10 +45,6 @@ virtual void addPltHeaderSymbols(InputSection &IS) const {} virtual void addPltSymbols(InputSection &IS, uint64_t Off) const {} - unsigned getPltEntryOffset(unsigned Index) const { - return Index * PltEntrySize + PltHeaderSize; - } - // Returns true if a relocation only uses the low bits of a value such that // all those bits are in the same page. For example, if the relocation // only uses the low 12 bits in a system with 4k pages. If this is true, the