From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id E87E23857C40 for ; Thu, 18 Feb 2021 16:59:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E87E23857C40 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-385-cHyDLC3AMpS3AtORw7T5IQ-1; Thu, 18 Feb 2021 11:59:46 -0500 X-MC-Unique: cHyDLC3AMpS3AtORw7T5IQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ABE5B801976; Thu, 18 Feb 2021 16:59:45 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-197.ams2.redhat.com [10.36.112.197]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4995C5D6AD; Thu, 18 Feb 2021 16:59:45 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 11IGxfwv2533606 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Feb 2021 17:59:42 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 11IGxe7t2533605; Thu, 18 Feb 2021 17:59:40 +0100 Date: Thu, 18 Feb 2021 17:59:40 +0100 From: Jakub Jelinek To: Mark Wielaard Cc: dwz@sourceware.org Subject: Re: [PATCH] Don't handle blocks as exprlocs for DWARF version 4 or higher. Message-ID: <20210218165940.GJ4020736@tucnak> Reply-To: Jakub Jelinek References: <20210213224622.16521-1-mark@klomp.org> <3fd1ebde0c9e1b8cbe09ea858a3e0f0a84af44b4.camel@klomp.org> <20210218140947.GG4020736@tucnak> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: dwz@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dwz mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Feb 2021 16:59:50 -0000 On Thu, Feb 18, 2021 at 05:18:10PM +0100, Mark Wielaard wrote: > > > > if (form == DW_FORM_block1) > > > > And likewise here: > > - if (form == DW_FORM_block1) > > + if (form == DW_FORM_block1 && cu->cu_version < 4) > > But here we do need to handle the DW_FORM_block && cu->cu_version >=4 > version separately. But that can be done by not indention the large > block and adding an small else if block. Ah, I got confused by DW_FORM_block{2,4,} cases changing form to DW_FORM_block1, indeed, for all of DW_FORM_{block{1,2,4,},exprloc} we need to do ptr += len; But perhaps we could do instead do: - if (form == DW_FORM_block1) + if (form == DW_FORM_block1 && cu->cu_version < 4) ... - ptr += len; ... - ptr += len; } + ptr += len; ? len is only set to non-0 for: case DW_FORM_block1: len = *ptr++; break; case DW_FORM_block2: len = read_16 (ptr); form = DW_FORM_block1; break; case DW_FORM_block4: len = read_32 (ptr); form = DW_FORM_block1; break; case DW_FORM_block: len = read_uleb128 (ptr); form = DW_FORM_block1; break; case DW_FORM_exprloc: len = read_uleb128 (ptr); break; i.e. exactly the cases we want to move. Anyway, looking around some more, if (unlikely (low_mem_phase1) && add_locexpr_dummy_dies (dso, cu, die, ptr, form, t->attr[i].attr, len)) goto fail; looks incorrect to me, form in that case will be DW_FORM_block{2,4,} and won't be canonicalized to DW_FORM_block1. And furthermore len will be always 0. It is preceded only by size_t len = 0; and a loop handling DW_FORM_indirect. So, ptr will always be the pointer to the block count too. This has been added for PR dwz/24204 by Tom, Tom, can you please comment on that? That function handles the DW_FORM_block1 (it wants canonicalization of DW_FORM_block{2,4,} to DW_FORM_block1) and DW_FORM_exprloc but wants ptr to be the start of those blocks and len to be the block length, or it handles DW_FORM_data{4,8} and DW_FORM_sec_offset for which it wants ptr to stay before the bump. So, I bet we need something like: switch (form) { case DW_FORM_block1: len = *ptr++; break; case DW_FORM_block2: len = read_16 (ptr); form = DW_FORM_block1; break; case DW_FORM_block4: len = read_32 (ptr); form = DW_FORM_block1; break; case DW_FORM_block: len = read_uleb128 (ptr); form = DW_FORM_block1; break; case DW_FORM_exprloc: len = read_uleb128 (ptr); break; default: break; } added before the if (unlikely (low_mem_phase1) && add_locexpr_dummy_dies (dso, cu, die, ptr, form, t->attr[i].attr, len)) goto fail; and then the DW_FORM_{block*,exprloc} handling later on be changed to: case DW_FORM_block1: break; case DW_FORM_exprloc: form = DW_FORM_block1; break; and remove the DW_FORM_block{2,4,} cases. Jakub