This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib 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] Arm startup code stack alignment


The Arm startup code allocates stack space for argv[]. The attached patch 
ensures that the stack pointer remains aligned to a doubleword boundary, as 
required by the EABI.

Ok?

Paul

2005-03-28  Paul Brook  <paul@codesourcery.com>

libgloss/
 * arm/crt0.S: Ensure doubleword stack alignment.
newlib/
 * libc/sys/arm/crt0.S: Ensure doubleword stack alignment.
Index: libgloss/arm/crt0.S
===================================================================
RCS file: /var/cvsroot/src-cvs/src/libgloss/arm/crt0.S,v
retrieving revision 1.3
diff -u -p -r1.3 crt0.S
--- libgloss/arm/crt0.S	7 Jan 2005 18:01:26 -0000	1.3
+++ libgloss/arm/crt0.S	28 Mar 2005 14:14:48 -0000
 /* Start by setting up a stack */
 #ifdef ARM_RDP_MONITOR
 	/*  Issue Demon SWI to read stack info */
@@ -251,6 +263,11 @@ __change_mode:	
 	add	r3, #4
 	b	.LC15
 .LC14:	
+	/* Ensure doubleword stack alignment.  */
+	mov	r4, sp
+	mov	r5, #7
+	bic	r4, r5
+	mov	sp, r4
 #else
 	add	r2, sp, r0, LSL #2	/* End of args */
 	mov	r3, sp			/* Start of args */
@@ -260,6 +277,8 @@ __change_mode:	
 	strhi	r5, [r2, #-4]!
 	strhi	r4, [r3], #4
 	bhi	.LC13
+	/* Ensure doubleword stack alignment.  */
+	bic	sp, sp, #7
 #endif
 #endif
 
Index: newlib/libc/sys/arm/crt0.S
===================================================================
RCS file: /var/cvsroot/src-cvs/src/newlib/libc/sys/arm/crt0.S,v
retrieving revision 1.10
diff -u -p -r1.10 crt0.S
--- newlib/libc/sys/arm/crt0.S	7 Jan 2005 18:04:39 -0000	1.10
+++ newlib/libc/sys/arm/crt0.S	28 Mar 2005 14:15:05 -0000
@@ -186,6 +198,11 @@ __change_mode:	
 	add	r3, #4
 	b	.LC15
 .LC14:	
+	/* Ensure doubleword stack alignment.  */
+	mov	r4, sp
+	mov	r5, #7
+	bic	r4, r5
+	mov	sp, r4
 #else
 	add	r2, sp, r0, LSL #2	/* End of args */
 	mov	r3, sp			/* Start of args */
@@ -195,6 +212,8 @@ __change_mode:	
 	strhi	r5, [r2, #-4]!
 	strhi	r4, [r3], #4
 	bhi	.LC13
+	/* Ensure doubleword stack alignment.  */
+	bic	sp, sp, #7
 #endif
 #endif
 

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