From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0A6083849ADD; Mon, 13 May 2024 15:58:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A6083849ADD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1715615910; bh=lpThQqjlRaEfis767dgHIy6+vYPpwwfJmBeTqFy4Ch4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fMu5ogg7l2XTWD1ln+ofNfnKL5ly7YJQQsSHKMtV3ols8zNR8v3nPRRNkiTaV4eCf ghQRigvVrcOGGqaECo8R0oxRK0fXOU834GvVFckrKCdb+6qF0E5IB1THT0jcm1FIWA dBg1VcESS4WLlGx/trNDgK1NWbvGXIlthHVZKGQs= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug symtab/31725] [gdb/symtab] wrong .debug_str section used in dwarf_decode_macro_bytes Date: Mon, 13 May 2024 15:58:29 +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: 14.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal 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: 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 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31725 --- Comment #6 from Tom de Vries --- This seems to work: ... diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 049ee4d52ff..2ab94b0dd27 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -21200,7 +21200,21 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset, str_offsets_section =3D &cu->dwo_unit->dwo_file ->sections.str_offsets; str_section =3D &cu->dwo_unit->dwo_file->sections.str; - str_offsets_base =3D cu->header.addr_size; + if (cu->per_cu->version () <=3D 4) + str_offsets_base =3D 0; + else + { + bfd *abfd =3D str_offsets_section->get_bfd_owner (); + unsigned int bytes_read; + read_initial_length (abfd, str_offsets_section->buffer, &bytes_re= ad, false); + if (!(bytes_read =3D=3D 4 || bytes_read =3D=3D 12)) + { + complaint (_("Can't get initial length of %s"), str_offsets_section->get_name ()); + return; + } + const bool is_dwarf64 =3D bytes_read !=3D 4; + str_offsets_base =3D is_dwarf64 ? 16 : 8; + } } else { ... --=20 You are receiving this mail because: You are on the CC list for the bug.=