Optimization for size corrupt the stack
Currently I'm developing firmware for STM32F105. Everything worked fine, until I enabled optimization for size.
I traced the problem and came to conclusion, that the stack get corrupted by one concrete function. At the end of the function there is a call to another function. Please see the disassembly:
.......
0800291a: adds r2, #12
0800291c: movs r3, #64 ; 0x40
738 }
0800291e: ldmia.w sp!, {r4, r5, r6, r7, r8, lr}
730 DCD_EP_Tx (pdev, 0x80 | epnum, (uint8_t *)(&CanRxReport
08002922: b.w 0x8002dc4 <DCD_EP_Tx>
734 release_
08002926: mov r0, r6
0800292c: b.w 0x8002566 <release_mutex>
08002930: ldmia.w sp!, {r4, r5, r6, r7, r8, pc}
.......
I omitted large part as it is not relevant for the moment. You can see, the branch to function DCD_EP_Tx(...) is OK, as the stack is properly cleaned up. But the branch to function release_mutex(...) is not correct, because the stack is leaved without popping previously stored values of the registers.
Is this a bug?
(p.s.: Sorry for my English.)
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Brainless
- Solved:
- Last query:
- Last reply: