diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp --- a/llvm/lib/Object/RelocationResolver.cpp +++ b/llvm/lib/Object/RelocationResolver.cpp @@ -539,6 +539,9 @@ case ELF::R_LARCH_32: case ELF::R_LARCH_32_PCREL: case ELF::R_LARCH_64: + case ELF::R_LARCH_64_PCREL: + case ELF::R_LARCH_ADD6: + case ELF::R_LARCH_SUB6: case ELF::R_LARCH_ADD8: case ELF::R_LARCH_SUB8: case ELF::R_LARCH_ADD16: @@ -548,6 +551,11 @@ case ELF::R_LARCH_ADD64: case ELF::R_LARCH_SUB64: return true; + case ELF::R_LARCH_ADD_ULEB128: + case ELF::R_LARCH_SUB_ULEB128: + // TODO: Cannot be supported with the current API: LEB128 requires a + // stream for I/O. + return false; default: return false; } @@ -564,6 +572,12 @@ return (S + Addend - Offset) & 0xFFFFFFFF; case ELF::R_LARCH_64: return S + Addend; + case ELF::R_LARCH_64_PCREL: + return S + Addend - Offset; + case ELF::R_LARCH_ADD6: + return (LocData & 0xC0) | (((LocData & 0x3F) + (S + Addend)) & 0x3F); + case ELF::R_LARCH_SUB6: + return (LocData & 0xC0) | (((LocData & 0x3F) - (S + Addend)) & 0x3F); case ELF::R_LARCH_ADD8: return (LocData + (S + Addend)) & 0xFF; case ELF::R_LARCH_SUB8: @@ -880,8 +894,10 @@ if (GetRelSectionType() == ELF::SHT_RELA) { Addend = getELFAddend(R); - // RISCV relocations use both LocData and Addend. - if (Obj->getArch() != Triple::riscv32 && + // LoongArch and RISCV relocations use both LocData and Addend. + if (Obj->getArch() != Triple::loongarch32 && + Obj->getArch() != Triple::loongarch64 && + Obj->getArch() != Triple::riscv32 && Obj->getArch() != Triple::riscv64) LocData = 0; }