[PATCH] D70204: [DWARF][RISCV] Resolve R_RISCV_32_PCREL
Luís Marques via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 13 12:38:06 PST 2019
luismarques created this revision.
luismarques added reviewers: asb, lenary.
Herald added subscribers: llvm-commits, sameer.abuasal, pzheng, s.egerton, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar, hiraditya, aprantl.
Herald added a project: LLVM.
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 <https://reviews.llvm.org/D66419> but the corresponding resolving wasn't added then*. The test adds a check that should catch future unresolved relocations.
*I would blame the reviewer, but it turns out that person was me, so he's exculpated.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D70204
Files:
llvm/lib/Object/RelocationResolver.cpp
llvm/test/DebugInfo/RISCV/relax-debug-frame.ll
Index: llvm/test/DebugInfo/RISCV/relax-debug-frame.ll
===================================================================
--- llvm/test/DebugInfo/RISCV/relax-debug-frame.ll
+++ 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
Index: llvm/lib/Object/RelocationResolver.cpp
===================================================================
--- llvm/lib/Object/RelocationResolver.cpp
+++ 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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70204.229158.patch
Type: text/x-patch
Size: 1523 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191113/c593a71b/attachment-0001.bin>
More information about the llvm-commits
mailing list