summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-07-09 22:52:32 +0000
committerRui Ueyama <ruiu@google.com>2016-07-09 22:52:32 +0000
commite2efadced79abdd23f0a6b2c40880f943db56663 (patch)
treea18805f1629b73c320b8525ae91584e543084a48
parent3d2bbb13d0bd15d2dc5c7038447a398dbf40d2a9 (diff)
downloadbcm5719-llvm-e2efadced79abdd23f0a6b2c40880f943db56663.tar.gz
bcm5719-llvm-e2efadced79abdd23f0a6b2c40880f943db56663.zip
Remove Target::writeThunk.
Only MipsThunk were using the function, and the way how it wrote thunk contents was different from ARM thunks. This patch makes them consistent. llvm-svn: 274997
-rw-r--r--lld/ELF/Target.cpp14
-rw-r--r--lld/ELF/Target.h1
-rw-r--r--lld/ELF/Thunks.cpp17
3 files changed, 11 insertions, 21 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 51d18c370ba..e822904ba8f 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -200,7 +200,6 @@ public:
void writePltHeader(uint8_t *Buf) const override;
void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
int32_t Index, unsigned RelOff) const override;
- void writeThunk(uint8_t *Buf, uint64_t S) const override;
RelExpr getThunkExpr(RelExpr Expr, uint32_t RelocType,
const InputFile &File,
const SymbolBody &S) const override;
@@ -1919,19 +1918,6 @@ void MipsTargetInfo<ELFT>::writePlt(uint8_t *Buf, uint64_t GotEntryAddr,
}
template <class ELFT>
-void MipsTargetInfo<ELFT>::writeThunk(uint8_t *Buf, uint64_t S) const {
- // Write MIPS LA25 thunk code to call PIC function from the non-PIC one.
- // See MipsTargetInfo::writeThunk for details.
- const endianness E = ELFT::TargetEndianness;
- write32<E>(Buf, 0x3c190000); // lui $25, %hi(func)
- write32<E>(Buf + 4, 0x08000000 | (S >> 2)); // j func
- write32<E>(Buf + 8, 0x27390000); // addiu $25, $25, %lo(func)
- write32<E>(Buf + 12, 0x00000000); // nop
- writeMipsHi16<E>(Buf, S);
- writeMipsLo16<E>(Buf + 8, S);
-}
-
-template <class ELFT>
RelExpr MipsTargetInfo<ELFT>::getThunkExpr(RelExpr Expr, uint32_t Type,
const InputFile &File,
const SymbolBody &S) const {
diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h
index 7adbf971a5c..a5ee37d9d54 100644
--- a/lld/ELF/Target.h
+++ b/lld/ELF/Target.h
@@ -57,7 +57,6 @@ public:
virtual RelExpr getThunkExpr(RelExpr Expr, uint32_t RelocType,
const InputFile &File,
const SymbolBody &S) const;
- virtual void writeThunk(uint8_t *Buf, uint64_t S) const {}
virtual RelExpr getRelExpr(uint32_t Type, const SymbolBody &S) const = 0;
virtual void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const = 0;
virtual ~TargetInfo();
diff --git a/lld/ELF/Thunks.cpp b/lld/ELF/Thunks.cpp
index 42c21ce3fda..b5fe570c270 100644
--- a/lld/ELF/Thunks.cpp
+++ b/lld/ELF/Thunks.cpp
@@ -81,9 +81,7 @@ public:
void writeTo(uint8_t *Buf) const override;
};
-// Mips thunk.
-// Only the MIPS LA25 Thunk is supported, the implementation is delegated
-// to the MipsTargetInfo class in Target.cpp
+// MIPS LA25 thunk
template <class ELFT> class MipsThunk final : public Thunk<ELFT> {
public:
MipsThunk(const SymbolBody &Dest, const InputSection<ELFT> &Owner)
@@ -155,10 +153,17 @@ void ThumbToARMV7PILongThunk<ELFT>::writeTo(uint8_t *Buf) const {
Target->relocateOne(Buf + 4, R_ARM_THM_MOVT_PREL, S - P - 8);
}
+// Write MIPS LA25 thunk code to call PIC function from the non-PIC one.
template <class ELFT> void MipsThunk<ELFT>::writeTo(uint8_t *Buf) const {
- const SymbolBody &D = this->Destination;
- uint64_t S = D.getVA<ELFT>();
- Target->writeThunk(Buf, S);
+ const endianness E = ELFT::TargetEndianness;
+
+ uint64_t S = this->Destination.template getVA<ELFT>();
+ write32<E>(Buf, 0x3c190000); // lui $25, %hi(func)
+ write32<E>(Buf + 4, 0x08000000 | (S >> 2)); // j func
+ write32<E>(Buf + 8, 0x27390000); // addiu $25, $25, %lo(func)
+ write32<E>(Buf + 12, 0x00000000); // nop
+ Target->relocateOne(Buf, R_MIPS_HI16, S);
+ Target->relocateOne(Buf + 8, R_MIPS_LO16, S);
}
template <class ELFT>
OpenPOWER on IntegriCloud