On Wed, May 04, 2016 at 02:07:06PM -0500, Segher Boessenkool wrote:
On Wed, May 04, 2016 at 07:54:03PM +0100, Mark Cave-Ayland wrote:
And the bl clobbers at least r4,r5.
I'm sorry but I still don't understand? __switch_context loads a completely new CPU state from the stack in order to switch context so actually every single register gets clobbered. But we preserve the original link register in a local variable to ensure that we can jump back to where we were upon return.
If your asm clobbers all regs, the asm needs to say it does.
So this function clobbers all callee-save registers, but you want it to return to the caller anyway? And that is expected to work?
Mark and I talked on IRC. It turns out __switch_context does not switch the context, but also calls the target and switches the context back. So there are no such issues; and we don't need to do the call in asm at all (pure C would work fine), but that is a detail.
Segher