[binutils-gdb] Remove support for .gdb_index < 7

Tom Tromey tromey@sourceware.org
Wed Sep 10 22:17:14 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f55320428b9480112ba837d66e61e1e57c8787e4

commit f55320428b9480112ba837d66e61e1e57c8787e4
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Sep 8 17:55:57 2025 -0600

    Remove support for .gdb_index < 7
    
    This patch removes support for .gdb_index versions less than 7.  See
    the patch that rewrites the reader to understand why this is needed.
    
    Approved-By: Simon Marchi <simon.marchi@efficios.com>
    Reviewed-By: Eli Zaretskii <eliz@gnu.org>
    Acked-By: Simon Marchi <simon.marchi@efficios.com>

Diff:
---
 gdb/NEWS                    |  3 +++
 gdb/doc/gdb.texinfo         | 10 +++-------
 gdb/dwarf2/read-gdb-index.c | 36 ++++--------------------------------
 3 files changed, 10 insertions(+), 39 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index 36065ec1943..1a9cd9df897 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,9 @@
 
 *** Changes since GDB 17
 
+* Support for .gdb_index sections with version less than 7 has been
+  removed.
+
 * New targets
 
 GNU/Linux/MicroBlaze (gdbserver) microblazeel-*linux*
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 4c33cd2a521..dd9498c3dc8 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -50686,17 +50686,13 @@ unless otherwise noted:
 
 @enumerate
 @item
-The version number, currently 9.  Versions 1, 2 and 3 are obsolete.
-Version 4 uses a different hashing function from versions 5 and 6.
-Version 6 includes symbols for inlined functions, whereas versions 4
-and 5 do not.  Version 7 adds attributes to the CU indices in the
-symbol table.  Version 8 specifies that symbols from DWARF type units
+The version number, currently 9.  Versions 1 through 6 are obsolete.
+Version 7 adds attributes to the CU indices in the symbol table.
+Version 8 specifies that symbols from DWARF type units
 (@samp{DW_TAG_type_unit}) refer to the type unit's symbol table and not the
 compilation unit (@samp{DW_TAG_comp_unit}) using the type.  Version 9 adds
 the name and the language of the main function to the index.
 
-@value{GDBN} will only read version 4, 5, or 6 indices
-by specifying @code{set use-deprecated-index-sections on}.
 GDB has a workaround for potentially broken version 7 indices so it is
 currently not flagged as deprecated.
 
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index f2686e30efe..070239a5b6a 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -1060,9 +1060,7 @@ dw2_expand_marked_cus (dwarf2_per_objfile *per_objfile, offset_type idx,
 	 Indices prior to version 7 don't record them,
 	 and indices >= 7 may elide them for certain symbols
 	 (gold does this).  */
-      int attrs_valid =
-	(index.version >= 7
-	 && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);
+      int attrs_valid = symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE;
 
       /* Work around gold/15646.  */
       if (attrs_valid
@@ -1210,11 +1208,9 @@ read_gdb_index_from_buffer (const char *filename,
 
   /* Version check.  */
   offset_type version = metadata[0];
-  /* Versions earlier than 3 emitted every copy of a psymbol.  This
-     causes the index to behave very poorly for certain requests.  Version 3
-     contained incomplete addrmap.  So, it seems better to just ignore such
-     indices.  */
-  if (version < 4)
+  /* GDB now requires the symbol attributes, which were added in
+     version 7.  */
+  if (version < 7)
     {
       static int warning_printed = 0;
       if (!warning_printed)
@@ -1225,30 +1221,6 @@ read_gdb_index_from_buffer (const char *filename,
 	}
       return 0;
     }
-  /* Index version 4 uses a different hash function than index version
-     5 and later.
-
-     Versions earlier than 6 did not emit psymbols for inlined
-     functions.  Using these files will cause GDB not to be able to
-     set breakpoints on inlined functions by name, so we ignore these
-     indices unless the user has done
-     "set use-deprecated-index-sections on".  */
-  if (version < 6 && !deprecated_ok)
-    {
-      static int warning_printed = 0;
-      if (!warning_printed)
-	{
-	  warning (_("\
-Skipping deprecated .gdb_index section in %s.\n\
-Do \"%ps\" before the file is read\n\
-to use the section anyway."),
-		   filename,
-		   styled_string (command_style.style (),
-				  "set use-deprecated-index-sections on"));
-	  warning_printed = 1;
-	}
-      return 0;
-    }
   /* Version 7 indices generated by gold refer to the CU for a symbol instead
      of the TU (for symbols coming from TUs),
      http://sourceware.org/bugzilla/show_bug.cgi?id=15021.


More information about the Gdb-cvs mailing list