Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Jan 2011 08:57:51 +0100
From:      Joerg Sonnenberger <joerg@britannica.bec.de>
To:        freebsd-hackers@freebsd.org, FreeBSD Hackers <hackers@freebsd.org>
Subject:   Re: What does the FreeBSD/i386 ABI say about stack alignment?
Message-ID:  <20110114075751.GA9961@britannica.bec.de>
In-Reply-To: <20110113220052.GL2518@deviant.kiev.zoral.com.ua>
References:  <AANLkTikrsHUO3M%2Bfvo0kO%2B3dPq8OHu5L2zBf3fa3jL2x@mail.gmail.com> <20110113215713.GB5278@britannica.bec.de> <20110113220052.GL2518@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jan 14, 2011 at 12:00:52AM +0200, Kostik Belousov wrote:
> On Thu, Jan 13, 2011 at 10:57:15PM +0100, Joerg Sonnenberger wrote:
> > On Thu, Jan 13, 2011 at 12:19:00PM -0500, Ryan Stone wrote:
> > > 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.
> > 
> > FreeBSD follows the original SYSV ABI. Linux at some point silently
> > decided to redefine the ABI to fit their mindset. I think you want to
> > use a combination of -mpreferred-stack-boundary=4 and
> > -mincoming-stack-boundary=2.
> 
> I think gcc [*] requires 16-byte alignment. Also, it follows the
> policy of not changing the stack alignment through the calls.

Well, yes. GCC decided to force the Linux ABI change down our throat.
It's not an issue if you decide to rebuild all your libraries every
week, but it is a major PITA if you deal with old binary-only
releases.

Joerg



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110114075751.GA9961>