aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-08-09 10:59:20 -0700
committerGitHub <noreply@github.com>2024-08-09 10:59:20 -0700
commitedf45e4eddbc5a10cc3db4397b3b7100e8f03dcf (patch)
treecad85f5033b95026f80c0a4ca3bbb705b7a0d830 /llvm/lib/Object
parent9f3ff8d28a97379521ceb8cb29fbba5c3b487fec (diff)
downloadllvm-edf45e4eddbc5a10cc3db4397b3b7100e8f03dcf.zip
llvm-edf45e4eddbc5a10cc3db4397b3b7100e8f03dcf.tar.gz
llvm-edf45e4eddbc5a10cc3db4397b3b7100e8f03dcf.tar.bz2
Suppress spurious warnings due to R_RISCV_SET_ULEB128
llvm-objdump -S issues unnecessary warnings for RISC-V relocatable files containing .debug_loclists or .debug_rnglists sections with ULEB128 relocations. This occurred because `DWARFObjInMemory` verifies support for all relocation types, triggering warnings for unsupported ones. ``` % llvm-objdump -S a.o ... 0000000000000000 <foo>: warning: failed to compute relocation: R_RISCV_SUB_ULEB128, Invalid data was encountered while parsing the file warning: failed to compute relocation: R_RISCV_SET_ULEB128, Invalid data was encountered while parsing the file ... ``` This change fixes #101544 by declaring support for the two ULEB128 relocation types, silencing the spurious warnings. --- In DWARF v5 builds, DW_LLE_offset_pair/DW_RLE_offset_pair might be generated in .debug_loclists/.debug_rnglists with ULEB128 relocations. They are only read by llvm-dwarfdump to dump section content and verbose DW_AT_location/DW_AT_ranges output for relocatable files. The DebugInfoDWARF user (e.g. DWARFDebugRnglists.cpp) calls `Data.getULEB128` without checking the ULEB128 relocations, as the unrelocated value holds meaning (refer to the assembler implementation https://reviews.llvm.org/D157657). This differs from `.quad .Lfoo`, which requires relocation reading (e.g. https://reviews.llvm.org/D74404). Pull Request: https://github.com/llvm/llvm-project/pull/101607
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r--llvm/lib/Object/RelocationResolver.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp
index 564d9da..d9bb8f1 100644
--- a/llvm/lib/Object/RelocationResolver.cpp
+++ b/llvm/lib/Object/RelocationResolver.cpp
@@ -457,6 +457,12 @@ static bool supportsRISCV(uint64_t Type) {
case ELF::R_RISCV_SUB32:
case ELF::R_RISCV_ADD64:
case ELF::R_RISCV_SUB64:
+ // Because the unrelocated value generated by .uleb128 A-B (used by
+ // loclists/rnglists) is meaningful, DebugInfoDWARF does not inspect the
+ // relocations. We declare support for the two relocation types without an
+ // (unreachable) implementation.
+ case ELF::R_RISCV_SET_ULEB128:
+ case ELF::R_RISCV_SUB_ULEB128:
return true;
default:
return false;