From patchwork Thu Jul 14 10:41:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 13790 Received: (qmail 34575 invoked by alias); 14 Jul 2016 10:41:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 34558 invoked by uid 89); 14 Jul 2016 10:41:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=SIM, demon X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 14 Jul 2016 10:41:36 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFB60D6848 for ; Thu, 14 Jul 2016 10:41:35 +0000 (UTC) Received: from localhost.localdomain.redhat.com (vpn1-7-90.ams2.redhat.com [10.36.7.90]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6EAfWsN023201 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 14 Jul 2016 06:41:35 -0400 From: Nick Clifton To: gdb-patches@sourceware.org Subject: Commit: ARM SIM Date: Thu, 14 Jul 2016 11:41:32 +0100 Message-ID: <87vb088psz.fsf@redhat.com> MIME-Version: 1.0 Hi Guys, I have been testing the ARM simulator against various illegal binaries and I have come across a couple of small problems. The first is that the sim will complain about illegal arguments to the 64-bit multiply instructions (good), but it will complain even if the user does not want to see the complaints (bad). So I have added code to restrict the error messages to when debugging is enabled. The second fix is to the SWIopen() function, which used to assume that the flags provided in register r1 were always valid. This patch adds code to check the flags, and ignore invalid ones. Cheers Nick sim/arm/ChangeLog 2016-07-14 Nick Clifton * armemu.c (Multiply64): Only issue error messages about invalid arguments if debugging is enabled. * armos.c (ARMul_OSHandleSWI): Ignore invalid flags. 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)