[lld] r274997 - Remove Target::writeThunk.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 9 15:52:32 PDT 2016
Author: ruiu
Date: Sat Jul 9 17:52:32 2016
New Revision: 274997
URL: http://llvm.org/viewvc/llvm-project?rev=274997&view=rev
Log:
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.
Modified:
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Target.h
lld/trunk/ELF/Thunks.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=274997&r1=274996&r2=274997&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Sat Jul 9 17:52:32 2016
@@ -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(uint
}
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 {
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=274997&r1=274996&r2=274997&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Sat Jul 9 17:52:32 2016
@@ -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();
Modified: lld/trunk/ELF/Thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Thunks.cpp?rev=274997&r1=274996&r2=274997&view=diff
==============================================================================
--- lld/trunk/ELF/Thunks.cpp (original)
+++ lld/trunk/ELF/Thunks.cpp Sat Jul 9 17:52:32 2016
@@ -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>::writ
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>
More information about the llvm-commits
mailing list