Skip to content

Commit e98baf8

Browse files
committedMay 31, 2019
[ELF] Delete GotEntrySize and GotPltEntrySize
GotEntrySize and GotPltEntrySize were added in D22288. Later, with the introduction of wordsize() (then Config->Wordsize), they become redundant, because there is no target that sets GotEntrySize or GotPltEntrySize to a number different from Config->Wordsize. Reviewed By: grimar, ruiu Differential Revision: https://reviews.llvm.org/D62727 llvm-svn: 362220
1 parent 802c9b5 commit e98baf8

12 files changed

+14
-35
lines changed
 

‎lld/ELF/Arch/AArch64.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ AArch64::AArch64() {
6161
PltRel = R_AARCH64_JUMP_SLOT;
6262
TlsDescRel = R_AARCH64_TLSDESC;
6363
TlsGotRel = R_AARCH64_TLS_TPREL64;
64-
GotEntrySize = 8;
65-
GotPltEntrySize = 8;
6664
PltEntrySize = 16;
6765
PltHeaderSize = 32;
6866
DefaultMaxPageSize = 65536;

‎lld/ELF/Arch/AMDGPU.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ AMDGPU::AMDGPU() {
3535
RelativeRel = R_AMDGPU_RELATIVE64;
3636
GotRel = R_AMDGPU_ABS64;
3737
NoneRel = R_AMDGPU_NONE;
38-
GotEntrySize = 8;
3938
}
4039

4140
static uint32_t getEFlags(InputFile *File) {

‎lld/ELF/Arch/ARM.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ ARM::ARM() {
5656
TlsModuleIndexRel = R_ARM_TLS_DTPMOD32;
5757
TlsOffsetRel = R_ARM_TLS_DTPOFF32;
5858
GotBaseSymInGotPlt = false;
59-
GotEntrySize = 4;
60-
GotPltEntrySize = 4;
6159
PltEntrySize = 16;
6260
PltHeaderSize = 32;
6361
TrapInstr = {0xd4, 0xd4, 0xd4, 0xd4};

‎lld/ELF/Arch/Hexagon.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ Hexagon::Hexagon() {
4040
PltRel = R_HEX_JMP_SLOT;
4141
RelativeRel = R_HEX_RELATIVE;
4242
GotRel = R_HEX_GLOB_DAT;
43-
GotEntrySize = 4;
43+
4444
// The zero'th GOT entry is reserved for the address of _DYNAMIC. The
4545
// next 3 are reserved for the dynamic loader.
4646
GotPltHeaderEntriesNum = 4;
47-
GotPltEntrySize = 4;
4847

4948
PltEntrySize = 16;
5049
PltHeaderSize = 32;

‎lld/ELF/Arch/Mips.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ template <class ELFT> class MIPS final : public TargetInfo {
4646
template <class ELFT> MIPS<ELFT>::MIPS() {
4747
GotPltHeaderEntriesNum = 2;
4848
DefaultMaxPageSize = 65536;
49-
GotEntrySize = sizeof(typename ELFT::uint);
50-
GotPltEntrySize = sizeof(typename ELFT::uint);
5149
GotBaseSymInGotPlt = false;
5250
PltEntrySize = 16;
5351
PltHeaderSize = 32;

‎lld/ELF/Arch/PPC64.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,7 @@ PPC64::PPC64() {
288288
PltRel = R_PPC64_JMP_SLOT;
289289
RelativeRel = R_PPC64_RELATIVE;
290290
IRelativeRel = R_PPC64_IRELATIVE;
291-
GotEntrySize = 8;
292291
PltEntrySize = 4;
293-
GotPltEntrySize = 8;
294292
GotBaseSymInGotPlt = false;
295293
GotHeaderEntriesNum = 1;
296294
GotPltHeaderEntriesNum = 2;

‎lld/ELF/Arch/SPARCV9.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ SPARCV9::SPARCV9() {
3737
NoneRel = R_SPARC_NONE;
3838
PltRel = R_SPARC_JMP_SLOT;
3939
RelativeRel = R_SPARC_RELATIVE;
40-
GotEntrySize = 8;
4140
PltEntrySize = 32;
4241
PltHeaderSize = 4 * PltEntrySize;
4342

‎lld/ELF/Arch/X86.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ X86::X86() {
5555
TlsGotRel = R_386_TLS_TPOFF;
5656
TlsModuleIndexRel = R_386_TLS_DTPMOD32;
5757
TlsOffsetRel = R_386_TLS_DTPOFF32;
58-
GotEntrySize = 4;
59-
GotPltEntrySize = 4;
6058
PltEntrySize = 16;
6159
PltHeaderSize = 16;
6260
TrapInstr = {0xcc, 0xcc, 0xcc, 0xcc}; // 0xcc = INT3

‎lld/ELF/Arch/X86_64.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ X86_64::X86_64() {
5959
TlsGotRel = R_X86_64_TPOFF64;
6060
TlsModuleIndexRel = R_X86_64_DTPMOD64;
6161
TlsOffsetRel = R_X86_64_DTPOFF64;
62-
GotEntrySize = 8;
63-
GotPltEntrySize = 8;
6462
PltEntrySize = 16;
6563
PltHeaderSize = 16;
6664
TrapInstr = {0xcc, 0xcc, 0xcc, 0xcc}; // 0xcc = INT3

‎lld/ELF/Symbols.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ uint64_t Symbol::getGotVA() const {
136136
return In.Got->getVA() + getGotOffset();
137137
}
138138

139-
uint64_t Symbol::getGotOffset() const {
140-
return GotIndex * Target->GotEntrySize;
141-
}
139+
uint64_t Symbol::getGotOffset() const { return GotIndex * Config->Wordsize; }
142140

143141
uint64_t Symbol::getGotPltVA() const {
144142
if (IsInIplt)
@@ -148,13 +146,13 @@ uint64_t Symbol::getGotPltVA() const {
148146

149147
uint64_t Symbol::getGotPltOffset() const {
150148
if (IsInIplt)
151-
return PltIndex * Target->GotPltEntrySize;
152-
return (PltIndex + Target->GotPltHeaderEntriesNum) * Target->GotPltEntrySize;
149+
return PltIndex * Config->Wordsize;
150+
return (PltIndex + Target->GotPltHeaderEntriesNum) * Config->Wordsize;
153151
}
154152

155153
uint64_t Symbol::getPPC64LongBranchOffset() const {
156154
assert(PPC64BranchltIndex != 0xffff);
157-
return PPC64BranchltIndex * Target->GotPltEntrySize;
155+
return PPC64BranchltIndex * Config->Wordsize;
158156
}
159157

160158
uint64_t Symbol::getPltVA() const {
@@ -172,7 +170,7 @@ uint64_t Symbol::getPltVA() const {
172170
uint64_t Symbol::getPPC64LongBranchTableVA() const {
173171
assert(PPC64BranchltIndex != 0xffff);
174172
return In.PPC64LongBranchTarget->getVA() +
175-
PPC64BranchltIndex * Target->GotPltEntrySize;
173+
PPC64BranchltIndex * Config->Wordsize;
176174
}
177175

178176
uint64_t Symbol::getSize() const {

‎lld/ELF/SyntheticSections.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ void EhFrameSection::writeTo(uint8_t *Buf) {
542542
}
543543

544544
GotSection::GotSection()
545-
: SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
546-
Target->GotEntrySize, ".got") {
545+
: SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS, Config->Wordsize,
546+
".got") {
547547
// PPC64 saves the ElfSym::GlobalOffsetTable .TOC. as the first entry in the
548548
// .got. If there are no references to .TOC. in the symbol table,
549549
// ElfSym::GlobalOffsetTable will not be defined and we won't need to save
@@ -1030,7 +1030,7 @@ void MipsGotSection::writeTo(uint8_t *Buf) {
10301030
GotPltSection::GotPltSection()
10311031
: SyntheticSection(SHF_ALLOC | SHF_WRITE,
10321032
Config->EMachine == EM_PPC64 ? SHT_NOBITS : SHT_PROGBITS,
1033-
Target->GotPltEntrySize,
1033+
Config->Wordsize,
10341034
Config->EMachine == EM_PPC64 ? ".plt" : ".got.plt") {}
10351035

10361036
void GotPltSection::addEntry(Symbol &Sym) {
@@ -1039,13 +1039,12 @@ void GotPltSection::addEntry(Symbol &Sym) {
10391039
}
10401040

10411041
size_t GotPltSection::getSize() const {
1042-
return (Target->GotPltHeaderEntriesNum + Entries.size()) *
1043-
Target->GotPltEntrySize;
1042+
return (Target->GotPltHeaderEntriesNum + Entries.size()) * Config->Wordsize;
10441043
}
10451044

10461045
void GotPltSection::writeTo(uint8_t *Buf) {
10471046
Target->writeGotPltHeader(Buf);
1048-
Buf += Target->GotPltHeaderEntriesNum * Target->GotPltEntrySize;
1047+
Buf += Target->GotPltHeaderEntriesNum * Config->Wordsize;
10491048
for (const Symbol *B : Entries) {
10501049
Target->writeGotPlt(Buf, *B);
10511050
Buf += Config->Wordsize;
@@ -1076,15 +1075,15 @@ static StringRef getIgotPltName() {
10761075
IgotPltSection::IgotPltSection()
10771076
: SyntheticSection(SHF_ALLOC | SHF_WRITE,
10781077
Config->EMachine == EM_PPC64 ? SHT_NOBITS : SHT_PROGBITS,
1079-
Target->GotPltEntrySize, getIgotPltName()) {}
1078+
Config->Wordsize, getIgotPltName()) {}
10801079

10811080
void IgotPltSection::addEntry(Symbol &Sym) {
10821081
assert(Sym.PltIndex == Entries.size());
10831082
Entries.push_back(&Sym);
10841083
}
10851084

10861085
size_t IgotPltSection::getSize() const {
1087-
return Entries.size() * Target->GotPltEntrySize;
1086+
return Entries.size() * Config->Wordsize;
10881087
}
10891088

10901089
void IgotPltSection::writeTo(uint8_t *Buf) {
@@ -3228,7 +3227,6 @@ size_t PPC64LongBranchTargetSection::getSize() const {
32283227
}
32293228

32303229
void PPC64LongBranchTargetSection::writeTo(uint8_t *Buf) {
3231-
assert(Target->GotPltEntrySize == 8);
32323230
// If linking non-pic we have the final addresses of the targets and they get
32333231
// written to the table directly. For pic the dynamic linker will allocate
32343232
// the section and fill it it.
@@ -3241,7 +3239,7 @@ void PPC64LongBranchTargetSection::writeTo(uint8_t *Buf) {
32413239
// must be a local-call.
32423240
write64(Buf,
32433241
Sym->getVA() + getPPC64GlobalEntryToLocalEntryOffset(Sym->StOther));
3244-
Buf += Target->GotPltEntrySize;
3242+
Buf += 8;
32453243
}
32463244
}
32473245

‎lld/ELF/Target.h

-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ class TargetInfo {
9999
RelType TlsGotRel;
100100
RelType TlsModuleIndexRel;
101101
RelType TlsOffsetRel;
102-
unsigned GotEntrySize = 0;
103-
unsigned GotPltEntrySize = 0;
104102
unsigned PltEntrySize;
105103
unsigned PltHeaderSize;
106104

0 commit comments

Comments
 (0)
Please sign in to comment.