In DWARF 5, a type unit can appear in .debug_info. However, the gdb_index section does not handle this situation -- it assumes that all type units appear in .debug_types.
Probably we should just close this as part of a general move to preferring .debug_names instead.
There's a test for this, gdb.dwarf2/gdb-index-types-dwarf5.exp, but from what I can see it only passes by accident.
It turns out there is a check where, if there is not .debug_types, then TUs are assumed to come from .debug_info: dwarf2_section_info *section = (per_bfd->types.size () == 1 ? &per_bfd->types[0] : &per_bfd->infos[0]); So while this doesn't work in general, it can work in a specific case. This isn't documented.