Add GotEntrySize/GotPltEntrySize to ELF target.
Patch by H.J Lu.
For x86-64 psABI, the entry size of .got and .got.plt sections is 8
bytes for both LP64 and ILP32. Add GotEntrySize and GotPltEntrySize
to ELF target instead of using size of ELFT::uint. Now we can generate
a simple working x32 executable.
Differential Revision: http://reviews.llvm.org/D22288
llvm-svn: 275301
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index a3d228c..7c7ec0a 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -47,7 +47,7 @@
template <class ELFT>
GotPltSection<ELFT>::GotPltSection()
: OutputSectionBase<ELFT>(".got.plt", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE) {
- this->Header.sh_addralign = sizeof(uintX_t);
+ this->Header.sh_addralign = Target->GotPltEntrySize;
}
template <class ELFT> void GotPltSection<ELFT>::addEntry(SymbolBody &Sym) {
@@ -60,13 +60,13 @@
}
template <class ELFT> void GotPltSection<ELFT>::finalize() {
- this->Header.sh_size =
- (Target->GotPltHeaderEntriesNum + Entries.size()) * sizeof(uintX_t);
+ this->Header.sh_size = (Target->GotPltHeaderEntriesNum + Entries.size()) *
+ Target->GotPltEntrySize;
}
template <class ELFT> void GotPltSection<ELFT>::writeTo(uint8_t *Buf) {
Target->writeGotPltHeader(Buf);
- Buf += Target->GotPltHeaderEntriesNum * sizeof(uintX_t);
+ Buf += Target->GotPltHeaderEntriesNum * Target->GotPltEntrySize;
for (const SymbolBody *B : Entries) {
Target->writeGotPlt(Buf, *B);
Buf += sizeof(uintX_t);
@@ -78,7 +78,7 @@
: OutputSectionBase<ELFT>(".got", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE) {
if (Config->EMachine == EM_MIPS)
this->Header.sh_flags |= SHF_MIPS_GPREL;
- this->Header.sh_addralign = sizeof(uintX_t);
+ this->Header.sh_addralign = Target->GotEntrySize;
}
template <class ELFT>