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]

[arm] Stack alignment in crt?.asm


The following patch makes crti.asm and crtn.asm push/pop an extra register. 
This ensures that proper stack alignment is preserved.

Tested with cross to arm-none-elf.
Ok?

Paul

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.

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	3 May 2004 21:26:11 -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	3 May 2004 21:29:26 -0000
@@ -43,17 +43,18 @@
 	# 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}
+	ldmdb	fp, {r3, 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]