aboutsummaryrefslogtreecommitdiff
path: root/ELF/InputSection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ELF/InputSection.cpp')
-rw-r--r--ELF/InputSection.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/ELF/InputSection.cpp b/ELF/InputSection.cpp
index 32fed5504..db7a69042 100644
--- a/ELF/InputSection.cpp
+++ b/ELF/InputSection.cpp
@@ -14,6 +14,7 @@
#include "InputFiles.h"
#include "OutputSections.h"
#include "Target.h"
+#include "Thunks.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Endian.h"
@@ -127,9 +128,9 @@ InputSectionBase<ELFT> *InputSection<ELFT>::getRelocatedSection() {
return Sections[this->Header->sh_info];
}
-template <class ELFT> void InputSection<ELFT>::addThunk(SymbolBody &Body) {
- Body.ThunkIndex = Thunks.size();
- Thunks.push_back(&Body);
+template <class ELFT> void
+InputSection<ELFT>::addThunk(const Thunk<ELFT>* thunk) {
+ Thunks.push_back(thunk);
}
template <class ELFT> uint64_t InputSection<ELFT>::getThunkOff() const {
@@ -137,7 +138,10 @@ template <class ELFT> uint64_t InputSection<ELFT>::getThunkOff() const {
}
template <class ELFT> uint64_t InputSection<ELFT>::getThunksSize() const {
- return Thunks.size() * Target->ThunkSize;
+ uint64_t total = 0;
+ for (const Thunk<ELFT> *T : Thunks)
+ total += T->size();
+ return total;
}
// This is used for -r. We can't use memcpy to copy relocations because we need
@@ -182,8 +186,11 @@ getSymVA(uint32_t Type, typename ELFT::uint A, typename ELFT::uint P,
Out<ELFT>::Got->getNumEntries() * sizeof(uintX_t);
case R_TLSLD_PC:
return Out<ELFT>::Got->getTlsIndexVA() + A - P;
- case R_THUNK:
- return Body.getThunkVA<ELFT>();
+ case R_THUNK_ABS:
+ return Thunks<ELFT>::X->getThunk(Body)->getVA();
+ case R_THUNK_PC:
+ case R_THUNK_PLT_PC:
+ return Thunks<ELFT>::X->getThunk(Body)->getVA() + A - P;
case R_PPC_TOC:
return getPPC64TocBase() + A;
case R_TLSGD:
@@ -403,9 +410,9 @@ template <class ELFT> void InputSection<ELFT>::writeTo(uint8_t *Buf) {
// jump istruction.
if (!Thunks.empty()) {
Buf += OutSecOff + getThunkOff();
- for (const SymbolBody *S : Thunks) {
- Target->writeThunk(Buf, S->getVA<ELFT>());
- Buf += Target->ThunkSize;
+ for (const Thunk<ELFT> * T : Thunks) {
+ T->writeTo(Buf);
+ Buf += T->size();
}
}
}