From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by sourceware.org (Postfix) with ESMTPS id 40AA13858018 for ; Mon, 17 Jan 2022 13:06:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 40AA13858018 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=seketeli.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=seketeli.org Received: (Authenticated sender: dodji@seketeli.org) by mail.gandi.net (Postfix) with ESMTPSA id E0FFE1C0010; Mon, 17 Jan 2022 13:06:55 +0000 (UTC) Received: by localhost (Postfix, from userid 1000) id 5934F58010A; Mon, 17 Jan 2022 14:06:55 +0100 (CET) From: Dodji Seketeli To: Giuliano Procida Cc: libabigail@sourceware.org, kernel-team@android.com, maennich@google.com Subject: Re: [PATCH v4] Bug 28191 - Interpret DWARF 5 addrx locations Organization: Me, myself and I References: <20211119150138.2930800-1-gprocida@google.com> <20220113085648.3581287-1-gprocida@google.com> X-Operating-System: Fedora 36 X-URL: http://www.seketeli.net/~dodji Date: Mon, 17 Jan 2022 14:06:55 +0100 In-Reply-To: <20220113085648.3581287-1-gprocida@google.com> (Giuliano Procida's message of "Thu, 13 Jan 2022 08:56:48 +0000") Message-ID: <87o84acxzk.fsf@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Jan 2022 13:07:02 -0000 Giuliano Procida a =C3=A9crit: > 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=3D28220 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. > > Signed-off-by: Giuliano Procida Applied to master, thanks! [...] Cheers, > --- > src/abg-dwarf-reader.cc | 23 +++-- > .../PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi | 86 +++++++++++-------- > 2 files changed, 68 insertions(+), 41 deletions(-) > > diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc > index 3f716944..7693a023 100644 > --- a/src/abg-dwarf-reader.cc > +++ b/src/abg-dwarf-reader.cc > @@ -8858,18 +8858,31 @@ die_location_address(Dwarf_Die* die, > uint64_t expr_len =3D 0; >=20=20 > is_tls_address =3D false; > - if (!die_location_expr(die, DW_AT_location, &expr, &expr_len)) > + > + if (!die) > + return false; > + > + Dwarf_Attribute attr; > + if (!dwarf_attr_integrate(const_cast(die), DW_AT_location,= &attr)) > return false; >=20=20 > - int64_t addr =3D 0; > - if (!eval_last_constant_dwarf_sub_expr(expr, expr_len, addr, is_tls_ad= dress)) > + if (dwarf_getlocation(&attr, &expr, &expr_len)) > + return false; > + // Ignore location expressions where reading them succeeded but > + // their length is 0. > + if (expr_len =3D=3D 0) > return false; >=20=20 > - address =3D addr; > + Dwarf_Attribute result; > + if (!dwarf_getlocation_attr(&attr, expr, &result)) > + // A location that has been interpreted as an address. > + return !dwarf_formaddr(&result, &address); > + > + // Just get the address out of the number field. > + address =3D expr->number; > return true; > } >=20=20 > - > /// Return the index of a function in its virtual table. That is, > /// return the value of the DW_AT_vtable_elem_location attribute. > /// > diff --git a/tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6= .0.0.abi b/tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0= .abi > index 4a84fe97..91542872 100644 > --- a/tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi > +++ b/tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi > @@ -639,6 +639,14 @@ > > > > + > + > + > + > + > + > + > + > > > > @@ -665,6 +673,7 @@ > > > > + > > > > @@ -673,6 +682,7 @@ > > > > + > > > > @@ -727,11 +737,11 @@ > > > > - > - > + > + > > > - > + > > > > @@ -739,7 +749,7 @@ > > > > - > + > > > > @@ -768,63 +778,63 @@ > > > > - > + > > > > > > - > - > - > + > + > + > > > - > + > > > > > > > - > + > > > - > + > > > > - > + > > - > + > > > > > > - > + > > > > > > - > + > > > > - > + > > > > - > + > > > > - > + > > > > > - > + > > > > @@ -834,7 +844,7 @@ > > > > - > + > > > > @@ -944,8 +954,8 @@ > > > > - > - > + > + > > > > @@ -974,13 +984,13 @@ > > > > - > + > > > > > > - > + > > > > @@ -994,10 +1004,10 @@ > > > > - > - > + > + > > - > + > > > > @@ -1030,9 +1040,9 @@ > > > > - > - > - > + > + > + > > > > @@ -1045,11 +1055,11 @@ > > > > - > + > > > > - > + > > > > @@ -1068,11 +1078,15 @@ > > > > - > - > + > + > + > + > + > + > > - > - > + > + > > > --=20 Dodji