@@ -2627,6 +2648,7 @@ esac
case ${target} in
i[34567]86-*-linux* | x86_64-*-linux*)
tmake_file="${tmake_file} i386/t-pmm_malloc i386/t-i386"
+ libgcc_tm_file="${libgcc_tm_file} i386/value-unwind.h"
;;
i[34567]86-*-* | x86_64-*-*)
tmake_file="${tmake_file} i386/t-gmm_malloc i386/t-i386"
@@ -3701,6 +3701,14 @@ return @code{@var{regno}}.
@end defmac
+@defmac REG_VALUE_IN_UNWIND_CONTEXT
+
+Define this macro if the target stores register values as
+@code{_Unwind_Word} type in unwind context. The default is to
+store register values as @code{void *} type.
+
+@end defmac
+
@node Elimination
@subsection Eliminating Frame Pointer and Arg Pointer
@@ -3687,6 +3687,14 @@ return @code{@var{regno}}.
@end defmac
+@defmac REG_VALUE_IN_UNWIND_CONTEXT
+
+Define this macro if the target stores register values as
+@code{_Unwind_Word} type in unwind context. The default is to
+store register values as @code{void *} type.
+
+@end defmac
+
@node Elimination
@subsection Eliminating Frame Pointer and Arg Pointer
@@ -764,7 +764,7 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
/* Target macros only used for code built for the target, that have
moved to libgcc-tm.h or have never been present elsewhere. */
#pragma GCC poison DECLARE_LIBRARY_RENAMES LIBGCC2_GNU_PREFIX \
- MD_UNWIND_SUPPORT ENABLE_EXECUTE_STACK
+ MD_UNWIND_SUPPORT ENABLE_EXECUTE_STACK REG_VALUE_IN_UNWIND_CONTEXT
/* Other obsolete target macros, or macros that used to be in target
headers and were not used, and may be obsolete or may never have
@@ -69,16 +69,25 @@ struct _Unwind_Context
void *ra;
void *lsda;
struct dwarf_eh_bases bases;
+#ifdef REG_VALUE_IN_UNWIND_CONTEXT
+ /* Signal frame context. */
+#define SIGNAL_FRAME_BIT ((_Unwind_Word) 1 >> 0)
+#else
/* Signal frame context. */
#define SIGNAL_FRAME_BIT ((~(_Unwind_Word) 0 >> 1) + 1)
/* Context which has version/args_size/by_value fields. */
#define EXTENDED_CONTEXT_BIT ((~(_Unwind_Word) 0 >> 2) + 1)
+#endif
_Unwind_Word flags;
/* 0 for now, can be increased when further fields are added to
struct _Unwind_Context. */
_Unwind_Word version;
_Unwind_Word args_size;
+#ifdef REG_VALUE_IN_UNWIND_CONTEXT
+ _Unwind_Word value[DWARF_FRAME_REGISTERS+1];
+#else
char by_value[DWARF_FRAME_REGISTERS+1];
+#endif
};
/* Byte size of every register managed by these routines. */
@@ -144,11 +153,13 @@ _Unwind_SetSignalFrame (struct _Unwind_Context *context, int val)
context->flags &= ~SIGNAL_FRAME_BIT;
}
+#ifndef REG_VALUE_IN_UNWIND_CONTEXT
static inline _Unwind_Word
_Unwind_IsExtendedContext (struct _Unwind_Context *context)
{
return context->flags & EXTENDED_CONTEXT_BIT;
}
+#endif
/* Get the value of register INDEX as saved in CONTEXT. */
@@ -168,8 +179,13 @@ _Unwind_GetGR (struct _Unwind_Context *context, int index)
size = dwarf_reg_size_table[index];
ptr = context->reg[index];
+#ifdef REG_VALUE_IN_UNWIND_CONTEXT
+ if (context->reg[index] == &context->value[index])
+ return context->value[index];
+#else
if (_Unwind_IsExtendedContext (context) && context->by_value[index])
return (_Unwind_Word) (_Unwind_Internal_Ptr) ptr;
+#endif
/* This will segfault if the register hasn't been saved. */
if (size == sizeof(_Unwind_Ptr))
@@ -207,11 +223,19 @@ _Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word val)
gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
size = dwarf_reg_size_table[index];
+#ifdef REG_VALUE_IN_UNWIND_CONTEXT
+ if (context->reg[index] == &context->value[index])
+ {
+ context->value[index] = val;
+ return;
+ }
+#else
if (_Unwind_IsExtendedContext (context) && context->by_value[index])
{
context->reg[index] = (void *) (_Unwind_Internal_Ptr) val;
return;
}
+#endif
ptr = context->reg[index];
@@ -230,8 +254,10 @@ static inline void *
_Unwind_GetGRPtr (struct _Unwind_Context *context, int index)
{
index = DWARF_REG_TO_UNWIND_COLUMN (index);
+#ifndef REG_VALUE_IN_UNWIND_CONTEXT
if (_Unwind_IsExtendedContext (context) && context->by_value[index])
return &context->reg[index];
+#endif
return context->reg[index];
}
@@ -241,8 +267,10 @@ static inline void
_Unwind_SetGRPtr (struct _Unwind_Context *context, int index, void *p)
{
index = DWARF_REG_TO_UNWIND_COLUMN (index);
+#ifndef REG_VALUE_IN_UNWIND_CONTEXT
if (_Unwind_IsExtendedContext (context))
context->by_value[index] = 0;
+#endif
context->reg[index] = p;
}
@@ -254,10 +282,15 @@ _Unwind_SetGRValue (struct _Unwind_Context *context, int index,
{
index = DWARF_REG_TO_UNWIND_COLUMN (index);
gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
+#ifdef REG_VALUE_IN_UNWIND_CONTEXT
+ gcc_assert (dwarf_reg_size_table[index] == sizeof (_Unwind_Word));
+ context->value[index] = val;
+ context->reg[index] = &context->value[index];
+#else
gcc_assert (dwarf_reg_size_table[index] == sizeof (_Unwind_Ptr));
-
context->by_value[index] = 1;
context->reg[index] = (void *) (_Unwind_Internal_Ptr) val;
+#endif
}
/* Return nonzero if register INDEX is stored by value rather than
@@ -267,7 +300,11 @@ static inline int
_Unwind_GRByValue (struct _Unwind_Context *context, int index)
{
index = DWARF_REG_TO_UNWIND_COLUMN (index);
+#ifdef REG_VALUE_IN_UNWIND_CONTEXT
+ return context->reg[index] == &context->value[index];
+#else
return context->by_value[index];
+#endif
}
/* Retrieve the return address for CONTEXT. */
@@ -1215,7 +1252,9 @@ __frame_state_for (void *pc_target, struct frame_state *state_in)
int reg;
memset (&context, 0, sizeof (struct _Unwind_Context));
+#ifndef REG_VALUE_IN_UNWIND_CONTEXT
context.flags = EXTENDED_CONTEXT_BIT;
+#endif
context.ra = pc_target + 1;
if (uw_frame_state_for (&context, &fs) != _URC_NO_REASON)
@@ -1453,7 +1492,9 @@ uw_init_context_1 (struct _Unwind_Context *context,
memset (context, 0, sizeof (struct _Unwind_Context));
context->ra = ra;
+#ifndef REG_VALUE_IN_UNWIND_CONTEXT
context->flags = EXTENDED_CONTEXT_BIT;
+#endif
code = uw_frame_state_for (context, &fs);
gcc_assert (code == _URC_NO_REASON);
@@ -1535,8 +1576,13 @@ uw_install_context_1 (struct _Unwind_Context *current,
void *c = current->reg[i];
void *t = target->reg[i];
+#ifdef REG_VALUE_IN_UNWIND_CONTEXT
+ gcc_assert (current->reg[i] != ¤t->value[i]);
+ if (target->reg[i] == &target->value[i] && c)
+#else
gcc_assert (current->by_value[i] == 0);
if (target->by_value[i] && c)
+#endif
{
_Unwind_Word w;
_Unwind_Ptr p;
new file mode 100644
@@ -0,0 +1,26 @@
+/* Store register values as _Unwind_Word type in DWARF2 EH unwind context.
+ Copyright (C) 2011
+ Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GCC is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Define this macro if the target stores register values as _Unwind_Word
+ type in unwind context. Only enable it for x32. */
+#if defined __x86_64 && !defined __LP64__
+# define REG_VALUE_IN_UNWIND_CONTEXT
+#endif