From patchwork Thu Sep 30 11:53:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 66149 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 EEC92B6EFE for ; Thu, 30 Sep 2010 21:54:09 +1000 (EST) Received: (qmail 29674 invoked by alias); 30 Sep 2010 11:54:06 -0000 Received: (qmail 29663 invoked by uid 22791); 30 Sep 2010 11:54:05 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 30 Sep 2010 11:53:59 +0000 Received: (qmail 13026 invoked from network); 30 Sep 2010 11:53:57 -0000 Received: from unknown (HELO ?192.168.0.100?) (yao@127.0.0.2) by mail.codesourcery.com with ESMTPA; 30 Sep 2010 11:53:57 -0000 Message-ID: <4CA47A4A.5050404@codesourcery.com> Date: Thu, 30 Sep 2010 19:53:46 +0800 From: Yao Qi User-Agent: Thunderbird 2.0.0.24 (X11/20100411) MIME-Version: 1.0 To: Richard Guenther CC: GCC Patches Subject: Re: [patch, ARM] Fix PR45447 References: <4CA47011.4010400@codesourcery.com> <4CA474E7.4070409@codesourcery.com> In-Reply-To: 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 Richard Guenther wrote: > On Thu, Sep 30, 2010 at 1:30 PM, Yao Qi wrote: >> Richard Guenther wrote: >>> On Thu, Sep 30, 2010 at 1:10 PM, Yao Qi wrote: >>>> We created a struct type for va_list to follow ARM ABI, but TREE_CHAIN >>>> (va_list_type) is *not* set properly. This problem causes segmentation >>>> fault reported in PR45447. >>>> >>>> This patch is to address this problem. Regression test for >>>> arm-none-linux-gnueabi is still running. OK to trunk/4.5/4.4 if no >>>> regression? >>> Err - why do you think assigning to TREE_CHAIN makes sense? >> Because 1) TYPE_STUB_DECL and TREE_CHAIN is the same thing, defined in >> tree.h, >> >> #define TYPE_STUB_DECL(NODE) TREE_CHAIN (NODE) >> >> 2) TREE_CHAIN is used also for the similar purpose in i386.c: >> ix86_build_builtin_va_list_abi() >> TREE_CHAIN (record) = type_decl; >> >>> I think you want to use TYPE_STUB_DECL instead. >>> >> Are they different? or I may miss something. > > TREE_CHAIN is non-descriptive, it shouldn't be used if there is > a more descriptive macro available. OK, thanks for your explanation. Here is a new patch. gcc/ 2010-09-30 Yao Qi PR target/45447 * config/arm/arm.c (arm_build_builtin_va_list): Assign va_list_name to TYPE_STUB_DECL (va_list_type). gcc/testsuite/ 2010-09-30 Yao Qi PR target/45447 * gcc.target/arm/pr45447.c: New test. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 2ff010b..a5921fd 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -1205,6 +1205,7 @@ arm_build_builtin_va_list (void) va_list_type); DECL_ARTIFICIAL (va_list_name) = 1; TYPE_NAME (va_list_type) = va_list_name; + TYPE_STUB_DECL (va_list_type) = va_list_name; /* Create the __ap field. */ ap_field = build_decl (BUILTINS_LOCATION, FIELD_DECL, diff --git a/gcc/testsuite/gcc.target/arm/pr45447.c b/gcc/testsuite/gcc.target/arm/pr45447.c new file mode 100644 index 0000000..cb4a442 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr45447.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-g -femit-struct-debug-baseonly" } */ +typedef __builtin_va_list x;