Patchwork [ARM] Fix PR45447

login
register
mail settings
Submitter Yao Qi
Date Sept. 30, 2010, 11:10 a.m.
Message ID <4CA47011.4010400@codesourcery.com>
Download mbox | patch
Permalink /patch/66145/
State New
Headers show

Comments

Yao Qi - Sept. 30, 2010, 11:10 a.m.
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?
Richard Guenther - Sept. 30, 2010, 11:17 a.m.
On Thu, Sep 30, 2010 at 1:10 PM, Yao Qi <yao@codesourcery.com> 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?
I think you want to use TYPE_STUB_DECL instead.

> --
> Yao Qi
> CodeSourcery
> yao@codesourcery.com
> (650) 331-3385 x739
>
Yao Qi - Sept. 30, 2010, 11:30 a.m.
Richard Guenther wrote:
> On Thu, Sep 30, 2010 at 1:10 PM, Yao Qi <yao@codesourcery.com> 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.
Richard Guenther - Sept. 30, 2010, 11:33 a.m.
On Thu, Sep 30, 2010 at 1:30 PM, Yao Qi <yao@codesourcery.com> wrote:
> Richard Guenther wrote:
>> On Thu, Sep 30, 2010 at 1:10 PM, Yao Qi <yao@codesourcery.com> 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.

> --
> Yao Qi
> CodeSourcery
> yao@codesourcery.com
> (650) 331-3385 x739
>

Patch

gcc/
2010-09-30  Yao Qi  <yao@codesourcery.com>

	PR target/45447	
	* config/arm/arm.c (arm_build_builtin_va_list): Assign
	va_list_name to TREE_CHAIN (va_list_type). 

gcc/testsuite/
2010-09-30  Yao Qi  <yao@codesourcery.com>

	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..f61006a 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;
+  TREE_CHAIN (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;