[Backport] readelf: Handle DW_LLE_GNU_view_pair

Signed-off-by: linzhuorong <linzhuorong@huawei.com>
This commit is contained in:
linzhuorong 2022-11-30 15:36:14 +08:00
parent 560e035d46
commit 0a1ec07570
2 changed files with 79 additions and 1 deletions

View File

@ -0,0 +1,71 @@
From 4f97f4200f0e8a535cf045d5cb48edf50d67fa17 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 20 Oct 2022 00:02:39 +0200
Subject: [PATCH] readelf: Handle DW_LLE_GNU_view_pair
DW_LLE_GNU_view_pair is used by gcc -gvariable-location-views=incompat5.
As described in http://www.fsfla.org/~lxoliva/papers/sfn/dwarf6-sfn-lvu.txt
and proposed for DWARF6 https://dwarfstd.org/ShowIssue.php?issue=170427.1
Reference:https://sourceware.org/git/?p=elfutils.git;a=commit;h=85f4c22f60c87bd2f67b241974f1b5f0f355a29b
Conflict:
libdw/ChangLog
src/ChangeLog
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
libdw/dwarf.h | 6 +++++-
src/readelf.c | 12 ++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/libdw/dwarf.h b/libdw/dwarf.h
index 19a4be9..89af5cd 100644
--- a/libdw/dwarf.h
+++ b/libdw/dwarf.h
@@ -927,7 +927,11 @@ enum
DW_LLE_GNU_end_of_list_entry = 0x0,
DW_LLE_GNU_base_address_selection_entry = 0x1,
DW_LLE_GNU_start_end_entry = 0x2,
- DW_LLE_GNU_start_length_entry = 0x3
+ DW_LLE_GNU_start_length_entry = 0x3,
+
+ // http://www.fsfla.org/~lxoliva/papers/sfn/dwarf6-sfn-lvu.txt
+ // https://dwarfstd.org/ShowIssue.php?issue=170427.1
+ DW_LLE_GNU_view_pair = 0x9
};
diff --git a/src/readelf.c b/src/readelf.c
index 9b47262..c19b0a5 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -4120,6 +4120,8 @@ dwarf_loc_list_encoding_string (unsigned int kind)
#define DWARF_ONE_KNOWN_DW_LLE(NAME, CODE) case CODE: return #NAME;
DWARF_ALL_KNOWN_DW_LLE
#undef DWARF_ONE_KNOWN_DW_LLE
+ /* DW_LLE_GNU_view_pair is special/incompatible with default codes. */
+ case DW_LLE_GNU_view_pair: return "GNU_view_pair";
default:
return NULL;
}
@@ -9514,6 +9516,16 @@ print_debug_loclists_section (Dwfl_Module *dwflmod,
readp += len;
break;
+ case DW_LLE_GNU_view_pair:
+ if ((uint64_t) (nexthdr - readp) < 1)
+ goto invalid_entry;
+ get_uleb128 (op1, readp, nexthdr);
+ if ((uint64_t) (nexthdr - readp) < 1)
+ goto invalid_entry;
+ get_uleb128 (op2, readp, nexthdr);
+ printf (" %" PRIx64 ", %" PRIx64 "\n", op1, op2);
+ break;
+
default:
goto invalid_entry;
}
--
2.27.0

View File

@ -1,7 +1,7 @@
# -*- rpm-spec from http://elfutils.org/ -*-
Name: elfutils
Version: 0.185
Release: 14
Release: 15
Summary: A collection of utilities and DSOs to handle ELF files and DWARF data
URL: http://elfutils.org/
License: GPLv3+ and (GPLv2+ or LGPLv3+)
@ -12,6 +12,7 @@ Patch1: Fix-segfault-in-eu-ar-m.patch
Patch2: Fix-error-of-parsing-object-file-perms.patch
Patch3: Fix-issue-of-moving-files-by-ar-or-br.patch
Patch4: Get-instance-correctly-for-eu-ar-N-option.patch
Patch5: backport-readelf-Handle-DW_LLE_GNU_view_pair.patch
Provides: elfutils-libelf elfutils-default-yama-scope default-yama-scope elfutils-libs
Obsoletes: elfutils-libelf < %{version}-%{release} elfutils-default-yama-scope < %{version}-%{release} elfutils-libs < %{version}-%{release}
@ -254,6 +255,12 @@ exit 0
%systemd_postun_with_restart debuginfod.service
%changelog
* Wed Nov 30 2022 linzhuorong <linzhuorong@huawei.com> - 0.185-15
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:readelf: Handle DW_LLE_GNU_view_pair
* Mon Oct 31 2022 zhangruifang <zhangruifang1@h-partners.com> - 0.185-14
- Type:bugfix
- ID:NA