public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/56807] New: mingw32: Conflict between stack realignment and stack probe destroys function argument in EAX
@ 2013-04-02  7:45 achurch+gcc at achurch dot org
  2013-04-02  7:47 ` [Bug target/56807] " achurch+gcc at achurch dot org
                   ` (25 more replies)
  0 siblings, 26 replies; 27+ messages in thread
From: achurch+gcc at achurch dot org @ 2013-04-02  7:45 UTC (permalink / raw)
  To: gcc-bugs


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


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2014-02-20 14:44 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-02  7:45 [Bug target/56807] New: mingw32: Conflict between stack realignment and stack probe destroys function argument in EAX achurch+gcc at achurch dot org
2013-04-02  7:47 ` [Bug target/56807] " achurch+gcc at achurch dot org
2013-04-02  7:48 ` achurch+gcc at achurch dot org
2013-04-02  7:53 ` achurch+gcc at achurch dot org
2013-05-15 11:59 ` ktietz at gcc dot gnu.org
2013-12-05 23:45 ` ktietz at gcc dot gnu.org
2013-12-06  6:20 ` achurch+gcc at achurch dot org
2013-12-06 13:42 ` ktietz at gcc dot gnu.org
2013-12-06 16:52 ` achurch+gcc at achurch dot org
2013-12-10 16:37 ` ktietz at gcc dot gnu.org
2013-12-10 16:40 ` ktietz at gcc dot gnu.org
2013-12-10 16:52 ` ktietz at gcc dot gnu.org
2013-12-10 16:53 ` ktietz at gcc dot gnu.org
2013-12-11  6:09 ` achurch+gcc at achurch dot org
2013-12-11  8:34 ` ktietz at gcc dot gnu.org
2013-12-11  8:51 ` ebotcazou at gcc dot gnu.org
2013-12-11 14:06 ` ktietz at gcc dot gnu.org
2013-12-11 15:53 ` achurch+gcc at achurch dot org
2013-12-16 19:05 ` BugMaster at narod dot ru
2013-12-16 19:20 ` hjl.tools at gmail dot com
2013-12-16 19:31 ` BugMaster at narod dot ru
2013-12-16 19:32 ` BugMaster at narod dot ru
2013-12-16 21:33 ` hjl.tools at gmail dot com
2013-12-16 22:04 ` BugMaster at narod dot ru
2013-12-16 22:56 ` ktietz at gcc dot gnu.org
2014-02-14  9:30 ` ebotcazou at gcc dot gnu.org
2014-02-20 14:44 ` ktietz at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).