+2023-08-23 Nick Clifton <nickc@redhat.com>
+
+ PR 30791
+ * dwarf.h (debug_info): Add range_versions field.
+ * dwarf.c (read_and_display_attr_value): When recording a range
+ arribute also ecord the dwarf version number.
+ (is_range_list_for_this_section): New function.
+ (display_debug_ranges): Only show debug ranges whose version is
+ suitable for the secction being displayed.
+
2023-07-30 Jose E. Marchesi <jose.marchesi@oracle.com>
* readelf.c (get_machine_flags): Recognize and pretty print BPF
debug_info_p->range_lists = (uint64_t *)
xcrealloc (debug_info_p->range_lists,
lmax, sizeof (*debug_info_p->range_lists));
+ debug_info_p->range_versions = (unsigned int *)
+ xcrealloc (debug_info_p->range_versions,
+ lmax, sizeof (*debug_info_p->range_versions));
debug_info_p->max_range_lists = lmax;
}
uvalue = fetch_indexed_value (uvalue, rnglists, 0);
debug_info_p->range_lists [num] = uvalue;
+ debug_info_p->range_versions [num] = dwarf_version;
debug_info_p->num_range_lists++;
}
break;
return 1;
}
+static bool
+is_range_list_for_this_section (bool is_rnglists, unsigned int version)
+{
+ if (is_rnglists && version > 4)
+ return true;
+
+ if (! is_rnglists && version < 5)
+ return true;
+
+ return false;
+}
+
static int
display_debug_ranges (struct dwarf_section *section,
void *file ATTRIBUTE_UNUSED)
unsigned int num_range_list, i;
struct range_entry *range_entries;
struct range_entry *range_entry_fill;
- int is_rnglists = strstr (section->name, "debug_rnglists") != NULL;
+ bool is_rnglists = strstr (section->name, "debug_rnglists") != NULL;
/* Initialize it due to a false compiler warning. */
unsigned char address_size = 0;
uint64_t last_offset = 0;
{
/* This can happen when the file was compiled with -gsplit-debug
which removes references to range lists from the primary .o file. */
- printf (_("No range lists in .debug_info section.\n"));
+ printf (_("No range lists referenced by .debug_info section.\n"));
return 1;
}
for (j = 0; j < debug_info_p->num_range_lists; j++)
{
- range_entry_fill->ranges_offset = debug_info_p->range_lists[j];
- range_entry_fill->debug_info_p = debug_info_p;
- range_entry_fill++;
+ if (is_range_list_for_this_section (is_rnglists, debug_info_p->range_versions[j]))
+ {
+ range_entry_fill->ranges_offset = debug_info_p->range_lists[j];
+ range_entry_fill->debug_info_p = debug_info_p;
+ range_entry_fill++;
+ }
}
}
+ num_range_list = range_entry_fill - range_entries;
qsort (range_entries, num_range_list, sizeof (*range_entries),
range_entry_compar);