From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 51501385828E; Thu, 21 Jul 2022 09:00:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51501385828E From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug symtab/29367] [gdb, debug-types, gdb-index] Bad CU index complaint not triggered Date: Thu, 21 Jul 2022 09:00:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: symtab X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_severity Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2022 09:00:10 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D29367 Tom de Vries changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement --- Comment #1 from Tom de Vries --- (In reply to Tom de Vries from comment #0) > Now the question: is this change correct? >=20 > I can't figure out how a type in a .debug_types section would be addressed > from the index. >=20 > Maybe 56 is the correct way to address TU 0 ? At https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html I fi= nd: ... Note that if there are type CUs, then conceptually CUs and type CUs form a single list for the purposes of CU indices. ... I guess that answers my question. So this: ... /* Don't crash on bad data. */ - if (cu_index >=3D per_objfile->per_bfd->all_comp_units.size (CUTU)) + if (cu_index >=3D per_objfile->per_bfd->all_comp_units.size (CU)) ... is incorrect, the current code is in fact correct. But we might be able to be more strict though: ... diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index bcd01107377..8d216318c13 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2975,7 +2975,13 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *it= er, && symbol_kind !=3D GDB_INDEX_SYMBOL_KIND_NONE); /* Don't crash on bad data. */ - if (cu_index >=3D per_objfile->per_bfd->all_comp_units.size ()) + size_t nr_tus =3D per_objfile->per_bfd->tu_stats.nr_tus; + size_t nr_cus =3D (per_objfile->per_bfd->all_comp_units.size () - nr= _tus); + /* Only allow type symbols in type units. */ + size_t size_for_kind =3D (symbol_kind =3D=3D GDB_INDEX_SYMBOL_KIND_T= YPE + ? nr_cus + nr_tus + : nr_cus); + if (cu_index >=3D size_for_kind) { complaint (_(".gdb_index entry has bad CU index" " [in module %s]"), objfile_name (per_objfile->objfile)); ... by assuming there are only type symbols in the type units, which means for other symbols we can be more strict about the allowed indices. --=20 You are receiving this mail because: You are on the CC list for the bug.=