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 @@ -437,8 +437,10 @@ case ELF::R_RISCV_SUB6: case ELF::R_RISCV_ADD8: case ELF::R_RISCV_SUB8: + case ELF::R_RISCV_SET16: case ELF::R_RISCV_ADD16: case ELF::R_RISCV_SUB16: + case ELF::R_RISCV_SET32: case ELF::R_RISCV_ADD32: case ELF::R_RISCV_SUB32: case ELF::R_RISCV_ADD64: @@ -472,10 +474,14 @@ return (A + (S + RA)) & 0xFF; case ELF::R_RISCV_SUB8: return (A - (S + RA)) & 0xFF; + case ELF::R_RISCV_SET16: + return (S + RA) & 0xFFFF; case ELF::R_RISCV_ADD16: return (A + (S + RA)) & 0xFFFF; case ELF::R_RISCV_SUB16: return (A - (S + RA)) & 0xFFFF; + case ELF::R_RISCV_SET32: + return (S + RA) & 0xFFFFFFFF; case ELF::R_RISCV_ADD32: return (A + (S + RA)) & 0xFFFFFFFF; case ELF::R_RISCV_SUB32: diff --git a/llvm/test/MC/RISCV/cfi-advance.s b/llvm/test/MC/RISCV/cfi-advance.s --- a/llvm/test/MC/RISCV/cfi-advance.s +++ b/llvm/test/MC/RISCV/cfi-advance.s @@ -4,8 +4,16 @@ # RUN: | FileCheck -check-prefix=CHECK-DWARFDUMP %s # CHECK: 0x26 R_RISCV_SET8 - 0x0 -# CHECK-DWARFDUMP: DW_CFA_advance_loc1 -# CHECK-DWARFDUMP-NEXT: DW_CFA_def_cfa_offset +# CHECK-NEXT: 0x26 R_RISCV_SUB8 - 0x0 +# CHECK-NEXT: 0x2A R_RISCV_SET16 - 0x0 +# CHECK-NEXT: 0x2A R_RISCV_SUB16 - 0x0 +# CHECK-NEXT: 0x2F R_RISCV_SET32 - 0x0 +# CHECK-DWARFDUMP: DW_CFA_advance_loc1 +# CHECK-DWARFDUMP-NEXT: DW_CFA_def_cfa_offset +# CHECK-DWARFDUMP-NEXT: DW_CFA_advance_loc2 +# CHECK-DWARFDUMP-NEXT: DW_CFA_def_cfa_offset +# CHECK-DWARFDUMP-NEXT: DW_CFA_advance_loc4 +# CHECK-DWARFDUMP-NEXT: DW_CFA_def_cfa_offset .text .globl test # -- Begin function test .p2align 1 @@ -16,4 +24,10 @@ .zero 100, 0x90 .cfi_def_cfa_offset 8 nop + .zero 255, 0x90 + .cfi_def_cfa_offset 8 + nop + .zero 65535, 0x90 + .cfi_def_cfa_offset 8 + nop .cfi_endproc