Message ID | 20210209144637.GA17212@delia |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
On 2/9/21 3:46 PM, Tom de Vries wrote: > Hi, > > With exec: > ... > $ g++ src/gdb/testsuite/gdb.cp/cpexprs.cc -gdwarf-5 -fdebug-types-section > ... > I run into: > ... > $ readelf -w a.out > READELF > readelf: Error: Invalid range list entry type 126 > readelf: Error: Invalid range list entry type 60 > ... > > The problem is that the is_rnglists test in display_debug_ranges fails, > because the section name is prefixed with a dot: > ... > (gdb) p section->name > $3 = 0x4f4ad4 ".debug_rnglists" > ... > and the comparison is done using a string without such a prefix: > ... > int is_rnglists = strstr (section->name, "debug_rnglists") != NULL; > ... > > Fix this by adding the missing dot prefix in the comparison. > > OK for trunk? > Sorry, while the patch is not incorrect, it doesn't yet fix the errors, there's more to fix it seems. Thanks, - Tom > > [binutils] Fix debug_rnglists test in display_debug_ranges > > binutils/ChangeLog: > > 2021-02-09 Tom de Vries <tdevries@suse.de> > > PR binutils/27371 > * dwarf.c (display_debug_ranges): Fix is_rnglists test. > > --- > binutils/dwarf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/binutils/dwarf.c b/binutils/dwarf.c > index d6eb8926dbf..9fc040555b4 100644 > --- a/binutils/dwarf.c > +++ b/binutils/dwarf.c > @@ -7581,7 +7581,7 @@ display_debug_ranges (struct dwarf_section *section, > unsigned char *finish = start + bytes; > unsigned int num_range_list, i; > struct range_entry *range_entries, *range_entry_fill; > - int is_rnglists = strstr (section->name, "debug_rnglists") != NULL; > + 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; >
On 2/9/21 4:12 PM, Tom de Vries wrote: > On 2/9/21 3:46 PM, Tom de Vries wrote: >> Hi, >> >> With exec: >> ... >> $ g++ src/gdb/testsuite/gdb.cp/cpexprs.cc -gdwarf-5 -fdebug-types-section >> ... >> I run into: >> ... >> $ readelf -w a.out > READELF >> readelf: Error: Invalid range list entry type 126 >> readelf: Error: Invalid range list entry type 60 >> ... >> >> The problem is that the is_rnglists test in display_debug_ranges fails, >> because the section name is prefixed with a dot: >> ... >> (gdb) p section->name >> $3 = 0x4f4ad4 ".debug_rnglists" >> ... >> and the comparison is done using a string without such a prefix: >> ... >> int is_rnglists = strstr (section->name, "debug_rnglists") != NULL; >> ... >> >> Fix this by adding the missing dot prefix in the comparison. >> >> OK for trunk? >> > > Sorry, while the patch is not incorrect, it doesn't yet fix the errors, > there's more to fix it seems. > Updated patch, which fixes the errors. OK for trunk? Thanks, - Tom [binutils] Fix debug_rnglists test in display_debug_ranges With exec: ... $ g++ src/gdb/testsuite/gdb.cp/cpexprs.cc -gdwarf-5 -fdebug-types-section ... I run into: ... $ readelf -w a.out > READELF readelf: Error: Invalid range list entry type 126 readelf: Error: Invalid range list entry type 60 ... The problem is that the is_rnglists test in display_debug_ranges fails, because the section name is prefixed with a dot: ... (gdb) p section->name $3 = 0x4f4ad4 ".debug_rnglists" ... and the comparison is done using a string without such a prefix: ... int is_rnglists = strstr (section->name, "debug_rnglists") != NULL; ... Furthermore, the executable contains both a .debug_rnglists section (for CU cpexprs.cc) and a .debug_ranges section (for other CUs, like crti.S). But when executing display_debug_ranges for say, section .debug_rnglists it also tries to use the range list references related to section .debug_ranges. Fix these issues by: - adding the missing dot prefix in the comparison. - filtering out the .debug_range references when handling .debug_rnglists and vice versa. binutils/ChangeLog: 2021-02-09 Tom de Vries <tdevries@suse.de> PR binutils/27371 * dwarf.c (display_debug_ranges): Fix is_rnglists test. Filter range lists according to section. --- binutils/dwarf.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/binutils/dwarf.c b/binutils/dwarf.c index d6eb8926dbf..32d249e633e 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -7581,7 +7581,7 @@ display_debug_ranges (struct dwarf_section *section, unsigned char *finish = start + bytes; unsigned int num_range_list, i; struct range_entry *range_entries, *range_entry_fill; - int is_rnglists = strstr (section->name, "debug_rnglists") != NULL; + 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; @@ -7673,7 +7673,15 @@ display_debug_ranges (struct dwarf_section *section, num_range_list = 0; for (i = 0; i < num_debug_info_entries; i++) - num_range_list += debug_information [i].num_range_lists; + { + if (debug_information [i].dwarf_version < 5 && is_rnglists) + /* Skip .debug_rnglists reference. */ + continue; + if (debug_information [i].dwarf_version >= 5 && !is_rnglists) + /* Skip .debug_range reference. */ + continue; + num_range_list += debug_information [i].num_range_lists; + } if (num_range_list == 0) { @@ -7692,6 +7700,13 @@ display_debug_ranges (struct dwarf_section *section, debug_info *debug_info_p = &debug_information[i]; unsigned int j; + if (debug_information [i].dwarf_version < 5 && is_rnglists) + /* Skip .debug_rnglists reference. */ + continue; + if (debug_information [i].dwarf_version >= 5 && !is_rnglists) + /* Skip .debug_range reference. */ + continue; + for (j = 0; j < debug_info_p->num_range_lists; j++) { range_entry_fill->ranges_offset = debug_info_p->range_lists[j];
On Tue, Feb 09, 2021 at 05:56:54PM +0100, Tom de Vries wrote: > --- a/binutils/dwarf.c > +++ b/binutils/dwarf.c > @@ -7581,7 +7581,7 @@ display_debug_ranges (struct dwarf_section *section, > unsigned char *finish = start + bytes; > unsigned int num_range_list, i; > struct range_entry *range_entries, *range_entry_fill; > - int is_rnglists = strstr (section->name, "debug_rnglists") != NULL; > + 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; I must be having a slow brain day, but I don't see what the above is doing besides making .zdebug_rnglists not match. Isn't the whole point of using strstr here to allow the compressed section prefix? -- Alan Modra Australia Development Lab, IBM
diff --git a/binutils/dwarf.c b/binutils/dwarf.c index d6eb8926dbf..9fc040555b4 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -7581,7 +7581,7 @@ display_debug_ranges (struct dwarf_section *section, unsigned char *finish = start + bytes; unsigned int num_range_list, i; struct range_entry *range_entries, *range_entry_fill; - int is_rnglists = strstr (section->name, "debug_rnglists") != NULL; + 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;