On Tue, May 03, 2016 at 10:12:09PM +0100, Mark Cave-Ayland wrote:
Oh, yeah, that's another problem: a call can clobber all volatile (caller-save) registers. The best solution is to write this whole thing in actual assembler, instead of fighting the compiler to get just the assembler you want ;-)
Heh actually the bug was a missing volatile qualifier from the __context pointer which is interesting since this code is used almost boilerplate for other architectures - I'll spin up a patch to update the other archs once this has gone in. The v2 version of the patchset contains this correction though.
That is just a workaround. It might well work, and it can also break at any time.
Can you explain further? The v2 patch uses a single register marked as clobber for mflr/mtlr and the volatile modifier for __context ensures that the old value being written to the stack doesn't get optimised away by the compiler. What else am I missing?
A normal (ABI-following) function can clobber all of r9..r12, so that "bl" instruction can, too. If the function it calls is special (so at least written as assembler), things are different of course.
Segher