From fcfa9c7fcdbab22c42ef74d3975ecede5b912f6b Mon Sep 17 00:00:00 2001 From: LiaoChunyu Date: Thu, 22 Sep 2022 11:53:24 +0800 Subject: [PATCH] [RelocationResolver] Add R_RISCV_SET{16,32} Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D134408 --- llvm/lib/Object/RelocationResolver.cpp | 6 ++++++ llvm/test/MC/RISCV/cfi-advance.s | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp index e311ff4c2e9f..13a7a9851137 100644 --- a/llvm/lib/Object/RelocationResolver.cpp +++ b/llvm/lib/Object/RelocationResolver.cpp @@ -437,8 +437,10 @@ static bool supportsRISCV(uint64_t Type) { 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 @@ static uint64_t resolveRISCV(uint64_t Type, uint64_t Offset, uint64_t S, 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 index 8d11e6ec6636..b599b50692db 100644 --- 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 @@ test: .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