forked from OSchip/llvm-project
[Object][RISCV] Resolve R_RISCV_32_PCREL
Summary: Add support for resolving `R_RISCV_32_PCREL` relocations. Those aren't actually resolved AFAIK, but support is still needed to avoid llvm-dwarfdump errors. The use of these relocations was introduced in D66419 but the corresponding resolving wasn't added then. The test adds a check that should catch future unresolved relocations. Reviewers: asb, lenary Reviewed By: asb Tags: #llvm Differential Revision: https://reviews.llvm.org/D70204
This commit is contained in:
parent
75434366ce
commit
7bf721e59c
|
@ -336,6 +336,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,6 +361,8 @@ 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:
|
||||
|
|
|
@ -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: 0x39 R_RISCV_SET6
|
||||
; RELAX: 0x39 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
|
||||
|
|
Loading…
Reference in New Issue