[Bug target/56807] New: mingw32: Conflict between stack realignment and stack probe destroys function argument in EAX
achurch+gcc at achurch dot org
gcc-bugzilla@gcc.gnu.org
Tue Apr 2 07:45:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56807
Bug #: 56807
Summary: mingw32: Conflict between stack realignment and stack
probe destroys function argument in EAX
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: achurch+gcc@achurch.org
When compiling for mingw32 with an incoming stack boundary less than the
preferred stack boundary, if a non-leaf function with a large (>4000 bytes)
stack size takes arguments in registers, the first argument may be destroyed
depending on the actual stack alignment:
00000000 <_bar>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 e4 f0 and $0xfffffff0,%esp
6: 50 push %eax
7: b8 1c 10 00 00 mov $0x101c,%eax
c: e8 00 00 00 00 call 11 <_bar+0x11>
d: DISP32 ___chkstk_ms
11: 29 c4 sub %eax,%esp
13: 8b 45 f4 mov -0xc(%ebp),%eax
Note that the stack realignment (at 3) takes place after the frame pointer is
saved (at 1) but before the first argument is pushed to the stack (at 6), so
the offset from the frame pointer to the saved first argument is unknown, yet
GCC tries to reload the argument using the frame pointer as a base (at 13). If
the stack is not aligned to a multiple of 16 bytes before the function is
called, the reload will get some random value from the stack instead of the
first argument.
Configure options: --prefix=/usr
--bindir=/usr/i686-pc-linux-gnu/mingw32/gcc-bin/4.7.2
--includedir=/usr/lib/gcc/mingw32/4.7.2/include
--datadir=/usr/share/gcc-data/mingw32/4.7.2
--mandir=/usr/share/gcc-data/mingw32/4.7.2/man
--infodir=/usr/share/gcc-data/mingw32/4.7.2/info
--with-gxx-include-dir=/usr/lib/gcc/mingw32/4.7.2/include/g++-v4
--host=i686-pc-linux-gnu --target=mingw32 --build=i686-pc-linux-gnu
--disable-altivec --disable-fixed-point --without-ppl --without-cloog
--enable-lto --disable-nls --with-system-zlib --enable-obsolete
--disable-werror --enable-secureplt --disable-multilib --disable-libmudflap
--disable-libssp --disable-libgomp
--with-python-dir=/share/gcc-data/mingw32/4.7.2/python
--enable-poison-system-directories --enable-checking=release --disable-libgcj
--enable-libstdcxx-time --disable-libquadmath --enable-languages=c,c++
--with-sysroot=/usr/mingw32
More information about the Gcc-bugs
mailing list