[PATCH] D132019: [Object] Support LoongArch in RelocationResolver
Lu Weining via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 25 21:10:21 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0ce24da0e134: [Object] Support LoongArch in RelocationResolver (authored by WANG Xuerui <git at xen0n.name>, committed by SixWeining).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132019/new/
https://reviews.llvm.org/D132019
Files:
llvm/lib/Object/RelocationResolver.cpp
Index: llvm/lib/Object/RelocationResolver.cpp
===================================================================
--- llvm/lib/Object/RelocationResolver.cpp
+++ llvm/lib/Object/RelocationResolver.cpp
@@ -511,6 +511,58 @@
}
}
+static bool supportsLoongArch(uint64_t Type) {
+ switch (Type) {
+ case ELF::R_LARCH_NONE:
+ case ELF::R_LARCH_32:
+ case ELF::R_LARCH_32_PCREL:
+ case ELF::R_LARCH_64:
+ case ELF::R_LARCH_ADD8:
+ case ELF::R_LARCH_SUB8:
+ case ELF::R_LARCH_ADD16:
+ case ELF::R_LARCH_SUB16:
+ case ELF::R_LARCH_ADD32:
+ case ELF::R_LARCH_SUB32:
+ case ELF::R_LARCH_ADD64:
+ case ELF::R_LARCH_SUB64:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static uint64_t resolveLoongArch(uint64_t Type, uint64_t Offset, uint64_t S,
+ uint64_t LocData, int64_t Addend) {
+ switch (Type) {
+ case ELF::R_LARCH_NONE:
+ return LocData;
+ case ELF::R_LARCH_32:
+ return (S + Addend) & 0xFFFFFFFF;
+ case ELF::R_LARCH_32_PCREL:
+ return (S + Addend - Offset) & 0xFFFFFFFF;
+ case ELF::R_LARCH_64:
+ return S + Addend;
+ case ELF::R_LARCH_ADD8:
+ return (LocData + (S + Addend)) & 0xFF;
+ case ELF::R_LARCH_SUB8:
+ return (LocData - (S + Addend)) & 0xFF;
+ case ELF::R_LARCH_ADD16:
+ return (LocData + (S + Addend)) & 0xFFFF;
+ case ELF::R_LARCH_SUB16:
+ return (LocData - (S + Addend)) & 0xFFFF;
+ case ELF::R_LARCH_ADD32:
+ return (LocData + (S + Addend)) & 0xFFFFFFFF;
+ case ELF::R_LARCH_SUB32:
+ return (LocData - (S + Addend)) & 0xFFFFFFFF;
+ case ELF::R_LARCH_ADD64:
+ return (LocData + (S + Addend));
+ case ELF::R_LARCH_SUB64:
+ return (LocData - (S + Addend));
+ default:
+ llvm_unreachable("Invalid relocation type");
+ }
+}
+
static bool supportsCOFFX86(uint64_t Type) {
switch (Type) {
case COFF::IMAGE_REL_I386_SECREL:
@@ -711,6 +763,8 @@
case Triple::bpfel:
case Triple::bpfeb:
return {supportsBPF, resolveBPF};
+ case Triple::loongarch64:
+ return {supportsLoongArch, resolveLoongArch};
case Triple::mips64el:
case Triple::mips64:
return {supportsMips64, resolveMips64};
@@ -747,6 +801,8 @@
return {supportsAVR, resolveAVR};
case Triple::lanai:
return {supportsLanai, resolveLanai};
+ case Triple::loongarch32:
+ return {supportsLoongArch, resolveLoongArch};
case Triple::mipsel:
case Triple::mips:
return {supportsMips32, resolveMips32};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132019.455788.patch
Type: text/x-patch
Size: 2476 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220826/afec7df4/attachment.bin>
More information about the llvm-commits
mailing list