diff options
Diffstat (limited to 'llvm/lib/Object/RelocationResolver.cpp')
-rw-r--r-- | llvm/lib/Object/RelocationResolver.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp index ca89f5671b8a..31478be7899e 100644 --- a/llvm/lib/Object/RelocationResolver.cpp +++ b/llvm/lib/Object/RelocationResolver.cpp @@ -105,6 +105,7 @@ static bool supportsMips64(uint64_t Type) { case ELF::R_MIPS_32: case ELF::R_MIPS_64: case ELF::R_MIPS_TLS_DTPREL64: + case ELF::R_MIPS_PC32: return true; default: return false; @@ -119,6 +120,8 @@ static uint64_t resolveMips64(RelocationRef R, uint64_t S, uint64_t A) { return S + getELFAddend(R); case ELF::R_MIPS_TLS_DTPREL64: return S + getELFAddend(R) - 0x8000; + case ELF::R_MIPS_PC32: + return S + getELFAddend(R) - R.getOffset(); default: llvm_unreachable("Invalid relocation type"); } @@ -336,6 +339,7 @@ static bool supportsRISCV(uint64_t Type) { switch (Type) { case ELF::R_RISCV_NONE: case ELF::R_RISCV_32: + case ELF::R_RISCV_32_PCREL: case ELF::R_RISCV_64: case ELF::R_RISCV_SET6: case ELF::R_RISCV_SUB6: @@ -360,12 +364,14 @@ static uint64_t resolveRISCV(RelocationRef R, uint64_t S, uint64_t A) { return A; case ELF::R_RISCV_32: return (S + RA) & 0xFFFFFFFF; + case ELF::R_RISCV_32_PCREL: + return (S + RA - R.getOffset()) & 0xFFFFFFFF; case ELF::R_RISCV_64: return S + RA; case ELF::R_RISCV_SET6: - return (A + (S + RA)) & 0xFF; + return (A & 0xC0) | ((S + RA) & 0x3F); case ELF::R_RISCV_SUB6: - return (A - (S + RA)) & 0xFF; + return (A & 0xC0) | (((A & 0x3F) - (S + RA)) & 0x3F); case ELF::R_RISCV_ADD8: return (A + (S + RA)) & 0xFF; case ELF::R_RISCV_SUB8: |