Skip to content

Commit f601ffb

Browse files
committed
PR 33029 segv in dwarf2_finish with --gdwarf-5
Specifying --gdwarf-5 with a source lacking a ".file 0" directive results in this segfault. * dwarf2dbg.c (out_debug_str): Use files[1] if files[0] is empty regardless of dwarf level.
1 parent 5e3176d commit f601ffb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

gas/dwarf2dbg.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3019,15 +3019,19 @@ out_debug_str (segT str_seg, symbolS **name_sym, symbolS **comp_dir_sym,
30193019
int len;
30203020
int first_file = DWARF2_LINE_VERSION > 4 ? 0 : 1;
30213021

3022+
if (files_in_use == 0)
3023+
abort ();
3024+
if (first_file == 0 && files[first_file].filename == NULL)
3025+
first_file = 1;
3026+
30223027
subseg_set (str_seg, 0);
30233028

30243029
/* DW_AT_name. We don't have the actual file name that was present
30253030
on the command line, so assume files[first_file] is the main input file.
30263031
We're not supposed to get called unless at least one line number
30273032
entry was emitted, so this should always be defined. */
30283033
*name_sym = symbol_temp_new_now_octets ();
3029-
if (files_in_use == 0)
3030-
abort ();
3034+
30313035
if (files[first_file].dir)
30323036
{
30333037
char *dirname = remap_debug_filename (dirs[files[first_file].dir]);

0 commit comments

Comments
 (0)