From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id skWlEPkfp2jPpggAWB0awg (envelope-from ) for ; Thu, 21 Aug 2025 09:32:41 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=iraRdp5D; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=/wOVwwx8; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=iraRdp5D; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=/wOVwwx8; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 357E51E0B3; Thu, 21 Aug 2025 09:32:41 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 2AA731E047 for ; Thu, 21 Aug 2025 09:32:40 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EB8813854829 for ; Thu, 21 Aug 2025 13:32:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB8813854829 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=iraRdp5D; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=/wOVwwx8; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=iraRdp5D; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=/wOVwwx8 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 880C93854816 for ; Thu, 21 Aug 2025 13:31:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 880C93854816 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 880C93854816 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1755783076; cv=none; b=fYr65T9swwmAzN2w4DjEibmAYbquiKM8aKY3YzreQfGivpAI+RxYqUbdVDvh6BiYGu2DRMgre/10zhkdnsBfOa1zdCiTZE3H1ztkADL/BSKgL3S5nLBkDGRP6j5A79rbdgJXTX0snN0Z+RIQo6597r+zCytiJaYHe9b/7oA63JE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1755783076; c=relaxed/simple; bh=zMwGFe/Vx9DbDhag7Wq6zby4H22rs5pb8p1ajPdjeFw=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=b53rWfIbPW9s1vIoTNGjCyWFMdPNGiC6konLhkbdTRCkkw8F+U3EjjecBuhRwTAphIq7FFx96UIC3eJzMG2DgZSmNrwpu/5mgkmbY/WdKqgUgZAZ0VHI/6oS2bnSVJbkIOEr6QxRitglaIlHhw09YXkm0k7W8eAahlY0ZPicrmA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 880C93854816 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 56D9D22001 for ; Thu, 21 Aug 2025 13:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1755783075; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rNsytQqjUbtooSRIhaMeWc+t4an2XYcSsIaxudoRTXo=; b=iraRdp5DNo/L8dm2RXp3x82QI+xEZCau6CvsjUZ4WPUBAHdjSdWWPx0CSKOd0+wb32Gx5o YKa5boz23guzd5yUVlJKVMIBiIkB84WoajpTGxEpXcqR+buY7njjvRrn2KdIhduU/l6N7d /S+EXGu+KmXkIuy1HUREeLnfnD/aLao= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1755783075; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rNsytQqjUbtooSRIhaMeWc+t4an2XYcSsIaxudoRTXo=; b=/wOVwwx8A9P6K8NAA+OhnqW47d+sY4E1cd6qztarESnwVzkwO2seS739/3Y9rEzaDRbTRt 5Qvq9xz/3CKiKjDQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1755783075; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rNsytQqjUbtooSRIhaMeWc+t4an2XYcSsIaxudoRTXo=; b=iraRdp5DNo/L8dm2RXp3x82QI+xEZCau6CvsjUZ4WPUBAHdjSdWWPx0CSKOd0+wb32Gx5o YKa5boz23guzd5yUVlJKVMIBiIkB84WoajpTGxEpXcqR+buY7njjvRrn2KdIhduU/l6N7d /S+EXGu+KmXkIuy1HUREeLnfnD/aLao= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1755783075; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rNsytQqjUbtooSRIhaMeWc+t4an2XYcSsIaxudoRTXo=; b=/wOVwwx8A9P6K8NAA+OhnqW47d+sY4E1cd6qztarESnwVzkwO2seS739/3Y9rEzaDRbTRt 5Qvq9xz/3CKiKjDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B4EC613AB7 for ; Thu, 21 Aug 2025 13:31:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eI3yKqIfp2g/bQAAD6G6ig (envelope-from ) for ; Thu, 21 Aug 2025 13:31:14 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v2 1/5] [gdb/symtab] Bail out of create_addrmap_from_gdb_index on error Date: Thu, 21 Aug 2025 15:31:10 +0200 Message-ID: <20250821133114.24091-2-tdevries@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250821133114.24091-1-tdevries@suse.de> References: <20250821133114.24091-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Currently, in create_addrmap_from_gdb_index, when finding an incorrect entry in the address table of a .gdb_index section: - a (by default silent) complaint is made, - the entry is skipped, and - the rest of the entries is processed. This is the use-what-you-can approach, which make sense in general. But in the case that the .gdb_index section is incorrect while the other debug info is correct, this approach prevents gdb from building a correct cooked index (assuming there's no bug in gdb that would cause an incorrect index to be generated). Instead, bail out of create_addrmap_from_gdb_index on finding errors in the address table. I wonder about the following potential drawback of this approach: in the case that the .gdb_index section is incorrect because the debug info is incorrect, this approach rejects the .gdb_index section and spents time rebuilding a likewise incorrect index. But I'm not sure if this is a real problem. Perhaps gdb will refuse to generate such an index, in which case this is a non-issue. Tested on aarch64-linux. Approved-By: Simon Marchi --- gdb/dwarf2/read-gdb-index.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index fc7b654be1a..7db2834f4d3 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -1395,9 +1395,10 @@ create_signatured_type_table_from_gdb_index per_bfd->signatured_types = std::move (sig_types_hash); } -/* Read the address map data from the mapped GDB index. */ +/* Read the address map data from the mapped GDB index. Return true if no + errors were found, otherwise return false. */ -static void +static bool create_addrmap_from_gdb_index (dwarf2_per_objfile *per_objfile, mapped_gdb_index *index) { @@ -1423,14 +1424,14 @@ create_addrmap_from_gdb_index (dwarf2_per_objfile *per_objfile, { complaint (_(".gdb_index address table has invalid range (%s - %s)"), hex_string (lo), hex_string (hi)); - continue; + return false; } if (cu_index >= index->units.size ()) { complaint (_(".gdb_index address table has invalid CU number %u"), (unsigned) cu_index); - continue; + return false; } mutable_map.set_empty (lo, hi - 1, index->units[cu_index]); @@ -1438,6 +1439,8 @@ create_addrmap_from_gdb_index (dwarf2_per_objfile *per_objfile, index->index_addrmap = new (&per_bfd->obstack) addrmap_fixed (&per_bfd->obstack, &mutable_map); + + return true; } /* Sets the name and language of the main function from the shortcut table. */ @@ -1559,7 +1562,8 @@ dwarf2_read_gdb_index finalize_all_units (per_bfd); - create_addrmap_from_gdb_index (per_objfile, map.get ()); + if (!create_addrmap_from_gdb_index (per_objfile, map.get ())) + return false; set_main_name_from_gdb_index (per_objfile, map.get ()); -- 2.43.0