Skip to content

Commit c9fee5f

Browse files
committed
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. llvm-svn: 272910
1 parent afade35 commit c9fee5f

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

lld/ELF/OutputSections.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ template <class ELFT> void GotPltSection<ELFT>::writeTo(uint8_t *Buf) {
7979
Target->writeGotPltHeader(Buf);
8080
Buf += Target->GotPltHeaderEntriesNum * sizeof(uintX_t);
8181
for (const SymbolBody *B : Entries) {
82-
Target->writeGotPlt(Buf, B->getPltVA<ELFT>());
82+
Target->writeGotPlt(Buf, *B);
8383
Buf += sizeof(uintX_t);
8484
}
8585
}

lld/ELF/Target.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class X86TargetInfo final : public TargetInfo {
9191
bool isTlsLocalDynamicRel(uint32_t Type) const override;
9292
bool isTlsGlobalDynamicRel(uint32_t Type) const override;
9393
bool isTlsInitialExecRel(uint32_t Type) const override;
94-
void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
94+
void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
9595
void writePltZero(uint8_t *Buf) const override;
9696
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
9797
int32_t Index, unsigned RelOff) const override;
@@ -114,7 +114,7 @@ class X86_64TargetInfo final : public TargetInfo {
114114
bool isTlsGlobalDynamicRel(uint32_t Type) const override;
115115
bool isTlsInitialExecRel(uint32_t Type) const override;
116116
void writeGotPltHeader(uint8_t *Buf) const override;
117-
void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
117+
void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
118118
void writePltZero(uint8_t *Buf) const override;
119119
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
120120
int32_t Index, unsigned RelOff) const override;
@@ -155,7 +155,7 @@ class AArch64TargetInfo final : public TargetInfo {
155155
RelExpr getRelExpr(uint32_t Type, const SymbolBody &S) const override;
156156
uint32_t getDynRel(uint32_t Type) const override;
157157
bool isTlsInitialExecRel(uint32_t Type) const override;
158-
void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
158+
void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
159159
void writePltZero(uint8_t *Buf) const override;
160160
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
161161
int32_t Index, unsigned RelOff) const override;
@@ -181,7 +181,7 @@ class ARMTargetInfo final : public TargetInfo {
181181
RelExpr getRelExpr(uint32_t Type, const SymbolBody &S) const override;
182182
uint32_t getDynRel(uint32_t Type) const override;
183183
uint64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const override;
184-
void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
184+
void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
185185
void writePltZero(uint8_t *Buf) const override;
186186
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
187187
int32_t Index, unsigned RelOff) const override;
@@ -194,7 +194,7 @@ template <class ELFT> class MipsTargetInfo final : public TargetInfo {
194194
RelExpr getRelExpr(uint32_t Type, const SymbolBody &S) const override;
195195
uint64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const override;
196196
uint32_t getDynRel(uint32_t Type) const override;
197-
void writeGotPlt(uint8_t *Buf, uint64_t Plt) const override;
197+
void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
198198
void writePltZero(uint8_t *Buf) const override;
199199
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
200200
int32_t Index, unsigned RelOff) const override;
@@ -350,10 +350,10 @@ void X86TargetInfo::writeGotPltHeader(uint8_t *Buf) const {
350350
write32le(Buf, Out<ELF32LE>::Dynamic->getVA());
351351
}
352352

353-
void X86TargetInfo::writeGotPlt(uint8_t *Buf, uint64_t Plt) const {
353+
void X86TargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &S) const {
354354
// Entries in .got.plt initially points back to the corresponding
355355
// PLT entries with a fixed offset to skip the first instruction.
356-
write32le(Buf, Plt + 6);
356+
write32le(Buf, S.getPltVA<ELF32LE>() + 6);
357357
}
358358

359359
uint32_t X86TargetInfo::getDynRel(uint32_t Type) const {
@@ -583,9 +583,9 @@ void X86_64TargetInfo::writeGotPltHeader(uint8_t *Buf) const {
583583
write64le(Buf, Out<ELF64LE>::Dynamic->getVA());
584584
}
585585

586-
void X86_64TargetInfo::writeGotPlt(uint8_t *Buf, uint64_t Plt) const {
586+
void X86_64TargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &S) const {
587587
// See comments in X86TargetInfo::writeGotPlt.
588-
write32le(Buf, Plt + 6);
588+
write32le(Buf, S.getPltVA<ELF64LE>() + 6);
589589
}
590590

591591
void X86_64TargetInfo::writePltZero(uint8_t *Buf) const {
@@ -1203,7 +1203,7 @@ uint32_t AArch64TargetInfo::getDynRel(uint32_t Type) const {
12031203
return R_AARCH64_ABS32;
12041204
}
12051205

1206-
void AArch64TargetInfo::writeGotPlt(uint8_t *Buf, uint64_t Plt) const {
1206+
void AArch64TargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &) const {
12071207
write64le(Buf, Out<ELF64LE>::Plt->getVA());
12081208
}
12091209

@@ -1498,7 +1498,7 @@ uint32_t ARMTargetInfo::getDynRel(uint32_t Type) const {
14981498
return R_ARM_ABS32;
14991499
}
15001500

1501-
void ARMTargetInfo::writeGotPlt(uint8_t *Buf, uint64_t Plt) const {
1501+
void ARMTargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &) const {
15021502
write32le(Buf, Out<ELF32LE>::Plt->getVA());
15031503
}
15041504

@@ -1788,7 +1788,7 @@ uint32_t MipsTargetInfo<ELFT>::getDynRel(uint32_t Type) const {
17881788
}
17891789

17901790
template <class ELFT>
1791-
void MipsTargetInfo<ELFT>::writeGotPlt(uint8_t *Buf, uint64_t Plt) const {
1791+
void MipsTargetInfo<ELFT>::writeGotPlt(uint8_t *Buf, const SymbolBody &) const {
17921792
write32<ELFT::TargetEndianness>(Buf, Out<ELFT>::Plt->getVA());
17931793
}
17941794

lld/ELF/Target.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TargetInfo {
2929
virtual bool isTlsGlobalDynamicRel(uint32_t Type) const;
3030
virtual uint32_t getDynRel(uint32_t Type) const { return Type; }
3131
virtual void writeGotPltHeader(uint8_t *Buf) const {}
32-
virtual void writeGotPlt(uint8_t *Buf, uint64_t Plt) const {};
32+
virtual void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const {};
3333
virtual uint64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const;
3434

3535
// If lazy binding is supported, the first entry of the PLT has code

0 commit comments

Comments
 (0)