This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Re: mainthread.cxx - unaligned stack possible
- From: Larice Robert <larice at vidisys dot de>
- To: Jonathan Larmour <jifl at eCosCentric dot com>
- Cc: ecos-patches at sources dot redhat dot com
- Date: Sun, 9 Mar 2003 18:42:42 +0100 (CET)
- Subject: 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
Hello Jonathan Larmour,
obviously the linker does not what you thought.
i've a small test case here:
file alignment.c :
char obj0[3][5];
char obj1[3][5];
char obj2[3][5];
char obj3[3][5];
main() {;}
file Makefile :
prefix=/u2/larice/tools-sh-elf-v2/bin/sh-elf-
all :
$(prefix)gcc -ml -m3 -o alignment alignment.c
$(prefix)nm alignment | grep obj
produces the following output :
00002b37 B _obj0
00002b46 B _obj1
00002b28 B _obj2
00002b55 B _obj3
obviously obj0 and obj3 are NOT 32 bit aligned.
several month ago i've sent a patch to fix this for 200 or so global
arrays occuring in the ecos source code.
(http://sources.redhat.com/ml/ecos-patches/2002-06/msg00021.html)
all of them 2 dimensional char arrays, which are used for
stack purpose or for other things requiring some alignment.
would you please consider to apply this patch, or something else to
fix this ? this is a really uggly problem of ecos and would well be
repaired in the upcomming 2.0 .
Thank you,
Robert Larice