[PATCH v3] Bug 28191 - Interpret DWARF 5 addrx locations

Giuliano Procida gprocida@google.com
Wed Nov 24 11:44:06 GMT 2021


Last one I think.

On Wed, 24 Nov 2021 at 11:33, Giuliano Procida <gprocida@google.com> wrote:
>
> Hi.
>
> On Wed, 24 Nov 2021 at 11:11, Giuliano Procida <gprocida@google.com> wrote:
> >
> > Hi Dodji.
> >
> > On Tue, 23 Nov 2021 at 17:15, Dodji Seketeli <dodji@seketeli.org> wrote:
> > >
> > > [I am adding Mark to the list recipients as I am going to ask him a
> > > question below]
> > >
> >
> > Indeed, I forgot to CC him on the patch. Hi Mark.
> >
> > >
> > > Hello,
> > >
> > > Giuliano Procida <gprocida@google.com> a écrit:
> > >
> > > > This change uses libdw facilities to interpret location expressions
> > > > instead of using libabigail's own mini-interpreter. With the fix for
> > > > elfutils https://sourceware.org/bugzilla/show_bug.cgi?id=28220 in
> > > > elfutils-0.186, abidw will correctly interpret Clang DWARF 5 symbol
> > > > addresses. Without that fix many declarations will not be linked to
> > > > their corresponding symbols due to the incorrect interpretation of
> > > > location attribute data.
> > > >
> > > >       * src/abg-dwarf-reader.cc (die_location_address): Use
> > > >       dwarf_attr_integrate, dwarf_getlocation and
> > > >       dwarf_getlocation_attr to decode addreses, instead of
> > > >       die_location_expr and eval_last_constant_dwarf_sub_expr.
> > > >       * tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
> > > >       Refresh test reference output; two more symbols have types.
> > >
> > > Thanks for looking into that.
> > >
> > > It seems to me that we can also do away with the use of eval_last_constant_dwarf_sub_expr from
> > > die_member_offset.  Would that work on your testing binaries?
> > >
> >
> > I think I originally wrote the code just before a trip away and didn't
> > have the time to look into the other callers then.
> >
> > >
> > > From what I am seeing, dwarf_getlocation_attr and dwarf_getlocation are
> > > present in elfutils 0.176 which is the oldest version that we need to
> > > support, so we should be able to ditch eval_last_constant_dwarf_sub_expr
> > > and its dependencies altogether.
> > >
> > > Or what am I missing?
> > >
> >
> > I think it would be good if we could rely on elfutils for this functionality.
> >
> > I've had a go at die_member_offset and I think I have it working (at
> > least with the test suite). I'll clean up what I have and post it.
> > There is considerable overlap with the address function.
> >
> > I haven't been able to get die_virtual_function_index to work as
> > dwarf_getlocation_attr fails.  There may be a simpler recipe to follow
> > here.
> >
>
> My mistake, the problem is with base-class offsets, not vtable
> indexes, so I don't have die_member_offset working after all. It's
> possible an extra specialisation of the function for the right DWARF
> "form" will fix this.
>

I concur with Mark:

< 1><0x0000009e>    DW_TAG_structure_type
                      DW_AT_name                  s0
                      DW_AT_byte_size             0x00000030
                      DW_AT_decl_file             0x00000001
/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc
                      DW_AT_decl_line             0x0000000d
                      DW_AT_containing_type       <0x0000009e>
                      DW_AT_sibling               <0x00000176>
< 2><0x000000ad>      DW_TAG_inheritance
                        DW_AT_type                  <0x00000029>
                        DW_AT_data_member_location  len 0x0006: 0x1206481c0622:
                            DW_OP_dup
                            DW_OP_deref
                            DW_OP_lit24
                            DW_OP_minus
                            DW_OP_deref
                            DW_OP_plus
                        DW_AT_virtuality            DW_VIRTUALITY_virtual
< 2><0x000000ba>      DW_TAG_inheritance
                        DW_AT_type                  <0x00000067>
                        DW_AT_data_member_location  len 0x0007:
0x120608201c0622:
                            DW_OP_dup
                            DW_OP_deref
                            DW_OP_const1u 32
                            DW_OP_minus
                            DW_OP_deref
                            DW_OP_plus
                        DW_AT_virtuality            DW_VIRTUALITY_virtual

Unless there is some exposed elfutils function that will interpret
these member locations for us, that code will still be needed in
libabigail.

> Giuliano.
>
> > If/when the 3 existing callers are working, there may be some code in
> > common to factor out as a new die_location_expr function.
> >
> > Regards,
> > Giuliano.
> >
> > >
> > > [...]
> > >
> > > Cheers,
> > >
> > > --
> > >                 Dodji


More information about the Libabigail mailing list