[binutils-gdb] Fix the assembler's new .nop directive so that the input line pointer is preserved.

Nick Clifton nickc@sourceware.org
Tue Sep 15 09:54:31 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f36eda1fe30d394274a5f0becdff45bbd81fd6a8

commit f36eda1fe30d394274a5f0becdff45bbd81fd6a8
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Sep 15 10:53:46 2020 +0100

    Fix the assembler's new .nop directive so that the input line pointer is preserved.
    
            * read.c (s_nop): Preserve the input_line_pointer around the call
            to md_assemble.
            * config/tc-s12z.c (md_assemble): Revert previous delta.

Diff:
---
 gas/ChangeLog        | 6 ++++++
 gas/config/tc-s12z.c | 9 +++------
 gas/read.c           | 5 +++++
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 633967d3068..add14d82749 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+2020-09-15  Nick Clifton  <nickc@redhat.com>
+
+	* read.c (s_nop): Preserve the input_line_pointer around the call
+	to md_assemble.
+	* config/tc-s12z.c (md_assemble): Revert previous delta.
+
 2020-09-15  David Faust  <david.faust@oracle.com>
 
 	* config/tc-bpf.h (md_single_noop_insn): Use 'ja 0' for no-op.
diff --git a/gas/config/tc-s12z.c b/gas/config/tc-s12z.c
index c79d2f43f16..d89fb0c21ff 100644
--- a/gas/config/tc-s12z.c
+++ b/gas/config/tc-s12z.c
@@ -3807,7 +3807,6 @@ md_assemble (char *str)
       return;
     }
 
-  char * saved_ilp = input_line_pointer;
   input_line_pointer = skip_whites (op_end);
 
   size_t i;
@@ -3817,17 +3816,15 @@ md_assemble (char *str)
       if (0 == strcmp (name, opc->name))
 	{
 	  if (opc->parse_operands (opc))
-	    {
-	      input_line_pointer = saved_ilp;
-	      return;
-	    }
+	    return;
 	  continue;
 	}
     }
 
   as_bad (_("Invalid instruction: \"%s\""), str);
   as_bad (_("First invalid token: \"%s\""), fail_line_pointer);
-  input_line_pointer = saved_ilp;
+  while (*input_line_pointer++)
+    ;
 }
 
 
diff --git a/gas/read.c b/gas/read.c
index 97a9e66e6f4..ff4737ef2cb 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -3530,7 +3530,12 @@ s_nop (int ignore ATTRIBUTE_UNUSED)
   if (asprintf (&nop, "%s", md_single_noop_insn) < 0)
     as_fatal ("%s", xstrerror (errno));
 
+  /* Some targets assume that they can update input_line_pointer inside
+     md_assemble, and, worse, that they can leave it assigned to the string
+     pointer that was provided as an argument.  So preserve ilp here.  */
+  char * saved_ilp = input_line_pointer;
   md_assemble (nop);
+  input_line_pointer = saved_ilp;
   free (nop);
 #endif
 }


More information about the Binutils-cvs mailing list