mainthread.cxx - unaligned stack possible
Larice Robert
larice@vidisys.de
Mon Mar 10 07:56:00 GMT 2003
> On Sun, 2003-03-09 at 10:42, Larice Robert wrote:
> > > 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:
> >
> >
>
> But, you didn't add the "alignment magic" that Jonathan did.
> Try it like this:
>
> #define CYGBLD_ATTRIB_ALIGN(__align__) __attribute__((aligned(__align__)))
> ...
Hello Gary Thomas,
please excuse my misarable english, i think you've got my letter
wrong. my sentence:
> > obviously the linker does not what you thought.
was meant in the following way:
Jonathan had the impression the linker will automatically add sufficient
alignment to a global char array. And I reply, this is not the case.
of course adding the __attribute__(aligned...)) is perfectly ok to
solve the issue.
But once you have understood, that such an attribute is necessairy,
then there is a important consequence:
Don't fix just one or the other such global char array,
but fix ALL of them in the ecos source code.
as i've allready said, in
(http://sources.redhat.com/ml/ecos-patches/2002-06/msg00021.html)
is a fix for apporoximately 200 such occurences in ecos.
Thank you,
Robert Larice
More information about the Ecos-patches
mailing list