From patchwork Wed Jul 7 15:58:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Haley X-Patchwork-Id: 58128 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D3194B6F0C for ; Thu, 8 Jul 2010 01:59:06 +1000 (EST) Received: (qmail 29045 invoked by alias); 7 Jul 2010 15:59:03 -0000 Received: (qmail 29035 invoked by uid 22791); 7 Jul 2010 15:59:02 -0000 X-SWARE-Spam-Status: No, hits=-5.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_BF, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Jul 2010 15:58:58 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o67FwulO019134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 7 Jul 2010 11:58:56 -0400 Received: from zebedee.pink (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o67FwtEg028671; Wed, 7 Jul 2010 11:58:55 -0400 Message-ID: <4C34A43E.2020207@redhat.com> Date: Wed, 07 Jul 2010 16:58:54 +0100 From: Andrew Haley User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Thunderbird/3.0 MIME-Version: 1.0 To: GCC Patches , libffi-discuss@sourceware.org Subject: [PATCH] x86: Align the stack to 16-bytes before making the call X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Applied for Neil Roberts to gcc trunk. Andrew. From 89d2865bcf30bc020399a74b3053d46ef7750a28 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 26 Feb 2010 14:42:49 +0000 Subject: [PATCH] x86: Align the stack to 16-bytes before making the call If gcc is targetting i686 then it will use SSE registers for the floating point operations. It will then sometimes use 16-byte temporary variables on the stack to store the registers and it will use aligned instructions to access them. This will segfault if the variable is not aligned to 16-bytes. Apparently GCC assumes that the stack is 16-byte aligned when a function is entered and it uses this to position its temporary variables. Therefore libffi needs to align the stack or the called function will crash in some circumstances. 2010-07-07 Neil Roberts * src/x86/sysv.S (ffi_call_SYSV): Align the stack pointer to 16-bytes. Index: libffi/src/x86/sysv.S =================================================================== --- libffi/src/x86/sysv.S (revision 161921) +++ libffi/src/x86/sysv.S (working copy) @@ -48,6 +48,9 @@ movl 16(%ebp),%ecx subl %ecx,%esp + /* Align the stack pointer to 16-bytes */ + andl $0xfffffff0, %esp + movl %esp,%eax /* Place all of the ffi_prep_args in position */