[ECOS] Re: Wrong declaration of idle_thread_stack

Uwe Kindler ukindler@htwm.de
Thu Jan 22 13:46:00 GMT 2004

Hello Eric,

> > 2. From hardware point of view of H8S, every section in different memory
> > region should start with even address that means ALIGN(2) (least
> > bit should be zero).
> So ALL variables needs to be alligned? every char? So if I use a char (in
> .bss section) in my program (.text section) is has to be alligned.
> And if I use a char from the middle of a array like
> char test[10];
>  *(char*)(&test[1]) = 5;
> I will get an allignment error?

No - "every section in different memory region should start with even
address" means that the start address of the section should be even if it
starts within a new memory region. The char data inside does not have to be
aligned. The h8300-elf-gcc compiler aligns chars to 1 byte boundaries, short
to 2 byte boundaries and int & long to 4 byte boundaries. It also aligns
arrays in the same way - char[] (1 byte aligned), short[] (2 byte aligned)
int[] (4 byte aligned).

Changing the idle_thread_stack alignment to a 4 byte boundary would solve
the problem - at least for H8S architecture. But it might be possible that
there are other char arrays within the eCos source wich require an
alignment. So this would be a serious problem. The only solution is to add
an compiler flag to the h8300-elf-gcc wich changes the behaviour of the
compiler to procude "eCos compatible code" - I will try do this fix. But in
my opinion it is not the best idea to declare char arrays and then expect
that the compiler would align them to a 4 byte boundary. This  works as long
as there will be the first compiler wich does not behave in the right way -
and the h8300-elf-gcc is not the first one.

Regards, Uwe

Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

More information about the Ecos-discuss mailing list