Fix wine_switch_to_stack on ppc

Simon Richter Simon.Richter at hogyros.de
Sat May 31 03:50:11 CDT 2008


The PowerPC ABI expects the caller to allocate space for the return
address on the stack, above the current stack pointer, even if the
address is passed in the link register (usually the address is stored at
SP+4 by the callee).

We allocate 16 bytes (which is the alignment minimum), and create a null
pointer at the address that we pass to the function, so debuggers will
terminate the stack walk here.
---
 libs/wine/port.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/libs/wine/port.c b/libs/wine/port.c
index 76a7586..81e7166 100644
--- a/libs/wine/port.c
+++ b/libs/wine/port.c
@@ -97,6 +97,9 @@ __ASM_GLOBAL_FUNC( wine_switch_to_stack,
                    "mtctr 3\n\t" /* func -> ctr */
                    "mr 3,4\n\t" /* args -> function param 1 (r3) */
                    "mr 1,5\n\t" /* stack */
+                   "subi 1, 1, 16\n\t" /* allocate space for the callee */
+                   "li 0, 0\n\t" /* load zero */
+                   "stw 0, 0(1)\n\t" /* create a bottom stack frame */
                    "bctrl\n\t" /* call ctr */
                    "1:\tb 1b") /* loop */
 #elif defined(__ALPHA__) && defined(__GNUC__)
-- 
1.5.5.2




More information about the wine-patches mailing list