From d93e1dfac8711cfed1a9d9cd1876a788b83945cd Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 2 Jan 2017 19:19:15 +0000 Subject: Vendor import of lld trunk r290819: https://llvm.org/svn/llvm-project/lld/trunk@290819 --- ELF/Thunks.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'ELF/Thunks.cpp') diff --git a/ELF/Thunks.cpp b/ELF/Thunks.cpp index 1ebbb17f30325..34b630ac25106 100644 --- a/ELF/Thunks.cpp +++ b/ELF/Thunks.cpp @@ -22,17 +22,20 @@ //===---------------------------------------------------------------------===// #include "Thunks.h" +#include "Config.h" #include "Error.h" -#include "InputFiles.h" #include "InputSection.h" +#include "Memory.h" #include "OutputSections.h" #include "Symbols.h" #include "Target.h" -#include "llvm/Support/Allocator.h" - -#include "llvm/Object/ELF.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/ELF.h" #include "llvm/Support/Endian.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/MathExtras.h" +#include +#include using namespace llvm; using namespace llvm::object; @@ -43,6 +46,7 @@ namespace lld { namespace elf { namespace { + // Specific ARM Thunk implementations. The naming convention is: // Source State, TargetState, Target Requirement, ABS or PI, Range template @@ -96,11 +100,13 @@ public: uint32_t size() const override { return 16; } void writeTo(uint8_t *Buf) const override; }; -} // anonymous namespace + +} // end anonymous namespace // ARM Target Thunks template static uint64_t getARMThunkDestVA(const SymbolBody &S) { - return S.isInPlt() ? S.getPltVA() : S.getVA(); + uint64_t V = S.isInPlt() ? S.getPltVA() : S.getVA(); + return SignExtend64<32>(V); } template @@ -177,10 +183,10 @@ Thunk::Thunk(const SymbolBody &D, const InputSection &O) : Destination(D), Owner(O), Offset(O.getThunkOff() + O.getThunksSize()) {} template typename ELFT::uint Thunk::getVA() const { - return Owner.OutSec->getVA() + Owner.OutSecOff + Offset; + return Owner.OutSec->Addr + Owner.OutSecOff + Offset; } -template Thunk::~Thunk() {} +template Thunk::~Thunk() = default; // Creates a thunk for Thumb-ARM interworking. template @@ -189,19 +195,18 @@ static Thunk *createThunkArm(uint32_t Reloc, SymbolBody &S, // ARM relocations need ARM to Thumb interworking Thunks. // Thumb relocations need Thumb to ARM relocations. // Use position independent Thunks if we require position independent code. - BumpPtrAllocator &Alloc = IS.getFile()->Alloc; switch (Reloc) { case R_ARM_PC24: case R_ARM_PLT32: case R_ARM_JUMP24: if (Config->Pic) - return new (Alloc) ARMToThumbV7PILongThunk(S, IS); - return new (Alloc) ARMToThumbV7ABSLongThunk(S, IS); + return new (BAlloc) ARMToThumbV7PILongThunk(S, IS); + return new (BAlloc) ARMToThumbV7ABSLongThunk(S, IS); case R_ARM_THM_JUMP19: case R_ARM_THM_JUMP24: if (Config->Pic) - return new (Alloc) ThumbToARMV7PILongThunk(S, IS); - return new (Alloc) ThumbToARMV7ABSLongThunk(S, IS); + return new (BAlloc) ThumbToARMV7PILongThunk(S, IS); + return new (BAlloc) ThumbToARMV7ABSLongThunk(S, IS); } fatal("unrecognized relocation type"); } @@ -235,7 +240,7 @@ static void addThunkMips(uint32_t RelocType, SymbolBody &S, // Mips Thunks are added to the InputSection defining S. auto *R = cast>(&S); auto *Sec = cast>(R->Section); - auto *T = new (IS.getFile()->Alloc) MipsThunk(S, *Sec); + auto *T = new (BAlloc) MipsThunk(S, *Sec); Sec->addThunk(T); R->ThunkData = T; } @@ -264,5 +269,5 @@ template class Thunk; template class Thunk; template class Thunk; -} // namespace elf -} // namespace lld +} // end namespace elf +} // end namespace lld -- cgit v1.3