[PATCH 6/6] gas: avoid octal numbers being accepted when processing .linefile

Jan Beulich jbeulich@suse.com
Fri May 6 06:08:23 GMT 2022


Compilers would put decimal numbers there, so I think we should treat
finding octal numbers the same as finding bignums - ignore them as
actually being comments of some very specific form.
---
With the bignum and this change in place, I'm still worried about the
secondary use of get_linefile_number() - afaict we might still
mistakenly try to process special form comments as line/file
"directives", and under the right conditions this might also still
result in unde diagnostics.

--- a/gas/read.c
+++ b/gas/read.c
@@ -2047,6 +2047,14 @@ get_linefile_number (int *flag)
   if (*input_line_pointer < '0' || *input_line_pointer > '9')
     return false;
 
+  /* Don't mistakenly interpret octal numbers as line numbers.  */
+  if (*input_line_pointer == '0')
+    {
+      *flag = 0;
+      ++input_line_pointer;
+      return true;
+    }
+
   expression_and_evaluate (&exp);
   if (exp.X_op != O_constant)
     return false;
--- a/gas/testsuite/gas/all/linefile.l
+++ b/gas/testsuite/gas/all/linefile.l
@@ -2,4 +2,5 @@
 .*linefile\.s: Assembler messages:
 .*linefile\.s:2: Warning: line 2
 .*linefile\.s:5: Warning: line 5
+.*linefile\.s:8: Warning: line 8
 #pass
--- a/gas/testsuite/gas/all/linefile.s
+++ b/gas/testsuite/gas/all/linefile.s
@@ -3,3 +3,6 @@
 
 # 123456789123456789123456789 "LINEfile.s"
 	.warning "line 5"
+
+# 0123456789 "lineFILE.s"
+	.warning "line 8"



More information about the Binutils mailing list