This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[PATCH] Off-by-one errors in gcc/config/arm/pr-support.c


I've decided to split this out on its own, since it is an obvious bugfix.

The _Unwind_VRS_Pop routine takes an "op" argument encoded within which
is the number of registers to be popped.  The ARM EHABI encodes register
ranges using a start register and an end register; thus, there is scope
for an off-by-one error and indeed such errors manifest themselves in
the current code in pr-support.c.  The patch fixes these errors, which
will cause failure to correctly unwind the stack in certain cases.

OK? (Could this even be eligible for mainline right now?)

Mark

--

gcc/ChangeLog:

2006-06-22 Mark Shinwell <shinwell@codesourcery.com>

	* config/arm/pr-support.c (gnu_unwind_execute): Fix bug by inserting
	" + 1" in necessary places to pass the correct "number of registers"
	values to _Unwind_VRS_Pop.
Index: gcc/config/arm/pr-support.c
===================================================================
--- gcc/config/arm/pr-support.c	(revision 114900)
+++ gcc/config/arm/pr-support.c	(working copy)
@@ -224,7 +224,7 @@ __gnu_unwind_execute (_Unwind_Context * 
 	    {
 	      /* Pop VFP registers with fldmx.  */
 	      op = next_unwind_byte (uws);
-	      op = ((op & 0xf0) << 12) | (op & 0xf);
+	      op = ((op & 0xf0) << 12) | ((op & 0xf) + 1);
 	      if (_Unwind_VRS_Pop (context, _UVRSC_VFP, op, _UVRSD_VFPX)
 		  != _UVRSR_OK)
 		return _URC_FAILURE;
@@ -253,7 +253,7 @@ __gnu_unwind_execute (_Unwind_Context * 
 	    {
 	      /* Pop iWMMXt D registers.  */
 	      op = next_unwind_byte (uws);
-	      op = ((op & 0xf0) << 12) | (op & 0xf);
+	      op = ((op & 0xf0) << 12) | ((op & 0xf) + 1);
 	      if (_Unwind_VRS_Pop (context, _UVRSC_WMMXD, op, _UVRSD_UINT64)
 		  != _UVRSR_OK)
 		return _URC_FAILURE;
@@ -284,7 +284,7 @@ __gnu_unwind_execute (_Unwind_Context * 
 	    {
 	      /* Pop FPA registers.  */
 	      op = next_unwind_byte (uws);
-	      op = ((op & 0xf0) << 12) | (op & 0xf);
+	      op = ((op & 0xf0) << 12) | ((op & 0xf) + 1);
 	      if (_Unwind_VRS_Pop (context, _UVRSC_FPA, op, _UVRSD_FPAX)
 		  != _UVRSR_OK)
 		return _URC_FAILURE;
@@ -294,7 +294,7 @@ __gnu_unwind_execute (_Unwind_Context * 
 	    {
 	      /* Pop VFP registers with fldmd.  */
 	      op = next_unwind_byte (uws);
-	      op = ((op & 0xf0) << 12) | (op & 0xf);
+	      op = ((op & 0xf0) << 12) | ((op & 0xf) + 1);
 	      if (_Unwind_VRS_Pop (context, _UVRSC_VFP, op, _UVRSD_DOUBLE)
 		  != _UVRSR_OK)
 		return _URC_FAILURE;

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