From patchwork Sun Mar 6 17:18:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 85582 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 EE0F9B70BA for ; Mon, 7 Mar 2011 04:18:42 +1100 (EST) Received: (qmail 18672 invoked by alias); 6 Mar 2011 17:18:38 -0000 Received: (qmail 18662 invoked by uid 22791); 6 Mar 2011 17:18:36 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=AWL, BAYES_00, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 06 Mar 2011 17:18:32 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 06 Mar 2011 09:18:30 -0800 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by fmsmga001.fm.intel.com with ESMTP; 06 Mar 2011 09:18:30 -0800 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 52CE0180973; Sun, 6 Mar 2011 09:18:30 -0800 (PST) Date: Sun, 6 Mar 2011 09:18:30 -0800 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Subject: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *) Message-ID: <20110306171830.GA18591@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 Hi, We shouldn't save call frame hard registers as "void *". This patch changes the unwind library to save call frame hard registers as _Unwind_Word. OK for 4.7? Thanks. H.J. ---- commit 4163355471bfb192fdacc5da1ceb9aec5569ff94 Author: H.J. Lu Date: Sun Mar 6 08:19:25 2011 -0800 Save call frame hard registers as _Unwind_Word. diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32 index 5389f19..022767b 100644 --- a/gcc/ChangeLog.x32 +++ b/gcc/ChangeLog.x32 @@ -1,3 +1,15 @@ +2011-03-06 H.J. Lu + + PR other/48007 + * unwind-dw2.c (_Unwind_Context): Save call frame hard registers + as _Unwind_Word. + (_Unwind_GetGR): Get GR value as _Unwind_Word. + (_Unwind_SetGR): Set GR value as _Unwind_Word. + (_Unwind_SetGRValue): Likewise. + (_Unwind_GetGRPtr): Cast return to "void *". + (_Unwind_SetGRPtr): Cast pointer to _Unwind_Word. + (uw_install_context_1): Cast pointer to "void *". + 2011-03-05 H.J. Lu * config/i386/linux-unwind.h (x86_64_fallback_frame_state): diff --git a/gcc/unwind-dw2.c b/gcc/unwind-dw2.c index 2ea9adb..229c373 100644 --- a/gcc/unwind-dw2.c +++ b/gcc/unwind-dw2.c @@ -60,7 +60,7 @@ to its caller. */ struct _Unwind_Context { - void *reg[DWARF_FRAME_REGISTERS+1]; + _Unwind_Word reg[DWARF_FRAME_REGISTERS+1]; void *cfa; void *ra; void *lsda; @@ -152,7 +152,7 @@ inline _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *context, int index) { int size; - void *ptr; + _Unwind_Word val; #ifdef DWARF_ZERO_REG if (index == DWARF_ZERO_REG) @@ -162,18 +162,18 @@ _Unwind_GetGR (struct _Unwind_Context *context, int index) index = DWARF_REG_TO_UNWIND_COLUMN (index); gcc_assert (index < (int) sizeof(dwarf_reg_size_table)); size = dwarf_reg_size_table[index]; - ptr = context->reg[index]; + val = context->reg[index]; if (_Unwind_IsExtendedContext (context) && context->by_value[index]) - return (_Unwind_Word) (_Unwind_Internal_Ptr) ptr; + return val; /* This will segfault if the register hasn't been saved. */ if (size == sizeof(_Unwind_Ptr)) - return * (_Unwind_Ptr *) ptr; + return * (_Unwind_Ptr *) (intptr_t) val; else { gcc_assert (size == sizeof(_Unwind_Word)); - return * (_Unwind_Word *) ptr; + return * (_Unwind_Word *) (intptr_t) val; } } @@ -205,11 +205,11 @@ _Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word val) if (_Unwind_IsExtendedContext (context) && context->by_value[index]) { - context->reg[index] = (void *) (_Unwind_Internal_Ptr) val; + context->reg[index] = val; return; } - ptr = context->reg[index]; + ptr = (void *) (intptr_t) context->reg[index]; if (size == sizeof(_Unwind_Ptr)) * (_Unwind_Ptr *) ptr = val; @@ -227,8 +227,8 @@ _Unwind_GetGRPtr (struct _Unwind_Context *context, int index) { index = DWARF_REG_TO_UNWIND_COLUMN (index); if (_Unwind_IsExtendedContext (context) && context->by_value[index]) - return &context->reg[index]; - return context->reg[index]; + return (void *) (intptr_t) &context->reg[index]; + return (void *) (intptr_t) context->reg[index]; } /* Set the pointer to a register INDEX as saved in CONTEXT. */ @@ -239,7 +239,7 @@ _Unwind_SetGRPtr (struct _Unwind_Context *context, int index, void *p) index = DWARF_REG_TO_UNWIND_COLUMN (index); if (_Unwind_IsExtendedContext (context)) context->by_value[index] = 0; - context->reg[index] = p; + context->reg[index] = (_Unwind_Word) (intptr_t) p; } /* Overwrite the saved value for register INDEX in CONTEXT with VAL. */ @@ -250,10 +250,10 @@ _Unwind_SetGRValue (struct _Unwind_Context *context, int index, { index = DWARF_REG_TO_UNWIND_COLUMN (index); gcc_assert (index < (int) sizeof(dwarf_reg_size_table)); - gcc_assert (dwarf_reg_size_table[index] == sizeof (_Unwind_Ptr)); + gcc_assert (dwarf_reg_size_table[index] == sizeof (_Unwind_Word)); context->by_value[index] = 1; - context->reg[index] = (void *) (_Unwind_Internal_Ptr) val; + context->reg[index] = val; } /* Return nonzero if register INDEX is stored by value rather than @@ -1524,8 +1524,8 @@ uw_install_context_1 (struct _Unwind_Context *current, for (i = 0; i < DWARF_FRAME_REGISTERS; ++i) { - void *c = current->reg[i]; - void *t = target->reg[i]; + void *c = (void *) (intptr_t) current->reg[i]; + void *t = (void *) (intptr_t) target->reg[i]; gcc_assert (current->by_value[i] == 0); if (target->by_value[i] && c)