corrupted call stack
|Definition of Done:|
Enabling stack checking for eCos on the µBlaze CPU runs immediately into an assertion, because the reserved area on top/bottom of the stack is overwritten.
Used toolchain: microblazeel-unknown-linux-gnu-gcc
We analyzed the generated assembler code and this looks strange:
8806dad8: addik r1, r1, -32
8806dadc: swi r15, r1, 0
8806dae0: swi r19, r1, 28
8806dae4: addk r19, r1, r0
8806dae8: swi r5, r19, 36
8806daec: swi r6, r19, 40
8806daf0: imm -1
8806daf4: brlid r15, -5064 // 0x8806c72c <Cyg_Scheduler_Base::clear_need_reschedule()>
From our understanding the compiler reserves 32 bytes on the stack "addik r1, r1, -32". But some instructions later the stack is used on offset 36 "swi r5, r19, 36" and 40 "swi r5, r19, 40". This results in a corrupted stack, which is detected by eCos stack_check() function.