[PATCH] dwarf: Dump .debug_loclists only for DWARF-5

H.J. Lu hjl.tools@gmail.com
Fri Mar 21 15:23:56 GMT 2025


On Fri, Mar 21, 2025 at 12:28 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 20.03.2025 21:27, H.J. Lu wrote:
> > --- a/binutils/dwarf.c
> > +++ b/binutils/dwarf.c
> > @@ -7324,7 +7324,7 @@ display_debug_loc (struct dwarf_section *section, void *file)
> >    unsigned int *array = NULL;
> >    const char *suffix = strrchr (section->name, '.');
> >    bool is_dwo = false;
> > -  int is_loclists = strstr (section->name, "debug_loclists") != NULL;
> > +  bool is_loclists = strstr (section->name, "debug_loclists") != NULL;
> >    uint64_t next_header_offset = 0;
> >
> >    if (suffix && strcmp (suffix, ".dwo") == 0)
> > @@ -7450,6 +7450,11 @@ display_debug_loc (struct dwarf_section *section, void *file)
> >        debug_info *debug_info_p = debug_information + i;
> >        uint32_t offset_count;
> >
> > +      /* Dump .debug_loclists only for DWARF-5 and dump .debug_loc only
> > +      for pre-DWARF-5.  */
> > +      if ((debug_info_p->dwarf_version == 5) != is_loclists)
> > +     continue;
>
> Comment and code aren't quite in sync: What about versions above 5? Aren't our
> chances better to stay correct if, until we know otherwise, we treat higher
> versions like 5, not like 4 and earlier?

I was following

if (debug_info_p->dwarf_version == 5)

a few lines below.  I guess since DWARF-5 added .debug_loclists, we don't know
if it will be different in the future.

> Jan



-- 
H.J.


More information about the Binutils mailing list