From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id CF6FA3858D37; Wed, 20 Mar 2024 08:56:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF6FA3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1710925005; bh=YFScENqXtBF3+LhIpFSQ6CWNNMfN3LV6RZp3W1RhE/o=; h=From:To:Subject:Date:From; b=CszpBS9jUVuQe6bz6P7yzfURUDdVykB8NmZ6Beyb5jdL5sAQ4KXjsnV10cFJCcxB4 DT7WKq9/fUS1ts3Gl0H9CL9P9GZmIOryxtZd9H1ZRZANOfkyZhFhY8OGmwAlTy6f2k bFT2btHsRfO8G4Wvyr7gGap7i9OI2n7ibU+ur73w= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/symtab] Workaround PR gas/31115 X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 8f39d04b97c87031bfd2fe351263b5d769464181 X-Git-Newrev: 8a61ee551ce3059f602fee1e576af08c03f991bc Message-Id: <20240320085645.CF6FA3858D37@sourceware.org> Date: Wed, 20 Mar 2024 08:56:45 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D8a61ee551ce3= 059f602fee1e576af08c03f991bc commit 8a61ee551ce3059f602fee1e576af08c03f991bc Author: Tom de Vries Date: Wed Mar 20 09:57:49 2024 +0100 [gdb/symtab] Workaround PR gas/31115 =20 On arm-linux, with gas 2.40, I run into: ... (gdb) x /i main+8^M 0x4e1 : vrhadd.u16 d14, d14, d31^M (gdb) FAIL: gdb.arch/pr25124.exp: disassemble thumb instruction (1st tr= y) ... =20 This is a regression due to PR gas/31115, which makes gas produce a low= _pc with the thumb bit set (0x4d8 & 0x1): ... <1><24>: Abbrev Number: 2 (DW_TAG_subprogram) <25> DW_AT_name : main <29> DW_AT_external : 1 <29> DW_AT_type : <0x2f> <2a> DW_AT_low_pc : 0x4d9 <2e> DW_AT_high_pc : 12 ... =20 The regression was introduced in 2.39, and is also present in 2.40 and = 2.41, and hasn't been fixed yet. =20 Work around this in read_func_scope, by using gdbarch_addr_bits_remove = on low_pc and high_pc. =20 Tested on arm-linux and x86_64-linux. =20 PR tdep/31453 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31453 Diff: --- gdb/dwarf2/cu.c | 1 + gdb/dwarf2/cu.h | 1 + gdb/dwarf2/read.c | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c index ae46dd2a9b2..62c0a8a3ede 100644 --- a/gdb/dwarf2/cu.c +++ b/gdb/dwarf2/cu.c @@ -42,6 +42,7 @@ dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu, producer_is_clang (false), producer_is_gas_lt_2_38 (false), producer_is_gas_2_39 (false), + producer_is_gas_ge_2_40 (false), processing_has_namespace_info (false) { } diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h index ad89228ef8d..58e89960aad 100644 --- a/gdb/dwarf2/cu.h +++ b/gdb/dwarf2/cu.h @@ -263,6 +263,7 @@ public: bool producer_is_clang : 1; bool producer_is_gas_lt_2_38 : 1; bool producer_is_gas_2_39 : 1; + bool producer_is_gas_ge_2_40 : 1; =20 /* When true, the file that we're processing is known to have debugging info for C++ namespaces. GCC 3.3.x did not produce diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 65b16719922..7442094874c 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -148,6 +148,7 @@ static int dwarf2_loclist_block_index; static int ada_block_index; =20 static bool producer_is_gas_lt_2_38 (struct dwarf2_cu *cu); +static bool producer_is_gas_ge_2_39 (struct dwarf2_cu *cu); =20 /* Size of .debug_loclists section header for 32-bit DWARF format. */ #define LOCLIST_HEADER_SIZE32 12 @@ -9981,6 +9982,15 @@ read_func_scope (struct die_info *die, struct dwarf2= _cu *cu) lowpc =3D per_objfile->relocate (unrel_low); highpc =3D per_objfile->relocate (unrel_high); =20 + if (gdbarch_bfd_arch_info (gdbarch)->arch =3D=3D bfd_arch_arm + && producer_is_gas_ge_2_39 (cu)) + { + /* Gas version 2.39 produces DWARF for a Thumb subprogram with a low= _pc + attribute with the thumb bit set (PR gas/31115). Work around this. */ + lowpc =3D gdbarch_addr_bits_remove (gdbarch, lowpc); + highpc =3D gdbarch_addr_bits_remove (gdbarch, highpc); + } + /* If we have any template arguments, then we must allocate a different sort of symbol. */ for (child_die =3D die->child; child_die; child_die =3D child_die->sibli= ng) @@ -11333,6 +11343,7 @@ check_producer (struct dwarf2_cu *cu) { cu->producer_is_gas_lt_2_38 =3D major < 2 || (major =3D=3D 2 && mino= r < 38); cu->producer_is_gas_2_39 =3D major =3D=3D 2 && minor =3D=3D 39; + cu->producer_is_gas_ge_2_40 =3D major > 2 || (major =3D=3D 2 && mino= r >=3D 40); } else { @@ -11387,6 +11398,17 @@ producer_is_gas_2_39 (struct dwarf2_cu *cu) return cu->producer_is_gas_2_39; } =20 +/* Return true if CU is produced by GAS 2.39 or later. */ + +static bool +producer_is_gas_ge_2_39 (struct dwarf2_cu *cu) +{ + if (!cu->checked_producer) + check_producer (cu); + + return cu->producer_is_gas_2_39 || cu->producer_is_gas_ge_2_40; +} + /* Return the accessibility of DIE, as given by DW_AT_accessibility. If that attribute is not available, return the appropriate default. */