From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id 2AAD33861034 for ; Thu, 29 Oct 2020 14:00:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2AAD33861034 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mark@klomp.org Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id A6E5C30278CD; Thu, 29 Oct 2020 15:00:20 +0100 (CET) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 509134001344; Thu, 29 Oct 2020 15:00:20 +0100 (CET) Message-ID: <96ce118ec34004439e7e83360e6b08b47117cd93.camel@klomp.org> Subject: Re: [PATCH 3/3] dwarf-reader: Ignore zero length location expressions from DW_AT_location From: Mark Wielaard To: Matthias Maennich , libabigail@sourceware.org Cc: dodji@seketeli.org, gprocida@google.com, kernel-team@android.com, Dan Albert Date: Thu, 29 Oct 2020 15:00:20 +0100 In-Reply-To: <20201029123005.GA787461@google.com> References: <20201029122100.765143-1-maennich@google.com> <20201029122100.765143-3-maennich@google.com> <20201029123005.GA787461@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution 3.28.5 (3.28.5-10.el7) Mime-Version: 1.0 X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Thu, 29 Oct 2020 14:00:23 -0000 Hi, On Thu, 2020-10-29 at 12:30 +0000, Matthias Maennich wrote: > On Thu, Oct 29, 2020 at 12:21:00PM +0000, Matthias Maennich wrote: > > Location expressions might occasionally be of length 0. E.g. a reason > > for that are thread local variables that do not exactly have a location > > to refer to. Compilers/Linkers may choose an odd representation. E.g. > > see the dwarfdump output for the added testcase based on libandroid.so > > (from AOSP). I don't think it is "odd", it is simply an empty location expression, which is defined as no location known. > > The DW_AT_location is properly read by elfutils' dwarf_location(), but > > is not useful for us to proceed with. Hence early exit on this. > >=20 > > * src/abg-dwarf-reader.cc (die_location_expr): Ignore zero > > length location expressions. > > * tests/data/Makefile.am: Add new test files. > > * tests/data/test-read-dwarf/test-libandroid.so: New test file. > > * tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise. > > * tests/test-read-dwarf.cc: Add new test case. > >=20 > > Reported-by: Dan Albert > > Reviewed-by: Giuliano Procida > > Cc: Mark Wielaard > > Signed-off-by: Matthias Maennich > [...] > // Ignore invalid location expressions where reading them succeeded but= their > // length is 0. > result &=3D len > 0; The actual code change looks correct, but I would like the comment to not say they are invalid (if they were dwarf_getlocation would have returned an error), but that an empty location expression represents an unknown location (and so it is indeed not very useful). See also DWARFv5 2.6.1.1.1 Empty Location Descriptions An empty location description consists of a DWARF expression containing no operations. It represents a piece or all of an object that is present in the source but not in the object code (perhaps due to optimization). Cheers, Mark