diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-07-03 14:10:23 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-07-03 14:10:23 +0000 |
| commit | 145449b1e420787bb99721a429341fa6be3adfb6 (patch) | |
| tree | 1d56ae694a6de602e348dd80165cf881a36600ed /llvm/lib/Object/RelocationResolver.cpp | |
| parent | ecbca9f5fb7d7613d2b94982c4825eb0d33d6842 (diff) | |
Diffstat (limited to 'llvm/lib/Object/RelocationResolver.cpp')
| -rw-r--r-- | llvm/lib/Object/RelocationResolver.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp index 00a45e2c5d4e..e14301663df3 100644 --- a/llvm/lib/Object/RelocationResolver.cpp +++ b/llvm/lib/Object/RelocationResolver.cpp @@ -11,6 +11,21 @@ //===----------------------------------------------------------------------===// #include "llvm/Object/RelocationResolver.h" +#include "llvm/ADT/Triple.h" +#include "llvm/ADT/Twine.h" +#include "llvm/BinaryFormat/COFF.h" +#include "llvm/BinaryFormat/ELF.h" +#include "llvm/BinaryFormat/MachO.h" +#include "llvm/BinaryFormat/Wasm.h" +#include "llvm/Object/ELFObjectFile.h" +#include "llvm/Object/ELFTypes.h" +#include "llvm/Object/ObjectFile.h" +#include "llvm/Object/SymbolicFile.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/ErrorHandling.h" +#include <cassert> +#include <vector> namespace llvm { namespace object { @@ -63,6 +78,7 @@ static bool supportsAArch64(uint64_t Type) { switch (Type) { case ELF::R_AARCH64_ABS32: case ELF::R_AARCH64_ABS64: + case ELF::R_AARCH64_PREL16: case ELF::R_AARCH64_PREL32: case ELF::R_AARCH64_PREL64: return true; @@ -78,6 +94,8 @@ static uint64_t resolveAArch64(uint64_t Type, uint64_t Offset, uint64_t S, return (S + Addend) & 0xFFFFFFFF; case ELF::R_AARCH64_ABS64: return S + Addend; + case ELF::R_AARCH64_PREL16: + return (S + Addend - Offset) & 0xFFFF; case ELF::R_AARCH64_PREL32: return (S + Addend - Offset) & 0xFFFFFFFF; case ELF::R_AARCH64_PREL64: @@ -468,6 +486,31 @@ static uint64_t resolveRISCV(uint64_t Type, uint64_t Offset, uint64_t S, } } +static bool supportsCSKY(uint64_t Type) { + switch (Type) { + case ELF::R_CKCORE_NONE: + case ELF::R_CKCORE_ADDR32: + case ELF::R_CKCORE_PCREL32: + return true; + default: + return false; + } +} + +static uint64_t resolveCSKY(uint64_t Type, uint64_t Offset, uint64_t S, + uint64_t LocData, int64_t Addend) { + switch (Type) { + case ELF::R_CKCORE_NONE: + return LocData; + case ELF::R_CKCORE_ADDR32: + return (S + Addend) & 0xFFFFFFFF; + case ELF::R_CKCORE_PCREL32: + return (S + Addend - Offset) & 0xFFFFFFFF; + default: + llvm_unreachable("Invalid relocation type"); + } +} + static bool supportsCOFFX86(uint64_t Type) { switch (Type) { case COFF::IMAGE_REL_I386_SECREL: @@ -715,6 +758,8 @@ getRelocationResolver(const ObjectFile &Obj) { return {supportsHexagon, resolveHexagon}; case Triple::riscv32: return {supportsRISCV, resolveRISCV}; + case Triple::csky: + return {supportsCSKY, resolveCSKY}; default: return {nullptr, nullptr}; } |
