Date: Thu, 13 Jan 2011 12:19:00 -0500 From: Ryan Stone <rysto32@gmail.com> To: FreeBSD Hackers <hackers@freebsd.org> Subject: What does the FreeBSD/i386 ABI say about stack alignment? Message-ID: <AANLkTikrsHUO3M%2Bfvo0kO%2B3dPq8OHu5L2zBf3fa3jL2x@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
I've been trying to get an application compiled with gcc 4.5.1 running on FreeBSD 8.1, but it's been crashing during startup with a SIGBUS. It turns out that the problem is that gcc is issuing SSE instructions(in my case, a movdqa) that assume that the stack will be aligned to a 16-byte boundary. It seems that Linux/i386 guarantees this, and I worry that gcc has extended this assumption to all i386 architectures. I'm assuming that FreeBSD doesn't make any such promises based on the fact that I'm getting crashes. There does seem to be a flag (-mstackrealign) that you can set to force gcc to align the stack to what it wants, but that pessimizes the generated code a bit. Some googling would seem to indicate that -mpreferred-stack-boundary won't always handle this problem correctly. Any ideas? My inclination, at least for our local source tree here at $WORK, would be to accommodate gcc and guarantee the stack alignment that it wants rather than pessimize our application. It seems we have an old local patch/hack in our FreeBSD 6.1 tree(apparently based on this: http://www.freebsd.org/cgi/getmsg.cgi?fetch=438552+0+/usr/local/www/db/text/2000/freebsd-current/20000507.freebsd-current). I believe that this patch is the reason why we haven't seen the problem when running on 6.1, but the patch doesn't seem to work anymore on 8.1.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikrsHUO3M%2Bfvo0kO%2B3dPq8OHu5L2zBf3fa3jL2x>