[RelocationResolver] Add R_RISCV_SET8
authorLiaoChunyu <chunyu@iscas.ac.cn>
Wed, 21 Sep 2022 13:46:11 +0000 (21:46 +0800)
committerLiaoChunyu <chunyu@iscas.ac.cn>
Thu, 22 Sep 2022 03:49:33 +0000 (11:49 +0800)
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D134164

llvm/lib/Object/RelocationResolver.cpp
llvm/test/MC/RISCV/cfi-advance.s [new file with mode: 0644]

index d172605..e311ff4 100644 (file)
@@ -433,6 +433,7 @@ static bool supportsRISCV(uint64_t Type) {
   case ELF::R_RISCV_32_PCREL:
   case ELF::R_RISCV_64:
   case ELF::R_RISCV_SET6:
+  case ELF::R_RISCV_SET8:
   case ELF::R_RISCV_SUB6:
   case ELF::R_RISCV_ADD8:
   case ELF::R_RISCV_SUB8:
@@ -465,6 +466,8 @@ static uint64_t resolveRISCV(uint64_t Type, uint64_t Offset, uint64_t S,
     return (A & 0xC0) | ((S + RA) & 0x3F);
   case ELF::R_RISCV_SUB6:
     return (A & 0xC0) | (((A & 0x3F) - (S + RA)) & 0x3F);
+  case ELF::R_RISCV_SET8:
+    return (S + RA) & 0xFF;
   case ELF::R_RISCV_ADD8:
     return (A + (S + RA)) & 0xFF;
   case ELF::R_RISCV_SUB8:
diff --git a/llvm/test/MC/RISCV/cfi-advance.s b/llvm/test/MC/RISCV/cfi-advance.s
new file mode 100644 (file)
index 0000000..8d11e6e
--- /dev/null
@@ -0,0 +1,19 @@
+# RUN: llvm-mc -filetype=obj -triple riscv32 %s -o %t.o  
+# RUN: llvm-readobj -r %t.o | FileCheck -check-prefix=CHECK %s
+# RUN: llvm-dwarfdump --debug-frame %t.o 2>&1 \
+# 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
+        .text
+        .globl  test                            # -- Begin function test
+        .p2align        1
+        .type   test,@function
+test:
+        .cfi_startproc
+        nop
+        .zero 100, 0x90
+        .cfi_def_cfa_offset 8
+        nop
+        .cfi_endproc