This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos 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: mainthread.cxx - unaligned stack possible


Scott Furman wrote:


eCos provides the stack for main() when building with libc startup support and CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM is defined. However, the stack is declared as an array of cyg_uint8, so there is the possibility that it is unaligned.

Hmm.. I thought the linker was meant to do this for statics/globals. Oh well, let's err on the side of caution...


> The attached trivial fix ensures that the stack
is at least octlet-aligned. (Does any architecture require an alignment stricter than 8 bytes ?)

Some can. I've checked in a slightly better version (attached).


Jifl
--
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[  can rejoice because thorns have roses." -Lincoln   ]-- Opinions==mine
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/startup/current/ChangeLog,v
retrieving revision 1.7
diff -u -5 -p -r1.7 ChangeLog
--- ChangeLog	24 Feb 2003 14:27:31 -0000	1.7
+++ ChangeLog	7 Mar 2003 11:35:05 -0000
@@ -1,5 +1,9 @@
+2003-03-07  Jonathan Larmour  <jifl at eCosCentric dot com>
+
+	* src/mainthread.cxx: Align stack to relevant architecture alignment.
+
 2003-02-24  Jonathan Larmour  <jifl at eCosCentric dot com>
 
 	* cdl/startup.cdl: Fix doc link.
 
 2002-04-09  Jonathan Larmour  <jlarmour at redhat dot com>
Index: src/mainthread.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/startup/current/src/mainthread.cxx,v
retrieving revision 1.3
diff -u -5 -p -r1.3 mainthread.cxx
--- src/mainthread.cxx	23 May 2002 23:07:12 -0000	1.3
+++ src/mainthread.cxx	7 Mar 2003 11:35:05 -0000
@@ -102,11 +102,12 @@ cyg_libc_invoke_main( CYG_ADDRWORD );
 #  undef CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE
 #  define CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
 # endif
 #endif
 
-static cyg_uint8 cyg_libc_main_stack[ CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE ];
+static cyg_uint8 cyg_libc_main_stack[ CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE ]
+  CYGBLD_ATTRIB_ALIGN(CYGARC_ALIGNMENT);
 
 #else // !ifdef CYGSEM_LIBC_MAIN_STACK_FROM_SYSTEM
 
 extern char *cyg_libc_main_stack;
 extern int cyg_libc_main_stack_size;

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