This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Fix an internal error in GAS when assembling a bogus piece of source code.


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

commit 99b2a2dd3cd91ee45aba56a90b52be943001e8f4
Author: Nick Clifton <nickc@redhat.com>
Date:   Wed Apr 29 17:09:05 2015 +0100

    Fix an internal error in GAS when assembling a bogus piece of source code.
    
    gas	PR 18256
    	* config/tc-arm.c (encode_arm_cp_address): Issue an error message
    	if the operand is neither a register nor a vector.
    
    tests	* gas/arm/pr18256.s: New file: Test case.
    	* gas/arm/pr18256.l: New file: Expected assembler output.
    	* gas/arm/pr18256.d: New file: Test driver.

Diff:
---
 gas/ChangeLog                   | 6 ++++++
 gas/config/tc-arm.c             | 7 ++++++-
 gas/testsuite/ChangeLog         | 7 +++++++
 gas/testsuite/gas/arm/pr18256.d | 9 +++++++++
 gas/testsuite/gas/arm/pr18256.l | 2 ++
 gas/testsuite/gas/arm/pr18256.s | 1 +
 6 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 1affd22..9ba6648 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,11 @@
 2015-04-29  Nick Clifton  <nickc@redhat.com>
 
+	PR 18256
+	* config/tc-arm.c (encode_arm_cp_address): Issue an error message
+	if the operand is neither a register nor a vector.
+
+2015-04-29  Nick Clifton  <nickc@redhat.com>
+
 	* doc/as.texinfo (Set): Note that a symbol cannot be set multiple
 	times if the expression is not constant and the target uses linker
 	relaxation.
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 5ce4da5..bc8f775 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -7891,7 +7891,12 @@ encode_arm_cp_address (int i, int wb_ok, int unind_ok, int reloc_override)
 {
   if (!inst.operands[i].isreg)
     {
-      gas_assert (inst.operands[0].isvec);
+      /* PR 18256 */
+      if (! inst.operands[0].isvec)
+	{
+	  inst.error = _("invalid co-processor operand");
+	  return FAIL;
+	}
       if (move_or_literal_pool (0, CONST_VEC, /*mode_3=*/FALSE))
 	return SUCCESS;
     }
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index d0167be..aed518a 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2015-04-29  Nick Clifton  <nickc@redhat.com>
+
+	PR gas/18265
+	* gas/arm/pr18256.s: New file: Test case.
+	* gas/arm/pr18256.l: New file: Expected assembler output.
+	* gas/arm/pr18256.d: New file: Test driver.
+
 2015-04-28  Renlin Li  <renlin.li@arm.com>
 
 	* gas/arm/thumb2_vpool_be.d: Adjust the desired output.
diff --git a/gas/testsuite/gas/arm/pr18256.d b/gas/testsuite/gas/arm/pr18256.d
new file mode 100644
index 0000000..0c5e514
--- /dev/null
+++ b/gas/testsuite/gas/arm/pr18256.d
@@ -0,0 +1,9 @@
+# name: PR18256 - Bad code triggers internal error
+#as:
+#error-output: pr18256.l
+
+
+
+
+
+
diff --git a/gas/testsuite/gas/arm/pr18256.l b/gas/testsuite/gas/arm/pr18256.l
new file mode 100644
index 0000000..b68e914
--- /dev/null
+++ b/gas/testsuite/gas/arm/pr18256.l
@@ -0,0 +1,2 @@
+[^:]*: Assembler messages:
+[^:]*:1: Error: invalid co-processor operand -- `ldc p0,c0,=.'
diff --git a/gas/testsuite/gas/arm/pr18256.s b/gas/testsuite/gas/arm/pr18256.s
new file mode 100644
index 0000000..3008d53
--- /dev/null
+++ b/gas/testsuite/gas/arm/pr18256.s
@@ -0,0 +1 @@
+   LDC p0, c0, =.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]