diff options
| author | Shankar Easwaran <shankare@codeaurora.org> | 2013-02-28 20:54:03 +0000 |
|---|---|---|
| committer | Shankar Easwaran <shankare@codeaurora.org> | 2013-02-28 20:54:03 +0000 |
| commit | da288955975c07d8f59ecb8ec3c15c2948d2f514 (patch) | |
| tree | e9b2dd8ba3c3b846e76e14175b0f62f7ae2ca979 | |
| parent | 0ac16d539c14fea155f8d61d499d5ac5244403ba (diff) | |
| download | bcm5719-llvm-da288955975c07d8f59ecb8ec3c15c2948d2f514.tar.gz bcm5719-llvm-da288955975c07d8f59ecb8ec3c15c2948d2f514.zip | |
[ELF][Hexagon] add quickdata relocations
llvm-svn: 176298
6 files changed, 54 insertions, 15 deletions
diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp index 97f63a2acc1..3792475217e 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp @@ -107,6 +107,20 @@ int relocHex_N_X(uint8_t *location, uint64_t P, uint64_t S, uint64_t A) { return 0; } +// GP REL relocations +int relocHexGPRELN(uint8_t *location, uint64_t P, uint64_t S, uint64_t A, + uint64_t GP, int nShiftBits) { + int32_t result = (int64_t)((S + A - GP) >> nShiftBits); + int32_t range = 1L << 16; + if (result <= range) { + result = lld::scatterBits<uint32_t>(result, FINDV4BITMASK(location)); + *reinterpret_cast<llvm::support::ulittle32_t *>(location) = + result | + (uint32_t) * reinterpret_cast<llvm::support::ulittle32_t *>(location); + return 0; + } + return 1; +} } // end anon namespace ErrorOr<void> HexagonTargetRelocationHandler::applyRelocation( @@ -157,6 +171,22 @@ ErrorOr<void> HexagonTargetRelocationHandler::applyRelocation( case R_HEX_B7_PCREL_X: relocHexBNPCRELX(location, relocVAddress, targetVAddress, ref.addend(), 6); break; + case R_HEX_GPREL16_0: + relocHexGPRELN(location, relocVAddress, targetVAddress, ref.addend(), + _targetLayout.getSDataSection()->virtualAddr(), 0); + break; + case R_HEX_GPREL16_1: + relocHexGPRELN(location, relocVAddress, targetVAddress, ref.addend(), + _targetLayout.getSDataSection()->virtualAddr(), 1); + break; + case R_HEX_GPREL16_2: + relocHexGPRELN(location, relocVAddress, targetVAddress, ref.addend(), + _targetLayout.getSDataSection()->virtualAddr(), 2); + break; + case R_HEX_GPREL16_3: + relocHexGPRELN(location, relocVAddress, targetVAddress, ref.addend(), + _targetLayout.getSDataSection()->virtualAddr(), 3); + break; case R_HEX_16_X: case R_HEX_12_X: case R_HEX_11_X: diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h index d1757cfd1d0..2894e5b8e85 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.h @@ -9,6 +9,7 @@ #ifndef LLD_READER_WRITER_ELF_HEXAGON_RELOCATION_HANDLER_H #define LLD_READER_WRITER_ELF_HEXAGON_RELOCATION_HANDLER_H +#include "HexagonSectionChunks.h" #include "HexagonTargetHandler.h" #include "lld/ReaderWriter/RelocationHelperFunctions.h" @@ -17,19 +18,23 @@ namespace elf { typedef llvm::object::ELFType<llvm::support::little, 4, false> HexagonELFType; class HexagonTargetInfo; +class HexagonTargetHandler; +template <class HexagonELFType> class HexagonTargetLayout; -class HexagonTargetRelocationHandler LLVM_FINAL - : public TargetRelocationHandler<HexagonELFType> { +class HexagonTargetRelocationHandler LLVM_FINAL : + public TargetRelocationHandler<HexagonELFType> { public: - HexagonTargetRelocationHandler(const HexagonTargetInfo &ti) : _targetInfo(ti) - {} - - virtual ErrorOr<void> applyRelocation(ELFWriter &, llvm::FileOutputBuffer &, - const AtomLayout &, - const Reference &)const; + HexagonTargetRelocationHandler( + const HexagonTargetInfo &ti, + const HexagonTargetLayout<HexagonELFType> &layout) + : _targetInfo(ti), _targetLayout(layout) {} + virtual ErrorOr<void> + applyRelocation(ELFWriter &, llvm::FileOutputBuffer &, const AtomLayout &, + const Reference &) const; private: const HexagonTargetInfo &_targetInfo; + const HexagonTargetLayout<HexagonELFType> &_targetLayout; }; } // elf } // lld diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h index 4bbe3b698e7..19911481c30 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h @@ -6,6 +6,8 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +#ifndef LLD_READER_WRITER_ELF_HEXAGON_SECTION_CHUNKS_H +#define LLD_READER_WRITER_ELF_HEXAGON_SECTION_CHUNKS_H #include "HexagonTargetHandler.h" @@ -75,3 +77,4 @@ void SDataSection<HexagonELFType>::doPreFlight() { } // elf } // lld +#endif // LLD_READER_WRITER_ELF_HEXAGON_SECTION_CHUNKS_H diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp index c998a34b6ac..d7ea9cb364f 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp @@ -16,6 +16,6 @@ using namespace elf; using namespace llvm::ELF; HexagonTargetHandler::HexagonTargetHandler(HexagonTargetInfo &targetInfo) - : DefaultTargetHandler(targetInfo), _relocationHandler(targetInfo), - _targetLayout(targetInfo), _hexagonRuntimeFile(targetInfo) { -} + : DefaultTargetHandler(targetInfo), _targetLayout(targetInfo), + _relocationHandler(targetInfo, _targetLayout), + _hexagonRuntimeFile(targetInfo) {} diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h index 03726df07b6..ff8278dea92 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h @@ -156,11 +156,11 @@ public: header->e_flags(0x3); } - virtual TargetLayout<HexagonELFType> &targetLayout() { + virtual HexagonTargetLayout<HexagonELFType> &targetLayout() { return _targetLayout; } - virtual TargetAtomHandler<HexagonELFType> &targetAtomHandler() { + virtual HexagonTargetAtomHandler<HexagonELFType> &targetAtomHandler() { return _targetAtomHandler; } @@ -184,10 +184,10 @@ public: } private: - HexagonTargetRelocationHandler _relocationHandler; HexagonTargetLayout<HexagonELFType> _targetLayout; + HexagonTargetRelocationHandler _relocationHandler; HexagonTargetAtomHandler<HexagonELFType> _targetAtomHandler; - HexagonRuntimeFile<HexagonELFType> _hexagonRuntimeFile; + HexagonRuntimeFile<HexagonELFType> _hexagonRuntimeFile; }; } // end namespace elf } // end namespace lld diff --git a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetInfo.h b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetInfo.h index e5a84ff580a..bf25b504f66 100644 --- a/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetInfo.h +++ b/lld/lib/ReaderWriter/ELF/Hexagon/HexagonTargetInfo.h @@ -20,6 +20,7 @@ namespace lld { namespace elf { + class HexagonTargetInfo LLVM_FINAL : public ELFTargetInfo { public: HexagonTargetInfo(const LinkerOptions &lo) : ELFTargetInfo(lo) { |

