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 @@ -347,6 +347,7 @@ case ELF::R_RISCV_SUB32: case ELF::R_RISCV_ADD64: case ELF::R_RISCV_SUB64: + case ELF::R_RISCV_32_PCREL: return true; default: return false; @@ -360,6 +361,8 @@ 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: diff --git a/llvm/test/DebugInfo/RISCV/relax-debug-frame.ll b/llvm/test/DebugInfo/RISCV/relax-debug-frame.ll --- a/llvm/test/DebugInfo/RISCV/relax-debug-frame.ll +++ b/llvm/test/DebugInfo/RISCV/relax-debug-frame.ll @@ -1,7 +1,7 @@ ; RUN: llc -filetype=obj -mtriple=riscv32 -mattr=+relax %s -o - \ ; RUN: | llvm-readobj -r | FileCheck -check-prefix=RELAX %s ; RUN: llc -filetype=obj -mtriple=riscv32 -mattr=+relax %s -o - \ -; RUN: | llvm-dwarfdump --debug-frame - \ +; RUN: | llvm-dwarfdump --debug-frame - 2>&1 \ ; RUN: | FileCheck -check-prefix=RELAX-DWARFDUMP %s ; ; RELAX: Section{{.*}}.rela.{{eh|debug}}_frame { @@ -15,6 +15,7 @@ ; RELAX: 0x25 R_RISCV_SET6 ; RELAX: 0x25 R_RISCV_SUB6 ; +; RELAX-DWARFDUMP-NOT: error: failed to compute relocation ; RELAX-DWARFDUMP: CIE ; RELAX-DWARFDUMP: DW_CFA_advance_loc ; RELAX-DWARFDUMP: DW_CFA_def_cfa_offset