diff options
-rw-r--r-- | lld/ELF/OutputSections.cpp | 10 | ||||
-rw-r--r-- | lld/ELF/Symbols.cpp | 4 | ||||
-rw-r--r-- | lld/ELF/Target.cpp | 12 | ||||
-rw-r--r-- | lld/ELF/Target.h | 2 |
4 files changed, 21 insertions, 7 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index a3d228c0b22..7c7ec0a05c8 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -47,7 +47,7 @@ void OutputSectionBase<ELFT>::writeHeaderTo(Elf_Shdr *Shdr) { 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> bool GotPltSection<ELFT>::empty() const { } 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 @@ GotSection<ELFT>::GotSection() : 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> diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 85c71e301c6..0c3a116b371 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -165,7 +165,7 @@ template <class ELFT> typename ELFT::uint SymbolBody::getGotVA() const { } template <class ELFT> typename ELFT::uint SymbolBody::getGotOffset() const { - return GotIndex * sizeof(typename ELFT::uint); + return GotIndex * Target->GotEntrySize; } template <class ELFT> typename ELFT::uint SymbolBody::getGotPltVA() const { @@ -173,7 +173,7 @@ template <class ELFT> typename ELFT::uint SymbolBody::getGotPltVA() const { } template <class ELFT> typename ELFT::uint SymbolBody::getGotPltOffset() const { - return GotPltIndex * sizeof(typename ELFT::uint); + return GotPltIndex * Target->GotPltEntrySize; } template <class ELFT> typename ELFT::uint SymbolBody::getPltVA() const { diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 8e520fbfaf1..6908d8ffe3f 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -308,6 +308,8 @@ X86TargetInfo::X86TargetInfo() { TlsGotRel = R_386_TLS_TPOFF; TlsModuleIndexRel = R_386_TLS_DTPMOD32; TlsOffsetRel = R_386_TLS_DTPOFF32; + GotEntrySize = 4; + GotPltEntrySize = 4; PltEntrySize = 16; PltHeaderSize = 16; TlsGdRelaxSkip = 2; @@ -551,6 +553,8 @@ template <class ELFT> X86_64TargetInfo<ELFT>::X86_64TargetInfo() { TlsGotRel = R_X86_64_TPOFF64; TlsModuleIndexRel = R_X86_64_DTPMOD64; TlsOffsetRel = R_X86_64_DTPOFF64; + GotEntrySize = 8; + GotPltEntrySize = 8; PltEntrySize = 16; PltHeaderSize = 16; TlsGdRelaxSkip = 2; @@ -976,6 +980,8 @@ RelExpr PPCTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const { PPC64TargetInfo::PPC64TargetInfo() { PltRel = GotRel = R_PPC64_GLOB_DAT; RelativeRel = R_PPC64_RELATIVE; + GotEntrySize = 8; + GotPltEntrySize = 8; PltEntrySize = 32; PltHeaderSize = 0; @@ -1140,6 +1146,8 @@ AArch64TargetInfo::AArch64TargetInfo() { PltRel = R_AARCH64_JUMP_SLOT; TlsDescRel = R_AARCH64_TLSDESC; TlsGotRel = R_AARCH64_TLS_TPREL64; + GotEntrySize = 8; + GotPltEntrySize = 8; PltEntrySize = 16; PltHeaderSize = 32; @@ -1480,6 +1488,8 @@ ARMTargetInfo::ARMTargetInfo() { TlsGotRel = R_ARM_TLS_TPOFF32; TlsModuleIndexRel = R_ARM_TLS_DTPMOD32; TlsOffsetRel = R_ARM_TLS_DTPOFF32; + GotEntrySize = 4; + GotPltEntrySize = 4; PltEntrySize = 16; PltHeaderSize = 20; } @@ -1787,6 +1797,8 @@ uint64_t ARMTargetInfo::getImplicitAddend(const uint8_t *Buf, template <class ELFT> MipsTargetInfo<ELFT>::MipsTargetInfo() { GotPltHeaderEntriesNum = 2; PageSize = 65536; + GotEntrySize = sizeof(typename ELFT::uint); + GotPltEntrySize = sizeof(typename ELFT::uint); PltEntrySize = 16; PltHeaderSize = 32; CopyRel = R_MIPS_COPY; diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h index c1efb20c38d..df4ceb17c98 100644 --- a/lld/ELF/Target.h +++ b/lld/ELF/Target.h @@ -81,6 +81,8 @@ public: uint32_t TlsGotRel; uint32_t TlsModuleIndexRel; uint32_t TlsOffsetRel; + unsigned GotEntrySize; + unsigned GotPltEntrySize; unsigned PltEntrySize; unsigned PltHeaderSize; |