Reported by Peeter Joot: dwp built from current trunk: gdb -q --args gold/dwp -o t --exec /bin/date Reading symbols from /build/gold/dwp...done. (gdb) r Starting program: /build/gold/dwp -o t --exec /bin/date Program received signal SIGSEGV, Segmentation fault. __GI_fseek (fp=0x0, offset=0, whence=0) at fseek.c:40 40 fseek.c: No such file or directory. (gdb) bt #0 __GI_fseek (fp=0x0, offset=0, whence=0) at fseek.c:40 #1 0x0000000000407841 in gold::Dwp_output_file::write_new_section (this=0x7fffffffcfe0, section_name=0x5f3508 ".debug_cu_index", contents=0x8d0710 "\002", len=16, align=8) at ../../src/gold/dwp.cc:1812 #2 0x000000000041f74d in gold::Dwp_output_file::write_index<false> (this=0x7fffffffcfe0, sect_name=0x5f3508 ".debug_cu_index", index=...) at ../../src/gold/dwp.cc:1921 #3 0x0000000000407be5 in gold::Dwp_output_file::finalize (this=0x7fffffffcfe0) at ../../src/gold/dwp.cc:1725 #4 0x0000000000405c02 in main (argc=5, argv=0x7fffffffd418) at ../../src/gold/dwp.cc:2278
The same crash happens with DWARF5 dwos (-gsplit-dwarf -gdwarf-5).
diff --git a/gold/dwp.cc b/gold/dwp.cc index 7c4eef090d..d71caae357 100644 --- a/gold/dwp.cc +++ b/gold/dwp.cc @@ -2418,6 +2418,8 @@ main(int argc, char** argv) { Dwo_file exe_file(exe_filename); exe_file.read_executable(&files); + if (files.empty()) + gold_fatal(_("Could not find any dwo links in specified EXE")); } // Add any additional files listed on command line.
I only see this crash when attempting to use the DWARF 5 format. DWP seems to be able to find the .dwo files necessary for the DWARF 4 format when given the executable.