[lld] r272910 - Eliminate unnecessary call of SymbolBody::getPltVA.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 16 09:14:51 PDT 2016
Author: ruiu
Date: Thu Jun 16 11:14:50 2016
New Revision: 272910
URL: http://llvm.org/viewvc/llvm-project?rev=272910&view=rev
Log:
Eliminate unnecessary call of SymbolBody::getPltVA.
For ARM and MIPS, we don't need to call this function.
This patch passes a symbol instead of a PLT entry address
so that the target handler can call it if necessary.
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Target.h
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=272910&r1=272909&r2=272910&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Thu Jun 16 11:14:50 2016
@@ -79,7 +79,7 @@ template <class ELFT> void GotPltSection
Target->writeGotPltHeader(Buf);
Buf += Target->GotPltHeaderEntriesNum * sizeof(uintX_t);
for (const SymbolBody *B : Entries) {
- Target->writeGotPlt(Buf, B->getPltVA<ELFT>());
+ Target->writeGotPlt(Buf, *B);
Buf += sizeof(uintX_t);
}
}
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=272910&r1=272909&r2=272910&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Jun 16 11:14:50 2016
@@ -91,7 +91,7 @@ public:
bool isTlsLocalDynamicRel(uint32_t Type) const override;
bool isTlsGlobalDynamicRel(uint32_t Type) const override;
bool isTlsInitialExecRel(uint32_t Type) const override;
- void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
+ void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
void writePltZero(uint8_t *Buf) const override;
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
int32_t Index, unsigned RelOff) const override;
@@ -114,7 +114,7 @@ public:
bool isTlsGlobalDynamicRel(uint32_t Type) const override;
bool isTlsInitialExecRel(uint32_t Type) const override;
void writeGotPltHeader(uint8_t *Buf) const override;
- void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
+ void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
void writePltZero(uint8_t *Buf) const override;
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
int32_t Index, unsigned RelOff) const override;
@@ -155,7 +155,7 @@ public:
RelExpr getRelExpr(uint32_t Type, const SymbolBody &S) const override;
uint32_t getDynRel(uint32_t Type) const override;
bool isTlsInitialExecRel(uint32_t Type) const override;
- void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
+ void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
void writePltZero(uint8_t *Buf) const override;
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
int32_t Index, unsigned RelOff) const override;
@@ -181,7 +181,7 @@ public:
RelExpr getRelExpr(uint32_t Type, const SymbolBody &S) const override;
uint32_t getDynRel(uint32_t Type) const override;
uint64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const override;
- void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
+ void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
void writePltZero(uint8_t *Buf) const override;
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
int32_t Index, unsigned RelOff) const override;
@@ -194,7 +194,7 @@ public:
RelExpr getRelExpr(uint32_t Type, const SymbolBody &S) const override;
uint64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const override;
uint32_t getDynRel(uint32_t Type) const override;
- void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
+ void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
void writePltZero(uint8_t *Buf) const override;
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
int32_t Index, unsigned RelOff) const override;
@@ -350,10 +350,10 @@ void X86TargetInfo::writeGotPltHeader(ui
write32le(Buf, Out<ELF32LE>::Dynamic->getVA());
}
-void X86TargetInfo::writeGotPlt(uint8_t *Buf, uint64_t Plt) const {
+void X86TargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &S) const {
// Entries in .got.plt initially points back to the corresponding
// PLT entries with a fixed offset to skip the first instruction.
- write32le(Buf, Plt + 6);
+ write32le(Buf, S.getPltVA<ELF32LE>() + 6);
}
uint32_t X86TargetInfo::getDynRel(uint32_t Type) const {
@@ -583,9 +583,9 @@ void X86_64TargetInfo::writeGotPltHeader
write64le(Buf, Out<ELF64LE>::Dynamic->getVA());
}
-void X86_64TargetInfo::writeGotPlt(uint8_t *Buf, uint64_t Plt) const {
+void X86_64TargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &S) const {
// See comments in X86TargetInfo::writeGotPlt.
- write32le(Buf, Plt + 6);
+ write32le(Buf, S.getPltVA<ELF64LE>() + 6);
}
void X86_64TargetInfo::writePltZero(uint8_t *Buf) const {
@@ -1203,7 +1203,7 @@ uint32_t AArch64TargetInfo::getDynRel(ui
return R_AARCH64_ABS32;
}
-void AArch64TargetInfo::writeGotPlt(uint8_t *Buf, uint64_t Plt) const {
+void AArch64TargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &) const {
write64le(Buf, Out<ELF64LE>::Plt->getVA());
}
@@ -1498,7 +1498,7 @@ uint32_t ARMTargetInfo::getDynRel(uint32
return R_ARM_ABS32;
}
-void ARMTargetInfo::writeGotPlt(uint8_t *Buf, uint64_t Plt) const {
+void ARMTargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &) const {
write32le(Buf, Out<ELF32LE>::Plt->getVA());
}
@@ -1788,7 +1788,7 @@ uint32_t MipsTargetInfo<ELFT>::getDynRel
}
template <class ELFT>
-void MipsTargetInfo<ELFT>::writeGotPlt(uint8_t *Buf, uint64_t Plt) const {
+void MipsTargetInfo<ELFT>::writeGotPlt(uint8_t *Buf, const SymbolBody &) const {
write32<ELFT::TargetEndianness>(Buf, Out<ELFT>::Plt->getVA());
}
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=272910&r1=272909&r2=272910&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Thu Jun 16 11:14:50 2016
@@ -29,7 +29,7 @@ public:
virtual bool isTlsGlobalDynamicRel(uint32_t Type) const;
virtual uint32_t getDynRel(uint32_t Type) const { return Type; }
virtual void writeGotPltHeader(uint8_t *Buf) const {}
- virtual void writeGotPlt(uint8_t *Buf, uint64_t Plt) const {};
+ virtual void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const {};
virtual uint64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const;
// If lazy binding is supported, the first entry of the PLT has code
More information about the llvm-commits
mailing list