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]

Re: [arm] Stack alignment in crt?.asm


> > 2004-05-04  Paul Brook  <paul@codesourcery.com>
> >
> > 	* config/arm/crti.asm: Push an even number of registers.
> > 	* config/arm/crtn.asm: And restore them.
>
> Ok, except for this one:
> > -	ldmdb	fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, lr}
> > +	ldmdb	fp, {r3, r4, r5, r6, r7, r8, r9, sl, fp, sp, lr}
>
> Which also needs to be fixed to do the frame pointer dance (must load
> via SP if restoring SP).
>
> R.

Applied as follows.

Paul

Index: crti.asm
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/crti.asm,v
retrieving revision 1.3
diff -u -p -r1.3 crti.asm
--- a/crti.asm	28 Sep 2002 15:29:36 -0000	1.3
+++ b/crti.asm	4 May 2004 11:11:41 -0000
@@ -42,12 +42,12 @@
 #ifdef __thumb__
 	.thumb
 	
-	push	{r4, r5, r6, r7, lr}
+	push	{r3, r4, r5, r6, r7, lr}
 #else
 	.arm
 	#  Create a stack frame and save any call-preserved registers
 	mov	ip, sp
-	stmdb	sp!, {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc}
+	stmdb	sp!, {r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc}
 	sub	fp, ip, #4
 #endif
 .endm
Index: crtn.asm
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/crtn.asm,v
retrieving revision 1.3
diff -u -p -r1.3 crtn.asm
--- a/crtn.asm	15 Jun 2003 07:51:33 -0000	1.3
+++ b/crtn.asm	4 May 2004 11:27:47 -0000
@@ -43,17 +43,19 @@
 	# sequences here, it is just not worth it.  Instead keep things
 	# simple.  Restore all the save resgisters, including the link
 	# register and then perform the correct function return instruction.
+	# We also save/restore r3 to ensure stack alignment.
 .macro FUNC_END
 #ifdef __thumb__
 	.thumb
 	
-	pop	{r4, r5, r6, r7}
+	pop	{r3, r4, r5, r6, r7}
 	pop	{r3}
 	mov	lr, r3
 #else
 	.arm
 	
-	ldmdb	fp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, lr}
+	sub	sp, fp, #40
+	ldmfd	sp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, lr}
 #endif
 	
 #if defined __THUMB_INTERWORK__ || defined __thumb__


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