[OpenBIOS] [PATCH 2/4] ppc: add new context handler
Mark Cave-Ayland
mark.cave-ayland at ilande.co.uk
Tue May 3 22:03:48 CEST 2016
On 02/05/16 18:35, Segher Boessenkool wrote:
>> It seems the problem John was seeing is related to the compile flags in
>> that the asm above don't work correctly when the binary is compiled with
>> -Os. For comparison here is what I see with the different optimisation
>> settings:
>>
>> -O0 (works):
>>
>> 0xfff08350 <+68>: mflr r9
>> 0xfff08354 <+72>: stw r9,8(r31)
>> 0xfff08358 <+76>: bl 0xfff08060 <__switch_context>
>> 0xfff0835c <+80>: lwz r9,8(r31)
>> 0xfff08360 <+84>: mtlr r9
>>
>> -Os (broken):
>>
>> 0xfff082a8 <+32>: mflr r9
>> 0xfff082ac <+36>: bl 0xfff08060 <__switch_context>
>> 0xfff082b0 <+40>: mtlr r9
>>
>> So the optimiser has decided to remove the storage to/from the lr stack
>> variable which of course means that the lr value isn't being preserved.
>> Do I somehow need to mark the "r" (lr) as clobbered or something else?
>
> 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.
ATB,
Mark.
More information about the OpenBIOS
mailing list