[PATCH] binutils/dwarf: Don't print duplicate range list entries
Andrew Burgess
andrew.burgess@embecosm.com
Wed Apr 29 09:52:00 GMT 2020
If multiple DWARF entries reference the same offset in the
.debug_ranges section then we will currently print duplicate range
lists when dumping the range information.
This looks something like this:
Contents of the .debug_ranges section:
Offset Begin End
00000000 0000000000401160 00000000004011ca
00000000 0000000000401040 0000000000401045
00000000 <End of list>
00000030 0000000000401169 0000000000401173
00000030 0000000000401040 0000000000401045
00000030 <End of list>
00000030 0000000000401169 0000000000401173
00000030 0000000000401040 0000000000401045
00000030 <End of list>
00000070 0000000000401160 00000000004011ca
00000070 0000000000401040 0000000000401045
00000070 0000000000401050 0000000000401065
00000070 <End of list>
Notice the range of offset 0x30 is printed twice.
This patch adds some filtering when printing the ranges list, so these
duplicates are ignored. After this patch the same output as above
would look like this:
Contents of the .debug_ranges section:
Offset Begin End
00000000 0000000000401160 00000000004011ca
00000000 0000000000401040 0000000000401045
00000000 <End of list>
00000030 0000000000401169 0000000000401173
00000030 0000000000401040 0000000000401045
00000030 <End of list>
00000070 0000000000401160 00000000004011ca
00000070 0000000000401040 0000000000401045
00000070 0000000000401050 0000000000401065
00000070 <End of list>
binutils/ChangeLog:
* dwarf.c (display_debug_ranges): Ignore duplicate entries in
range_entries for the same offset.
---
binutils/ChangeLog | 5 +++++
binutils/dwarf.c | 10 ++++++++++
2 files changed, 15 insertions(+)
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index c75059bd93a..e75bfb8bf70 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -6923,6 +6923,7 @@ display_debug_ranges (struct dwarf_section *section,
int is_rnglists = strstr (section->name, "debug_rnglists") != NULL;
/* Initialize it due to a false compiler warning. */
unsigned char address_size = 0;
+ dwarf_vma last_offset = 0;
if (bytes == 0)
{
@@ -7063,6 +7064,15 @@ display_debug_ranges (struct dwarf_section *section,
next = section_begin + offset;
base_address = debug_info_p->base_address;
+ /* If multiple DWARF entities reference the same range then we will
+ have multiple entries in the `range_entries' list for the same
+ offset. Thanks to the sort above these will all be consecutive in
+ the `range_entries' list, so we can easily ignore duplicates
+ here. */
+ if (i > 0 && last_offset == offset)
+ continue;
+ last_offset = offset;
+
/* PR 17512: file: 001-101485-0.001:0.1. */
if (pointer_size < 2 || pointer_size > 8)
{
--
2.25.3
More information about the Binutils
mailing list