From patchwork Sun Aug 4 22:42:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Harmstone X-Patchwork-Id: 1968859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=harmstone.com header.i=@harmstone.com header.a=rsa-sha256 header.s=mail header.b=be6V2NSQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WcZMr03Sxz1yZb for ; Mon, 5 Aug 2024 08:42:48 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3A09E385C6C6 for ; Sun, 4 Aug 2024 22:42:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.burntcomma.com (mail2.burntcomma.com [217.169.27.34]) by sourceware.org (Postfix) with ESMTPS id 40464385841C for ; Sun, 4 Aug 2024 22:42:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 40464385841C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=harmstone.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=harmstone.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 40464385841C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.169.27.34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722811347; cv=none; b=NzxcuVY3+7joCYtk6eHzTHguExBIPW2ZNPJ6I+ICY3CSscX5ZroowDz69IYeXKz4gEyIi7k1Ql3Dv+CcB4ztA8ACcVv86nwdOdTVRSKFRKCVr554VGbXqZhVnwyjtaWh3m0t2lFs2hqAK2NsOLeTLAxsV4gCtzoKJVP2KT3EoTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722811347; c=relaxed/simple; bh=h50wXFBnf5puuDPj2rleGWg9iKNHobII0ZtwIzYZ7ew=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:Mime-Version; b=pqyzLGpCQIJEv1Px+4K76tkzG5TWIsgjBYRTE4T2MO1chS/aq/lulhPbYGrHKj9rstvAAI87RzXxNe2gXg6WHC1AjwBUJOz6v/n+wzWXSlnz5/q3xGvXSfzUTMHQXsIQQW9Ihl+nouWyEyXzBYRAQEVMS0BeSEKepBZfKTA/n3g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost.localdomain (beren.burntcomma.com [IPv6:2a02:8012:8cf0:0:b62e:99ff:fee9:ad9f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by mail.burntcomma.com (Postfix) with ESMTPSA id A571C410D27B; Sun, 4 Aug 2024 23:42:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=harmstone.com; s=mail; t=1722811342; bh=BH+xWndsplv+WVeBChsQ7EzSFuujnulAq0aFT801Cyc=; h=From:To:Cc:Subject:Date; b=be6V2NSQ4lsL+9FyBL2gQaDnDUb/CBt90mQU+xA8CDXkEiakgHhRmdrwAv3QY3BTO jYVtUGdy01j/eIOKzv69IPaxCJ9pDML1Axs/f160RUWwySeNVXqKzn610/+uQ91lA9 aZvhBAeLnCKeCsSSzB/qOhIYuk4pA4D7poHM1k4E= From: Mark Harmstone To: gcc-patches@gcc.gnu.org Cc: Mark Harmstone Subject: [PATCH] Fix handling of const or volatile void pointers in CodeView Date: Sun, 4 Aug 2024 23:42:12 +0100 Message-ID: <20240804224212.19192-1-mark@harmstone.com> Mime-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org DWARF represents voids in DW_TAG_const_type and DW_TAG_volatile_type DIEs by the absence of a DW_AT_type attribute, which we weren't handling correctly. gcc/ * dwarf2codeview.cc (get_type_num_const_type): Handle missing DW_AT_type attribute. (get_type_num_volatile_type): Likewise. --- gcc/dwarf2codeview.cc | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc index 470cbae7110..f7107021bc7 100644 --- a/gcc/dwarf2codeview.cc +++ b/gcc/dwarf2codeview.cc @@ -2344,23 +2344,26 @@ get_type_num_const_type (dw_die_ref type, bool in_struct) bool is_volatile = false; base_type = get_AT_ref (type, DW_AT_type); - if (!base_type) - return 0; /* Handle case when this is a const volatile type - we only need one LF_MODIFIER for this. */ - if (dw_get_die_tag (base_type) == DW_TAG_volatile_type) + if (base_type && dw_get_die_tag (base_type) == DW_TAG_volatile_type) { is_volatile = true; base_type = get_AT_ref (base_type, DW_AT_type); - if (!base_type) - return 0; } - base_type_num = get_type_num (base_type, in_struct, false); - if (base_type_num == 0) - return 0; + if (!base_type) + { + base_type_num = T_VOID; + } + else + { + base_type_num = get_type_num (base_type, in_struct, false); + if (base_type_num == 0) + return 0; + } ct = (codeview_custom_type *) xmalloc (sizeof (codeview_custom_type)); @@ -2383,13 +2386,22 @@ get_type_num_const_type (dw_die_ref type, bool in_struct) static uint32_t get_type_num_volatile_type (dw_die_ref type, bool in_struct) { + dw_die_ref base_type; uint32_t base_type_num; codeview_custom_type *ct; - base_type_num = get_type_num (get_AT_ref (type, DW_AT_type), in_struct, - false); - if (base_type_num == 0) - return 0; + base_type = get_AT_ref (type, DW_AT_type); + + if (base_type) + { + base_type_num = get_type_num (base_type, in_struct, false); + if (base_type_num == 0) + return 0; + } + else + { + base_type_num = T_VOID; + } ct = (codeview_custom_type *) xmalloc (sizeof (codeview_custom_type));