From 421c4a00d9e2bdfffe9817600c4b4abb39464a3f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 13 Aug 2025 10:16:46 -0600 Subject: [PATCH] Refine range check in create_addrmap_from_gdb_index PR symtab/33247 points out that this check in create_addrmap_from_gdb_index: if (lo > hi) { complaint (_(".gdb_index address table has invalid range (%s - %s)"), hex_string (lo), hex_string (hi)); ... should probably use ">=" instead. Reading a bit further the reason seems obvious: mutable_map.set_empty (lo, hi - 1, index->units[cu_index]); Here if lo==hi, then this will insert a "reversed" range into the addrmap. Apparently some LLVM tool can erroneously create a .gdb_index like this. No test because it seems like more trouble to write than it's worth. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33247 Approved-By: Simon Marchi --- gdb/dwarf2/read-gdb-index.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index 76317fe3191..7dfba732451 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -1419,7 +1419,7 @@ create_addrmap_from_gdb_index (dwarf2_per_objfile *per_objfile, cu_index = extract_unsigned_integer (iter, 4, BFD_ENDIAN_LITTLE); iter += 4; - if (lo > hi) + if (lo >= hi) { complaint (_(".gdb_index address table has invalid range (%s - %s)"), hex_string (lo), hex_string (hi)); -- 2.47.3