[ECOS] Stack access violations in eCos
Thu Apr 3 09:35:00 GMT 2003
Jonathan Larmour <jifl@eCosCentric.com> writes:
> One _potential_ problem is that some align the stack to say 16 byte
> alignment *but* then go and take off some space for a saved context -
> normally sizeof(HAL_SavedRegisters) but there are some differences in
> different architectures. The result is something that may now only be
> 4 byte aligned, which may cause problems for those archs that need
> more, most obviously FP doubles being 8 byte aligned.
In theory the size of HAL_SavedRegisters should preserve the alignment
after being pushed on to the stack. The MIPS structures even has some
padding to ensure this. But we only need to keep the alignment of the
fields within the structure. Nothing is going to be pushed on top of
it since this is always the "top" object on the stack during context
switch. The 16 byte alignment is what we need to stack to be after the
context is restored.
Interrupts and exceptions usually drop the stack by an exception
decrement value, which is sizeof(HAL_SavedRegisters) plus a safety
margin plus some padding to align it correctly.
Nick Garnett eCos Kernel Architect
http://www.ecoscentric.com/ The eCos and RedBoot experts
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