@@ -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/unique-unwind.h"
;;
i[34567]86-*-* | x86_64-*-*)
tmake_file="${tmake_file} i386/t-gmm_malloc i386/t-i386"
@@ -3701,6 +3701,13 @@ return @code{@var{regno}}.
@end defmac
+@defmac UNIQUE_UNWIND_CONTEXT
+
+Define this macro if the target only supports single unqiue unwind
+context. The default is to support multiple unwind contexts.
+
+@end defmac
+
@node Elimination
@subsection Eliminating Frame Pointer and Arg Pointer
@@ -3687,6 +3687,13 @@ return @code{@var{regno}}.
@end defmac
+@defmac UNIQUE_UNWIND_CONTEXT
+
+Define this macro if the target only supports single unqiue unwind
+context. The default is to support multiple unwind contexts.
+
+@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 UNIQUE_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,6 +69,15 @@ struct _Unwind_Context
void *ra;
void *lsda;
struct dwarf_eh_bases bases;
+#ifdef UNIQUE_UNWIND_CONTEXT
+ /* Used to check for unique _Unwind_Context. */
+ void *dwarf_reg_size_table;
+ /* Signal frame context. */
+#define SIGNAL_FRAME_BIT ((_Unwind_Word) 1 >> 0)
+ _Unwind_Word flags;
+ _Unwind_Word args_size;
+ _Unwind_Word value[DWARF_FRAME_REGISTERS+1];
+#else
/* Signal frame context. */
#define SIGNAL_FRAME_BIT ((~(_Unwind_Word) 0 >> 1) + 1)
/* Context which has version/args_size/by_value fields. */
@@ -79,6 +88,7 @@ struct _Unwind_Context
_Unwind_Word version;
_Unwind_Word args_size;
char by_value[DWARF_FRAME_REGISTERS+1];
+#endif
};
/* Byte size of every register managed by these routines. */
@@ -144,11 +154,13 @@ _Unwind_SetSignalFrame (struct _Unwind_Context *context, int val)
context->flags &= ~SIGNAL_FRAME_BIT;
}
+#ifndef UNIQUE_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 +180,14 @@ _Unwind_GetGR (struct _Unwind_Context *context, int index)
size = dwarf_reg_size_table[index];
ptr = context->reg[index];
+#ifdef UNIQUE_UNWIND_CONTEXT
+ gcc_assert (context->dwarf_reg_size_table == &dwarf_reg_size_table);
+ 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 +225,20 @@ _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 UNIQUE_UNWIND_CONTEXT
+ gcc_assert (context->dwarf_reg_size_table == &dwarf_reg_size_table);
+ 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 +257,10 @@ static inline void *
_Unwind_GetGRPtr (struct _Unwind_Context *context, int index)
{
index = DWARF_REG_TO_UNWIND_COLUMN (index);
+#ifndef UNIQUE_UNWIND_CONTEXT
if (_Unwind_IsExtendedContext (context) && context->by_value[index])
return &context->reg[index];
+#endif
return context->reg[index];
}
@@ -241,8 +270,10 @@ static inline void
_Unwind_SetGRPtr (struct _Unwind_Context *context, int index, void *p)
{
index = DWARF_REG_TO_UNWIND_COLUMN (index);
+#ifndef UNIQUE_UNWIND_CONTEXT
if (_Unwind_IsExtendedContext (context))
context->by_value[index] = 0;
+#endif
context->reg[index] = p;
}
@@ -254,10 +285,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 UNIQUE_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 +303,11 @@ static inline int
_Unwind_GRByValue (struct _Unwind_Context *context, int index)
{
index = DWARF_REG_TO_UNWIND_COLUMN (index);
+#ifdef UNIQUE_UNWIND_CONTEXT
+ return context->reg[index] == &context->value[index];
+#else
return context->by_value[index];
+#endif
}
/* Retrieve the return address for CONTEXT. */
@@ -1215,7 +1255,11 @@ __frame_state_for (void *pc_target, struct frame_state *state_in)
int reg;
memset (&context, 0, sizeof (struct _Unwind_Context));
+#ifdef UNIQUE_UNWIND_CONTEXT
+ context.dwarf_reg_size_table = &dwarf_reg_size_table;
+#else
context.flags = EXTENDED_CONTEXT_BIT;
+#endif
context.ra = pc_target + 1;
if (uw_frame_state_for (&context, &fs) != _URC_NO_REASON)
@@ -1453,7 +1497,11 @@ uw_init_context_1 (struct _Unwind_Context *context,
memset (context, 0, sizeof (struct _Unwind_Context));
context->ra = ra;
+#ifdef UNIQUE_UNWIND_CONTEXT
+ context->dwarf_reg_size_table = &dwarf_reg_size_table;
+#else
context->flags = EXTENDED_CONTEXT_BIT;
+#endif
code = uw_frame_state_for (context, &fs);
gcc_assert (code == _URC_NO_REASON);
@@ -1535,8 +1583,13 @@ uw_install_context_1 (struct _Unwind_Context *current,
void *c = current->reg[i];
void *t = target->reg[i];
+#ifdef UNIQUE_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 @@
+/* Support DWARF2 EH unwind with single unqiue 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 only supports single unqiue unwind
+ context. Only enable it for x32. */
+#if defined __x86_64 && !defined __LP64__
+# define UNIQUE_UNWIND_CONTEXT
+#endif