This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Main stack alignment
- From: Jonathan Larmour <jifl at eCosCentric dot com>
- To: Daniel Lidsten <Daniel dot Lidsten at combitechsystems dot com>
- Cc: ecos discuss list <ecos-discuss at sources dot redhat dot com>
- Date: Fri, 23 May 2003 03:08:42 +0100
- Subject: Re: [ECOS] Main stack alignment
- References: <004B1D7A5257174C9044A1B7BD0E60ED232D55@ratatosk.combitechsystems.com>
Daniel Lidsten wrote:
Hi,
When i allocate two structures in the main loop then they will be place
with an 8 bytes alignment in the main_stack. Why is that?
The stack is declared as:
static cyg_uint8 cyg_libc_main_stack[
CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE ] in mainthread.cxx;
...and placed in the .bss section by the linker script.
The odd thing is that if i declare my structures as static or make them
global, then they are 2-byte aligned. How come? I want my structures to
be 2 byte aligned even when i declare them inside main.
IIRC GCC often takes a pessimistic view of stack alignment and assumes it
may not be well aligned and so aligns it itself.
For static/global stuff, the linker puts it at a well defined address and
can therefore be sure of its address.
You may be able to override GCC's behaviour on the command line depending
on your architecture.
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
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss