Mac OSX x86 stack fixing patch

Nick Burns adger44 at hotmail.com
Fri Jun 2 03:46:41 CDT 2006


Here is a patch to use the new 'force_align_arg_pointer' and 'mstackrealign' 
directives of the new XCode 2.3.

###Notes from patch###
***You will need XCode 2.3 or better to use this patch***

****WINE MUST BE CONFIGURED WITH THE FOLLOWING EXPORT****
export CFLAGS='-g -O1'
(the -g is not needed -- but what the hell makes it easier to debug)
(Read the notes below to find out why...)

This patch will fix the stack problems when running windows apps on Mac OSX 
under wine
Windows uses a  4 byte algined stack
Mac OSX uses a 16 byte algined stack

This leads to windows applications working (luckily) 1/4 of the time (when 
the stack is aligned)

This patch activates a new gcc extension 
force_align_arg_pointer/mstackrealign
This extension will realign the stack (to native) when entering specified 
functions

So a windows application calls a wine function --
(Stack possibilities aligned to esp % 16 = {0, 4, 8, 12})
    Before:
        Call Mac OSX function with esp % 16 = {0, 4, 8, 12}
    After:
        Coming into function with esp % 16 = {0, 4, 8, 12}
        Align stack to 16 (this does take a register and extra instructions)
        Call Mac OSX function with esp % 16 = {0}

TODO: The change to 'dlls/msvcrt/Makefile.in' needs to be selective 
otherwise it may cause problems with older gcc's

-----
NOTE: Mac OSX wine needs this patch to function correctly
      It will not help older gcc's

NOTE: Due to a bug (has some patches out there)
      The realignment has problems with -O2 and above
      .: -O1 is used (when a fix is released to the public this should be 
checked)

- Nick

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winePatch_Stack_MacOSXx86.diff
Type: application/octet-stream
Size: 5891 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20060602/beddd86a/winePatch_Stack_MacOSXx86.obj


More information about the wine-patches mailing list