gas/Dwarf5: re-use file 0 line string table entry when faking file 0
authorJan Beulich <jbeulich@suse.com>
Wed, 23 Mar 2022 07:48:24 +0000 (08:48 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 23 Mar 2022 07:48:24 +0000 (08:48 +0100)
No need to emit the same string a 2nd time for file 1 in this case.

gas/dwarf2dbg.c

index c0a052df7d5f94a9c6d0dbe000a2d754b8b813aa..fee56c249e4fd9e300858a47f8470b9b8b3f9692 100644 (file)
@@ -2137,7 +2137,7 @@ out_dir_and_file_list (segT line_seg, int sizeof_offset)
   bool emit_timestamps = true;
   bool emit_filesize = true;
   segT line_str_seg = NULL;
-  symbolS *line_strp;
+  symbolS *line_strp, *file0_strp = NULL;
 
   /* Output the Directory Table.  */
   if (DWARF2_LINE_VERSION >= 5)
@@ -2301,9 +2301,17 @@ out_dir_and_file_list (segT line_seg, int sizeof_offset)
        }
       else
        {
-         line_strp = add_line_strp (line_str_seg, fullfilename);
+         if (!file0_strp)
+           line_strp = add_line_strp (line_str_seg, fullfilename);
+         else
+           line_strp = file0_strp;
          subseg_set (line_seg, 0);
          TC_DWARF2_EMIT_OFFSET (line_strp, sizeof_offset);
+         if (i == 0 && files_in_use > 1
+             && files[0].filename == files[1].filename)
+           file0_strp = line_strp;
+         else
+           file0_strp = NULL;
        }
 
       /* Directory number.  */