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(
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:
#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"
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
// 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"
} // elf
} // lld
+#endif // LLD_READER_WRITER_ELF_HEXAGON_SECTION_CHUNKS_H
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) {}
header->e_flags(0x3);
}
- virtual TargetLayout<HexagonELFType> &targetLayout() {
+ virtual HexagonTargetLayout<HexagonELFType> &targetLayout() {
return _targetLayout;
}
- virtual TargetAtomHandler<HexagonELFType> &targetAtomHandler() {
+ virtual HexagonTargetAtomHandler<HexagonELFType> &targetAtomHandler() {
return _targetAtomHandler;
}
}
private:
- HexagonTargetRelocationHandler _relocationHandler;
HexagonTargetLayout<HexagonELFType> _targetLayout;
+ HexagonTargetRelocationHandler _relocationHandler;
HexagonTargetAtomHandler<HexagonELFType> _targetAtomHandler;
- HexagonRuntimeFile<HexagonELFType> _hexagonRuntimeFile;
+ HexagonRuntimeFile<HexagonELFType> _hexagonRuntimeFile;
};
} // end namespace elf
} // end namespace lld
namespace lld {
namespace elf {
+
class HexagonTargetInfo LLVM_FINAL : public ELFTargetInfo {
public:
HexagonTargetInfo(const LinkerOptions &lo) : ELFTargetInfo(lo) {