Currently not supported: ... $ gcc -gdwarf-5 ../src/testsuite/dwz.tests/hello.c $ gdb-add-index -dwarf-5 a.out $ cp a.out 1; ./dwz 1 ./dwz: 1: Unknown debugging section .debug_names ...
This will need coordination with the rest of the GNU Toolchain, in particular GDB, which uses .gdb_index (which dwz does support). The .debug_names that gdb-add-index -dwarf-5 generates seems incomplete (https://www.sourceware.org/bugzilla/show_bug.cgi?id=24820) and it might need some extensions (in DWARF6?) to be generated properly.
FWIW I'd recommend simply making the index after running dwz. However, if you really want to have dwz understand how to make an index, you should be aware of gdb extensions: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Debug-Names.html#Debug-Names There will be more of these, I think -- actually to handle dwz we need some. Also, gdb does producer-sniffing and rejects most indexes, so probably it will also need a patch if dwz gains this capability.