emmanuel maillard e.rsz@libertysurf.fr writes:
changelog Add darwin/ppc support in THREAD_InitStack
I'm not sure what the problem is, but the fix doesn't look right at all. Tib.StackBase should point to the base of the stack as it has been allocated, no matter how it's used later on. Most likely you need to fix wine_switch_to_stack or something like that.
Emmanuel,
Can you try the following fix and if it works send a patch for it?
libs/wine/port.c -------------- elif defined(__powerpc__) && defined(__APPLE__) 136 __ASM_GLOBAL_FUNC( wine_switch_to_stack, 137 "mtctr r3\n\t" /* func -> ctr */ 138 "mr r3,r4\n\t" /* args -> function param 1 (r3) */ 139 "mr r1,r5\n\t" /* stack */ + 139 "add r5,r5,0xf\n\t" /* adjust the stack pointer add an extra 16 bits for the function return ptr stored at 8(SP) */ 140 "bctr\n" /* call ctr */ 141 "1:\tb 1b"); /* loop */
Thanks,
Pierre
Le 10 mai 04, à 21:01, Alexandre Julliard a écrit :
emmanuel maillard e.rsz@libertysurf.fr writes:
changelog Add darwin/ppc support in THREAD_InitStack
I'm not sure what the problem is, but the fix doesn't look right at all. Tib.StackBase should point to the base of the stack as it has been allocated, no matter how it's used later on. Most likely you need to fix wine_switch_to_stack or something like that.
-- Alexandre Julliard julliard@winehq.org
This SF.Net email is sponsored by Sleepycat Software Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver higher performing products faster, at low TCO. http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3 _______________________________________________ Darwine-devel mailing list Darwine-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/darwine-devel
I am sorry I meant:
Le 22 mai 04, à 13:20, Pierre d'Herbemont a écrit :
libs/wine/port.c
elif defined(__powerpc__) && defined(__APPLE__) 136 __ASM_GLOBAL_FUNC( wine_switch_to_stack, 137 "mtctr r3\n\t" /* func -> ctr */ 138 "mr r3,r4\n\t" /* args -> function param 1 (r3) */ 139 "mr r1,r5\n\t" /* stack */
+139 "add r5,r5,-0xf\n\t" /* adjust the stack pointer add an extra 16 bits for the function return ptr stored at 8(SP) */
and not "0xf" you guessed.
I'm not sure what the problem is
According to: http://developer.apple.com/documentation/DeveloperTools/Conceptual/ MachORuntime/index.html?http://developer.apple.com/documentation/ DeveloperTools/Conceptual/MachORuntime/2rt_powerpc_abi/ chapter_9_section_5.html
"The calling routine’s linkage area holds a number of values, some of which are saved by the calling routine and some by the called routine. The elements within the linkage area are as follows: • The Link Register (LR) value is saved at 8(SP) by the called routine if it chooses to do so. • The Condition Register (CR) value may be saved at 4(SP) by the called routine. As with the Link Register value, the called routine is not required to save this value."
The trouble is that Tib.StackBase points to the top of the stack frame, and as the stack grows down, if the function called by wine_switch_to_stack wants to save its link register it will try to write at Tib.StackBase+8 which will end up in an error, since the stack is allocated from Tib.StackBase to (Tib.StackBase - stack_size). And actually start_process saves its LR.
Pierre
Hi,
elif defined(__powerpc__) && defined(__APPLE__) 136 __ASM_GLOBAL_FUNC( wine_switch_to_stack, 137 "mtctr r3\n\t" /* func -> ctr */ 138 "mr r3,r4\n\t" /* args -> function param 1 (r3) */ 139 "mr r1,r5\n\t" /* stack */
+139 "add r5,r5,-0xf\n\t" /* adjust the stack pointer add an extra 16 bits for the function return ptr stored at 8(SP) */
and not "0xf" you guessed.
This doesn't compile.
According to: http://developer.apple.com/documentation/DeveloperTools/Conceptual/ MachORuntime/index.html?http://developer.apple.com/documentation/ DeveloperTools/Conceptual/MachORuntime/2rt_powerpc_abi/ chapter_9_section_5.html
"The calling routine’s linkage area holds a number of values, some of which are saved by the calling routine and some by the called routine. The elements within the linkage area are as follows: • The Link Register (LR) value is saved at 8(SP) by the called routine if it chooses to do so. • The Condition Register (CR) value may be saved at 4(SP) by the called routine. As with the Link Register value, the called routine is not required to save this value."
The trouble is that Tib.StackBase points to the top of the stack frame, and as the stack grows down, if the function called by wine_switch_to_stack wants to save its link register it will try to write at Tib.StackBase+8 which will end up in an error, since the stack is allocated from Tib.StackBase to (Tib.StackBase - stack_size). And actually start_process saves its LR.
To adjust stack with only 16 bytes is not enought, this fix the segmentation fault problem but corrupt the stack. Using 256 bytes adjustement (as done by _adjust_sp(void *) ) work fine : no seg fault, no stack corruption.
Changelog : Adjust stack pointer in wine_switch_to_stack to prevent segmentation fault on darwin/ppc.
emmanuel
Sorry this is the good patch :
Changelog Adjust stack pointer in wine_switch_to_stack to prevent segmentation fault on darwin/ppc.
emmanuel
Le 22 mai 04, à 15:33, emmanuel maillard a écrit :
Hi,
elif defined(__powerpc__) && defined(__APPLE__) 136 __ASM_GLOBAL_FUNC( wine_switch_to_stack, 137 "mtctr r3\n\t" /* func -> ctr */ 138 "mr r3,r4\n\t" /* args -> function param 1 (r3) */ 139 "mr r1,r5\n\t" /* stack */
+139 "add r5,r5,-0xf\n\t" /* adjust the stack pointer add an extra 16 bits for the function return ptr stored at 8(SP) */
and not "0xf" you guessed.
This doesn't compile.
According to: http://developer.apple.com/documentation/DeveloperTools/Conceptual/ MachORuntime/index.html?http://developer.apple.com/documentation/ DeveloperTools/Conceptual/MachORuntime/2rt_powerpc_abi/ chapter_9_section_5.html
"The calling routine’s linkage area holds a number of values, some of which are saved by the calling routine and some by the called routine. The elements within the linkage area are as follows: • The Link Register (LR) value is saved at 8(SP) by the called routine if it chooses to do so. • The Condition Register (CR) value may be saved at 4(SP) by the called routine. As with the Link Register value, the called routine is not required to save this value."
The trouble is that Tib.StackBase points to the top of the stack frame, and as the stack grows down, if the function called by wine_switch_to_stack wants to save its link register it will try to write at Tib.StackBase+8 which will end up in an error, since the stack is allocated from Tib.StackBase to (Tib.StackBase - stack_size). And actually start_process saves its LR.
To adjust stack with only 16 bytes is not enought, this fix the segmentation fault problem but corrupt the stack. Using 256 bytes adjustement (as done by _adjust_sp(void *) ) work fine : no seg fault, no stack corruption.
Changelog : Adjust stack pointer in wine_switch_to_stack to prevent segmentation fault on darwin/ppc.
<libswine_port.diff>
emmanuel