While working on PR29334, I noticed this code right above the DW_IDX_type_unit handling code: ... case DW_IDX_compile_unit: /* Don't crash on bad data. */ if (ull >= per_bfd->all_comp_units.size ()) { complaint (_(".debug_names entry has bad CU index %s" " [in module %s]"), pulongest (ull), objfile_name (objfile)); continue; } per_cu = per_bfd->get_cu (ull); break; ... So, if I have 5 CUs and 5 TUs, and a ull CU index of 7, we should complain. But we don't because we compare with "per_bfd->all_comp_units.size ()" instead of with "per_bfd->all_comp_units.size () - per_bfd->tu_stats.nr_tus".
Hmm, there are similar complaints for gdb-index, perhaps the same problem in dw2_symtab_iter_next?
Created attachment 14210 [details] tentative patch
(In reply to Tom de Vries from comment #1) > Hmm, there are similar complaints for gdb-index, perhaps the same problem in > dw2_symtab_iter_next? Filed as PR29367.
Submitted patch: https://sourceware.org/pipermail/gdb-patches/2022-July/190750.html
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=2fe9a3c41faa71b1f2bde40e818187491a5a9925