[PATCH v2] DWARF: Check version >= 3 for DW_FORM_ref_addr

H.J. Lu hjl.tools@gmail.com
Thu Mar 18 13:14:02 GMT 2021


On Wed, Mar 17, 2021 at 11:14 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Wed, Mar 17, 2021 at 09:25:51PM -0700, H.J. Lu via Binutils wrote:
> > --- a/bfd/dwarf2.c
> > +++ b/bfd/dwarf2.c
> > @@ -3420,10 +3420,14 @@ scan_unit_for_symbols (struct comp_unit *unit)
> >         /* Avoid multiple reports of the same missing abbrev.  */
> >         if (abbrev_number != previous_failed_abbrev)
> >           {
> > -           _bfd_error_handler
> > -             (_("DWARF error: could not find abbrev number %u"),
> > -              abbrev_number);
> > +           /* NB: DWARF5 may have references to other CUs.  */
> > +           if (unit->version < 5)
> > +             _bfd_error_handler
> > +               (_("DWARF error: could not find abbrev number %u"),
> > +                abbrev_number);
> >             previous_failed_abbrev = abbrev_number;
> > +           if (unit->version >= 5)
> > +             goto skip;
> >           }
> >         bfd_set_error (bfd_error_bad_value);
> >         goto fail;
>
> This doesn't feel right to me.  Why are we looking for an abbrev in
> the wrong CU?  Presumably if the reader can do that, then it might
> interpret a lower number abbrev wrongly.

Here is the updated patch to replace

if (unit->version == 3 || unit->version == 4)

with

if (unit->version >= 3)

for DWARF5 or above.  OK for master?

Thanks.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-DWARF-Check-version-3-for-DW_FORM_ref_addr.patch
Type: text/x-patch
Size: 5803 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20210318/546cb5a3/attachment.bin>


More information about the Binutils mailing list