[PATCH] D14703: [ELF2] Remove target specific code from GotPltSection.
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 16 09:46:45 PST 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253239: [ELF2] Remove target specific code from GotPltSection. (authored by ikudrin).
Changed prior to commit:
http://reviews.llvm.org/D14703?vs=40282&id=40308#toc
Repository:
rL LLVM
http://reviews.llvm.org/D14703
Files:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Target.h
Index: lld/trunk/ELF/OutputSections.cpp
===================================================================
--- lld/trunk/ELF/OutputSections.cpp
+++ lld/trunk/ELF/OutputSections.cpp
@@ -35,17 +35,15 @@
: OutputSectionBase<ELFT>(".got.plt", llvm::ELF::SHT_PROGBITS,
llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE) {
this->Header.sh_addralign = sizeof(uintX_t);
- // .got.plt has 3 reserved entry
- Entries.resize(3);
}
template <class ELFT> void GotPltSection<ELFT>::addEntry(SymbolBody *Sym) {
- Sym->GotPltIndex = Entries.size();
+ Sym->GotPltIndex = Target->getGotPltHeaderEntriesNum() + Entries.size();
Entries.push_back(Sym);
}
template <class ELFT> bool GotPltSection<ELFT>::empty() const {
- return Entries.size() == 3;
+ return Entries.empty();
}
template <class ELFT>
@@ -55,15 +53,15 @@
}
template <class ELFT> void GotPltSection<ELFT>::finalize() {
- this->Header.sh_size = Entries.size() * sizeof(uintX_t);
+ this->Header.sh_size =
+ (Target->getGotPltHeaderEntriesNum() + Entries.size()) * sizeof(uintX_t);
}
template <class ELFT> void GotPltSection<ELFT>::writeTo(uint8_t *Buf) {
- write<uintX_t, ELFT::TargetEndianness, sizeof(uintX_t)>(
- Buf, Out<ELFT>::Dynamic->getVA());
+ Target->writeGotPltHeaderEntries(Buf);
+ Buf += Target->getGotPltHeaderEntriesNum() * sizeof(uintX_t);
for (const SymbolBody *B : Entries) {
- if (B)
- Target->writeGotPltEntry(Buf, Out<ELFT>::Plt->getEntryAddr(*B));
+ Target->writeGotPltEntry(Buf, Out<ELFT>::Plt->getEntryAddr(*B));
Buf += sizeof(uintX_t);
}
}
Index: lld/trunk/ELF/Target.h
===================================================================
--- lld/trunk/ELF/Target.h
+++ lld/trunk/ELF/Target.h
@@ -43,8 +43,10 @@
unsigned getPltEntrySize() const { return PltEntrySize; }
bool supportsLazyRelocations() const { return LazyRelocations; }
unsigned getGotHeaderEntriesNum() const { return GotHeaderEntriesNum; }
+ unsigned getGotPltHeaderEntriesNum() const { return GotPltHeaderEntriesNum; }
virtual unsigned getPLTRefReloc(unsigned Type) const;
virtual void writeGotHeaderEntries(uint8_t *Buf) const;
+ virtual void writeGotPltHeaderEntries(uint8_t *Buf) const;
virtual void writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const = 0;
virtual void writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,
uint64_t PltEntryAddr) const = 0;
@@ -86,6 +88,7 @@
unsigned PltEntrySize = 8;
unsigned PltZeroEntrySize = 0;
unsigned GotHeaderEntriesNum = 0;
+ unsigned GotPltHeaderEntriesNum = 3;
bool LazyRelocations = false;
};
Index: lld/trunk/ELF/Target.cpp
===================================================================
--- lld/trunk/ELF/Target.cpp
+++ lld/trunk/ELF/Target.cpp
@@ -62,6 +62,7 @@
public:
X86_64TargetInfo();
unsigned getPLTRefReloc(unsigned Type) const override;
+ void writeGotPltHeaderEntries(uint8_t *Buf) const override;
void writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const override;
void writePltZeroEntry(uint8_t *Buf, uint64_t GotEntryAddr,
uint64_t PltEntryAddr) const override;
@@ -159,6 +160,8 @@
void TargetInfo::writeGotHeaderEntries(uint8_t *Buf) const {}
+void TargetInfo::writeGotPltHeaderEntries(uint8_t *Buf) const {}
+
X86TargetInfo::X86TargetInfo() {
PCRelReloc = R_386_PC32;
GotReloc = R_386_GLOB_DAT;
@@ -226,6 +229,10 @@
PltZeroEntrySize = 16;
}
+void X86_64TargetInfo::writeGotPltHeaderEntries(uint8_t *Buf) const {
+ write64le(Buf, Out<ELF64LE>::Dynamic->getVA());
+}
+
void X86_64TargetInfo::writeGotPltEntry(uint8_t *Buf, uint64_t Plt) const {
// Skip 6 bytes of "jmpq *got(%rip)"
write32le(Buf, Plt + 6);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14703.40308.patch
Type: text/x-patch
Size: 3746 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151116/13352707/attachment.bin>
More information about the llvm-commits
mailing list