This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB 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] Small improvements to the ARM simulator to cope with illegal binaries.


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

commit 7df94786e4723ba93d8982e55fc5e652b4b80142
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Jul 14 10:38:07 2016 +0100

    Small improvements to the ARM simulator to cope with illegal binaries.
    
    	* armemu.c (Multiply64): Only issue error messages about invalid
    	arguments if debugging is enabled.
    	* armos.c (ARMul_OSHandleSWI): Ignore invalid flags.

Diff:
---
 sim/arm/ChangeLog | 6 ++++++
 sim/arm/armemu.c  | 6 +++---
 sim/arm/armos.c   | 5 ++++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/sim/arm/ChangeLog b/sim/arm/ChangeLog
index cae6f52..2ce9429 100644
--- a/sim/arm/ChangeLog
+++ b/sim/arm/ChangeLog
@@ -1,3 +1,9 @@
+2016-07-14  Nick Clifton  <nickc@redhat.com>
+
+	* armemu.c (Multiply64): Only issue error messages about invalid
+	arguments if debugging is enabled.
+	* armos.c (ARMul_OSHandleSWI): Ignore invalid flags.
+
 2016-01-10  Mike Frysinger  <vapier@gentoo.org>
 
 	* config.in, configure: Regenerate.
diff --git a/sim/arm/armemu.c b/sim/arm/armemu.c
index 5fde3fd..76f398b 100644
--- a/sim/arm/armemu.c
+++ b/sim/arm/armemu.c
@@ -5950,10 +5950,10 @@ Multiply64 (ARMul_State * state, ARMword instr, int msigned, int scc)
 	;
       else
 #endif
-	if (nRdHi == nRm || nRdLo == nRm)
+	/* BAD code can trigger this result.  So only complain if debugging.  */
+	if (state->Debug && (nRdHi == nRm || nRdLo == nRm))
 	  fprintf (stderr, "sim: MULTIPLY64 - INVALID ARGUMENTS: %d %d %d\n",
 		   nRdHi, nRdLo, nRm);
-
       if (msigned)
 	{
 	  /* Compute sign of result and adjust operands if necessary.  */
@@ -5998,7 +5998,7 @@ Multiply64 (ARMul_State * state, ARMword instr, int msigned, int scc)
       state->Reg[nRdLo] = RdLo;
       state->Reg[nRdHi] = RdHi;
     }
-  else
+  else if (state->Debug)
     fprintf (stderr, "sim: MULTIPLY64 - INVALID ARGUMENTS\n");
 
   if (scc)
diff --git a/sim/arm/armos.c b/sim/arm/armos.c
index c49036f..ea3d229 100644
--- a/sim/arm/armos.c
+++ b/sim/arm/armos.c
@@ -260,7 +260,10 @@ SWIopen (ARMul_State * state, ARMword name, ARMword SWIflags)
     return;
 
   /* Now we need to decode the Demon open mode.  */
-  flags = translate_open_mode[SWIflags];
+  if (SWIflags >= sizeof (translate_open_mode) / sizeof (translate_open_mode[0]))
+    flags = 0;
+  else
+    flags = translate_open_mode[SWIflags];
 
   /* Filename ":tt" is special: it denotes stdin/out.  */
   if (strcmp (buf, ":tt") == 0)


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