From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 13 17:46:43 2011 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D94461065670 for ; Thu, 13 Jan 2011 17:46:43 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com [209.85.215.182]) by mx1.freebsd.org (Postfix) with ESMTP id 72B9E8FC16 for ; Thu, 13 Jan 2011 17:46:43 +0000 (UTC) Received: by eyf6 with SMTP id 6so985519eyf.13 for ; Thu, 13 Jan 2011 09:46:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=8CVSniCoKc0EagqUKN2JI3YFn7Ibt5vhW1yY1MOrenk=; b=cGXcPBU1bv1XE5mHzTXX6WzmDndczLk7ldRTytj3qltcTuNvAnGzymCsSgx2SIfgud mjsImwGk4G072ZHwBknE2TasTwFtFYBltDZAVewJUv7kkV/ZMm9NObJ0WrwVe9Ad1T3O yRMz2sVku2wu8Yy4q1wCdSb3oGYC/hUQY7os8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=U8GTqxUh5VQbeYbF0W5G2POJ1GCFKGmCfcosSo2+Thf2Mgk8Q2DMTkpeW3FPe/e/fx gkgvUOpsKI+ANoKzI7iy6s5Z+0crJONAri/BieQAf3J6BLoK//j7FwmWr7QzTf987NSf EsN3SRMUh0crsRTweXUXLnstpKEg61t03r8nc= MIME-Version: 1.0 Received: by 10.213.32.193 with SMTP id e1mr2516713ebd.74.1294939140195; Thu, 13 Jan 2011 09:19:00 -0800 (PST) Received: by 10.213.22.14 with HTTP; Thu, 13 Jan 2011 09:19:00 -0800 (PST) Date: Thu, 13 Jan 2011 12:19:00 -0500 Message-ID: From: Ryan Stone To: FreeBSD Hackers Content-Type: text/plain; charset=ISO-8859-1 Cc: Subject: What does the FreeBSD/i386 ABI say about stack alignment? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2011 17:46:43 -0000 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.