Skip to content

Commit 4a90f57

Browse files
committed
Rename PltZero -> PltHeader.
PltZero (or PLT[0]) was an appropriate name for the little code we have at beginning of the PLT section when we only supported x86 since the code for x86 just fits in the first PLT slot. It's not the case anymore. The code for ARM64 occupies first two slots, so PltZero spans PLT[0] and PLT[1], for example. This patch renames it to avoid confusion. llvm-svn: 272913
1 parent 87f0d0e commit 4a90f57

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

lld/ELF/OutputSections.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ PltSection<ELFT>::PltSection()
275275
template <class ELFT> void PltSection<ELFT>::writeTo(uint8_t *Buf) {
276276
// At beginning of PLT, we have code to call the dynamic linker
277277
// to resolve dynsyms at runtime. Write such code.
278-
Target->writePltZero(Buf);
279-
size_t Off = Target->PltZeroSize;
278+
Target->writePltHeader(Buf);
279+
size_t Off = Target->PltHeaderSize;
280280

281281
for (auto &I : Entries) {
282282
const SymbolBody *B = I.first;
@@ -296,7 +296,7 @@ template <class ELFT> void PltSection<ELFT>::addEntry(SymbolBody &Sym) {
296296

297297
template <class ELFT> void PltSection<ELFT>::finalize() {
298298
this->Header.sh_size =
299-
Target->PltZeroSize + Entries.size() * Target->PltEntrySize;
299+
Target->PltHeaderSize + Entries.size() * Target->PltEntrySize;
300300
}
301301

302302
template <class ELFT>

lld/ELF/Symbols.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ template <class ELFT> typename ELFT::uint SymbolBody::getGotPltOffset() const {
162162
}
163163

164164
template <class ELFT> typename ELFT::uint SymbolBody::getPltVA() const {
165-
return Out<ELFT>::Plt->getVA() + Target->PltZeroSize +
165+
return Out<ELFT>::Plt->getVA() + Target->PltHeaderSize +
166166
PltIndex * Target->PltEntrySize;
167167
}
168168

lld/ELF/Target.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class X86TargetInfo final : public TargetInfo {
9292
bool isTlsGlobalDynamicRel(uint32_t Type) const override;
9393
bool isTlsInitialExecRel(uint32_t Type) const override;
9494
void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
95-
void writePltZero(uint8_t *Buf) const override;
95+
void writePltHeader(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;
9898
void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
@@ -115,7 +115,7 @@ class X86_64TargetInfo final : public TargetInfo {
115115
bool isTlsInitialExecRel(uint32_t Type) const override;
116116
void writeGotPltHeader(uint8_t *Buf) const override;
117117
void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
118-
void writePltZero(uint8_t *Buf) const override;
118+
void writePltHeader(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;
121121
void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
@@ -156,7 +156,7 @@ class AArch64TargetInfo final : public TargetInfo {
156156
uint32_t getDynRel(uint32_t Type) const override;
157157
bool isTlsInitialExecRel(uint32_t Type) const override;
158158
void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
159-
void writePltZero(uint8_t *Buf) const override;
159+
void writePltHeader(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;
162162
bool usesOnlyLowPageBits(uint32_t Type) const override;
@@ -182,7 +182,7 @@ class ARMTargetInfo final : public TargetInfo {
182182
uint32_t getDynRel(uint32_t Type) const override;
183183
uint64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const override;
184184
void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
185-
void writePltZero(uint8_t *Buf) const override;
185+
void writePltHeader(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;
188188
void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
@@ -195,7 +195,7 @@ template <class ELFT> class MipsTargetInfo final : public TargetInfo {
195195
uint64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const override;
196196
uint32_t getDynRel(uint32_t Type) const override;
197197
void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
198-
void writePltZero(uint8_t *Buf) const override;
198+
void writePltHeader(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;
201201
void writeThunk(uint8_t *Buf, uint64_t S) const override;
@@ -302,7 +302,7 @@ X86TargetInfo::X86TargetInfo() {
302302
TlsModuleIndexRel = R_386_TLS_DTPMOD32;
303303
TlsOffsetRel = R_386_TLS_DTPOFF32;
304304
PltEntrySize = 16;
305-
PltZeroSize = 16;
305+
PltHeaderSize = 16;
306306
TlsGdRelaxSkip = 2;
307307
}
308308

@@ -376,7 +376,7 @@ bool X86TargetInfo::isTlsInitialExecRel(uint32_t Type) const {
376376
return Type == R_386_TLS_IE || Type == R_386_TLS_GOTIE;
377377
}
378378

379-
void X86TargetInfo::writePltZero(uint8_t *Buf) const {
379+
void X86TargetInfo::writePltHeader(uint8_t *Buf) const {
380380
// Executable files and shared object files have
381381
// separate procedure linkage tables.
382382
if (Config->Pic) {
@@ -415,7 +415,7 @@ void X86TargetInfo::writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
415415
uint32_t Got = Out<ELF32LE>::GotPlt->getVA();
416416
write32le(Buf + 2, Config->Shared ? GotEntryAddr - Got : GotEntryAddr);
417417
write32le(Buf + 7, RelOff);
418-
write32le(Buf + 12, -Index * PltEntrySize - PltZeroSize - 16);
418+
write32le(Buf + 12, -Index * PltEntrySize - PltHeaderSize - 16);
419419
}
420420

421421
uint64_t X86TargetInfo::getImplicitAddend(const uint8_t *Buf,
@@ -543,7 +543,7 @@ X86_64TargetInfo::X86_64TargetInfo() {
543543
TlsModuleIndexRel = R_X86_64_DTPMOD64;
544544
TlsOffsetRel = R_X86_64_DTPOFF64;
545545
PltEntrySize = 16;
546-
PltZeroSize = 16;
546+
PltHeaderSize = 16;
547547
TlsGdRelaxSkip = 2;
548548
}
549549

@@ -588,7 +588,7 @@ void X86_64TargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &S) const {
588588
write32le(Buf, S.getPltVA<ELF64LE>() + 6);
589589
}
590590

591-
void X86_64TargetInfo::writePltZero(uint8_t *Buf) const {
591+
void X86_64TargetInfo::writePltHeader(uint8_t *Buf) const {
592592
const uint8_t PltData[] = {
593593
0xff, 0x35, 0x00, 0x00, 0x00, 0x00, // pushq GOT+8(%rip)
594594
0xff, 0x25, 0x00, 0x00, 0x00, 0x00, // jmp *GOT+16(%rip)
@@ -613,7 +613,7 @@ void X86_64TargetInfo::writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
613613

614614
write32le(Buf + 2, GotEntryAddr - PltEntryAddr - 6);
615615
write32le(Buf + 7, Index);
616-
write32le(Buf + 12, -Index * PltEntrySize - PltZeroSize - 16);
616+
write32le(Buf + 12, -Index * PltEntrySize - PltHeaderSize - 16);
617617
}
618618

619619
uint32_t X86_64TargetInfo::getDynRel(uint32_t Type) const {
@@ -1113,7 +1113,7 @@ AArch64TargetInfo::AArch64TargetInfo() {
11131113
TlsDescRel = R_AARCH64_TLSDESC;
11141114
TlsGotRel = R_AARCH64_TLS_TPREL64;
11151115
PltEntrySize = 16;
1116-
PltZeroSize = 32;
1116+
PltHeaderSize = 32;
11171117

11181118
// It doesn't seem to be documented anywhere, but tls on aarch64 uses variant
11191119
// 1 of the tls structures and the tcb size is 16.
@@ -1211,7 +1211,7 @@ static uint64_t getAArch64Page(uint64_t Expr) {
12111211
return Expr & (~static_cast<uint64_t>(0xFFF));
12121212
}
12131213

1214-
void AArch64TargetInfo::writePltZero(uint8_t *Buf) const {
1214+
void AArch64TargetInfo::writePltHeader(uint8_t *Buf) const {
12151215
const uint8_t PltData[] = {
12161216
0xf0, 0x7b, 0xbf, 0xa9, // stp x16, x30, [sp,#-16]!
12171217
0x10, 0x00, 0x00, 0x90, // adrp x16, Page(&(.plt.got[2]))
@@ -1453,7 +1453,7 @@ ARMTargetInfo::ARMTargetInfo() {
14531453
TlsModuleIndexRel = R_ARM_TLS_DTPMOD32;
14541454
TlsOffsetRel = R_ARM_TLS_DTPOFF32;
14551455
PltEntrySize = 16;
1456-
PltZeroSize = 20;
1456+
PltHeaderSize = 20;
14571457
}
14581458

14591459
RelExpr ARMTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const {
@@ -1502,7 +1502,7 @@ void ARMTargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &) const {
15021502
write32le(Buf, Out<ELF32LE>::Plt->getVA());
15031503
}
15041504

1505-
void ARMTargetInfo::writePltZero(uint8_t *Buf) const {
1505+
void ARMTargetInfo::writePltHeader(uint8_t *Buf) const {
15061506
const uint8_t PltData[] = {
15071507
0x04, 0xe0, 0x2d, 0xe5, // str lr, [sp,#-4]!
15081508
0x04, 0xe0, 0x9f, 0xe5, // ldr lr, L2
@@ -1720,7 +1720,7 @@ template <class ELFT> MipsTargetInfo<ELFT>::MipsTargetInfo() {
17201720
GotPltHeaderEntriesNum = 2;
17211721
PageSize = 65536;
17221722
PltEntrySize = 16;
1723-
PltZeroSize = 32;
1723+
PltHeaderSize = 32;
17241724
ThunkSize = 16;
17251725
CopyRel = R_MIPS_COPY;
17261726
PltRel = R_MIPS_JUMP_SLOT;
@@ -1828,7 +1828,7 @@ template <endianness E> static int16_t readSignedLo16(const uint8_t *Loc) {
18281828
}
18291829

18301830
template <class ELFT>
1831-
void MipsTargetInfo<ELFT>::writePltZero(uint8_t *Buf) const {
1831+
void MipsTargetInfo<ELFT>::writePltHeader(uint8_t *Buf) const {
18321832
const endianness E = ELFT::TargetEndianness;
18331833
write32<E>(Buf, 0x3c1c0000); // lui $28, %hi(&GOTPLT[0])
18341834
write32<E>(Buf + 4, 0x8f990000); // lw $25, %lo(&GOTPLT[0])($28)

lld/ELF/Target.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class TargetInfo {
3535
// If lazy binding is supported, the first entry of the PLT has code
3636
// to call the dynamic linker to resolve PLT entries the first time
3737
// they are called. This function writes that code.
38-
virtual void writePltZero(uint8_t *Buf) const {}
38+
virtual void writePltHeader(uint8_t *Buf) const {}
3939

4040
virtual void writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
4141
uint64_t PltEntryAddr, int32_t Index,
@@ -78,7 +78,7 @@ class TargetInfo {
7878
uint32_t TlsModuleIndexRel;
7979
uint32_t TlsOffsetRel;
8080
unsigned PltEntrySize = 8;
81-
unsigned PltZeroSize = 0;
81+
unsigned PltHeaderSize = 0;
8282

8383
// At least on x86_64 positions 1 and 2 are used by the first plt entry
8484
// to support lazy loading.

0 commit comments

Comments
 (0)