From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23735 invoked by alias); 21 Mar 2011 21:56:36 -0000 Received: (qmail 23693 invoked by uid 22791); 21 Mar 2011 21:56:34 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Mar 2011 21:56:03 +0000 Received: from kpbe12.cbf.corp.google.com (kpbe12.cbf.corp.google.com [172.25.105.76]) by smtp-out.google.com with ESMTP id p2LLu1V1012134 for ; Mon, 21 Mar 2011 14:56:01 -0700 Received: from vxk12 (vxk12.prod.google.com [10.241.35.140]) by kpbe12.cbf.corp.google.com with ESMTP id p2LLtxJO031249 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Mon, 21 Mar 2011 14:55:59 -0700 Received: by vxk12 with SMTP id 12so7313597vxk.39 for ; Mon, 21 Mar 2011 14:55:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.184.2 with SMTP id ci2mr1256143vcb.172.1300744558855; Mon, 21 Mar 2011 14:55:58 -0700 (PDT) Received: by 10.220.118.70 with HTTP; Mon, 21 Mar 2011 14:55:58 -0700 (PDT) In-Reply-To: <20110306171830.GA18591@intel.com> References: <20110306171830.GA18591@intel.com> Date: Mon, 21 Mar 2011 21:56:00 -0000 Message-ID: Subject: Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *) From: Ian Lance Taylor To: "H.J. Lu" Cc: "H.J. Lu" , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg01346.txt.bz2 On Sun, Mar 6, 2011 at 9:18 AM, H.J. Lu wrote: > We shouldn't save call frame hard registers as "void *". =A0This patch > changes the unwind library to save call frame hard registers as > _Unwind_Word. =A0OK for 4.7? > + =A0 =A0 =A0 PR other/48007 > + =A0 =A0 =A0 * unwind-dw2.c (_Unwind_Context): Save call frame hard regi= sters > + =A0 =A0 =A0 as _Unwind_Word. > + =A0 =A0 =A0 (_Unwind_GetGR): Get GR value as _Unwind_Word. > + =A0 =A0 =A0 (_Unwind_SetGR): Set GR value as _Unwind_Word. > + =A0 =A0 =A0 (_Unwind_SetGRValue): Likewise. > + =A0 =A0 =A0 (_Unwind_GetGRPtr): Cast return to "void *". > + =A0 =A0 =A0 (_Unwind_SetGRPtr): Cast pointer to _Unwind_Word. > + =A0 =A0 =A0 (uw_install_context_1): Cast pointer to "void *". The approach you are using here looks wrong to me. When looking at the DWARF2 _Unwind_Context, you have to look at the by_value field for the register. If by_value is true, then the reg field for that register holds an _Unwind_Word which is the value of the register. If by_value is false, then the reg field holds a pointer to the place where the actual value is stored. The size of the actual value is determined by dwarf_reg_size_table. In other words, the reg field is a really a union of _Unwind_Word and void*. You have correctly observed that the current code fails for the case where sizeof(_Unwind_Word) > sizeof(void*). However, the answer is not to change the type from void* to _Unwind_Word. That will fail when sizeof(void*) > sizeof(_Unwind_Word). I think you have to make the reg field a union. By the way, don't use intptr_t in the unwind code. Use _Unwind_Internal_Ptr. But I think if you make the field a union, you won't need to use either type. Ian