This is the mail archive of the binutils@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]

[patch] Extend ARM .movsp for nested functions


For nested functions gcc generates the following code:

        str     ip, [sp, #-4]!
        add     ip, sp, #4
        stmfd   sp!, {fp, ip, lr, pc}
        sub     fp, ip, #8

The patch below extends the .movsp directive to allow this to be conveniently 
described in unwinding information.

Ok?

Paul

2006-09-14  Paul Brook  <paul@codesourcery.com>

	gas/
	* config/tc-arm.c (s_arm_unwind_movsp): Add offset argument.
	* doc/c-arm.texi (movsp): Document offset argument.

Index: gas/config/tc-arm.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/gas/config/tc-arm.c,v
retrieving revision 1.250.2.32
diff -u -p -r1.250.2.32 tc-arm.c
--- gas/config/tc-arm.c	8 Sep 2006 22:36:13 -0000	1.250.2.32
+++ gas/config/tc-arm.c	14 Sep 2006 01:28:29 -0000
@@ -3633,6 +3633,7 @@ s_arm_unwind_movsp (int ignored ATTRIBUT
 {
   int reg;
   valueT op;
+  int offset;
 
   reg = arm_reg_parse (&input_line_pointer, REG_TYPE_RN);
   if (reg == FAIL)
@@ -3641,6 +3642,16 @@ s_arm_unwind_movsp (int ignored ATTRIBUT
       ignore_rest_of_line ();
       return;
     }
+
+  /* Optional constant.	 */
+  if (skip_past_comma (&input_line_pointer) != FAIL)
+    {
+      if (immediate_for_directive (&offset) == FAIL)
+	return;
+    }
+  else
+    offset = 0;
+
   demand_empty_rest_of_line ();
 
   if (reg == REG_SP || reg == REG_PC)
@@ -3658,7 +3669,7 @@ s_arm_unwind_movsp (int ignored ATTRIBUT
 
   /* Record the information for later.	*/
   unwind.fp_reg = reg;
-  unwind.fp_offset = unwind.frame_size;
+  unwind.fp_offset = unwind.frame_size - offset;
   unwind.sp_restored = 1;
 }
 
Index: gas/doc/c-arm.texi
===================================================================
RCS file: /var/cvsroot/src-cvs/src/gas/doc/c-arm.texi,v
retrieving revision 1.37.2.4
diff -u -p -r1.37.2.4 c-arm.texi
--- gas/doc/c-arm.texi	8 Sep 2006 22:36:13 -0000	1.37.2.4
+++ gas/doc/c-arm.texi	14 Sep 2006 12:31:51 -0000
@@ -574,8 +574,10 @@ A positive value indicates the function 
 decrementing the stack pointer.
 
 @cindex @code{.movsp} directive, ARM
-@item .movsp @var{reg}
-Tell the unwinder that @var{reg} contains the current stack pointer.
+@item .movsp @var{reg} [, #@var{offset}]
+Tell the unwinder that @var{reg} contains and offset from the current
+stack pointer.  If @var{offset} is not specified then it is assumed to be
+zero.
 
 @cindex @code{.setfp} directive, ARM
 @item .setfp @var{fpreg}, @var{spreg} [, #@var{offset}]


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