]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: abort in new_logical_line_flags master
authorAlan Modra <amodra@gmail.com>
Mon, 16 Feb 2026 23:29:37 +0000 (09:59 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 17 Feb 2026 00:45:47 +0000 (11:15 +1030)
.linefile 0.

hits the "case 1 << 3" abort in new_logical_line_flags with line_number
of -1.

Similar to commit b60f6a628897, this fixes the abort by extending the
meaning of .linefile in user code to restore the physical line for
".linefile 0 .".

* input-scrub.c (new_logical_line_flags <case 1<<3>): Don't
abort on negative line number, instead restore physical line
for ".linefile 0".

gas/input-scrub.c

index afb80ef2ce0c61e81bdef112fa194d6a8dc972fd..2b90632040ba6041327daeb6bd26b58fe2417ac3 100644 (file)
@@ -495,7 +495,12 @@ new_logical_line_flags (const char *fname, /* DON'T destroy it!  We point to it!
       /* FIXME: we could check that include nesting is correct.  */
       break;
     case 1 << 3:
       /* FIXME: we could check that include nesting is correct.  */
       break;
     case 1 << 3:
-      if (line_number < 0 || fname != NULL)
+      /* s_linefile conditionally decrements the line depending on
+        whether '\n' is seen.  */
+      if (line_number < 0
+         || (line_number == 0 && input_line_pointer[-1] != '\n'))
+       line_number = physical_input_line;
+      if (fname != NULL)
        abort ();
       if (next_saved_file == NULL)
        fname = physical_input_file;
        abort ();
       if (next_saved_file == NULL)
        fname = physical_input_file;