@@ -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
@@ -59,20 +59,56 @@
#define DWARF_REG_TO_UNWIND_COLUMN(REGNO) (REGNO)
#endif
+#ifdef REG_VALUE_IN_UNWIND_CONTEXT
+typedef _Unwind_Word _Unwind_Context_Reg_Val;
+/* Signal frame context. */
+#define SIGNAL_FRAME_BIT ((_Unwind_Word) 1 >> 0)
+
+#define _Unwind_IsExtendedContext(c) 1
+
+static inline _Unwind_Word
+_Unwind_Get_Unwind_Word (_Unwind_Context_Reg_Val val)
+{
+ return val;
+}
+
+static inline _Unwind_Context_Reg_Val
+_Unwind_Get_Unwind_Context_Reg_Val (_Unwind_Word val)
+{
+ return val;
+}
+#else
+typedef void *_Unwind_Context_Reg_Val;
+/* 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)
+
+#define _Unwind_IsExtendedContext(c) ((c)->flags & EXTENDED_CONTEXT_BIT)
+
+static inline _Unwind_Word
+_Unwind_Get_Unwind_Word (_Unwind_Context_Reg_Val val)
+{
+ return (_Unwind_Word) (_Unwind_Internal_Ptr) val;
+}
+
+static inline _Unwind_Context_Reg_Val
+_Unwind_Get_Unwind_Context_Reg_Val (_Unwind_Word val)
+{
+ return (_Unwind_Context_Reg_Val) (_Unwind_Internal_Ptr) val;
+}
+#endif
+
/* This is the register and unwind state for a particular frame. This
provides the information necessary to unwind up past a frame and return
to its caller. */
struct _Unwind_Context
{
- void *reg[DWARF_FRAME_REGISTERS+1];
+ _Unwind_Context_Reg_Val reg[DWARF_FRAME_REGISTERS+1];
void *cfa;
void *ra;
void *lsda;
struct dwarf_eh_bases bases;
- /* 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)
_Unwind_Word flags;
/* 0 for now, can be increased when further fields are added to
struct _Unwind_Context. */
@@ -143,12 +179,6 @@ _Unwind_SetSignalFrame (struct _Unwind_Context *context, int val)
else
context->flags &= ~SIGNAL_FRAME_BIT;
}
-
-static inline _Unwind_Word
-_Unwind_IsExtendedContext (struct _Unwind_Context *context)
-{
- return context->flags & EXTENDED_CONTEXT_BIT;
-}
/* Get the value of register INDEX as saved in CONTEXT. */
@@ -156,7 +186,7 @@ inline _Unwind_Word
_Unwind_GetGR (struct _Unwind_Context *context, int index)
{
int size;
- void *ptr;
+ _Unwind_Context_Reg_Val val;
#ifdef DWARF_ZERO_REG
if (index == DWARF_ZERO_REG)
@@ -166,18 +196,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 _Unwind_Get_Unwind_Word (val);
/* This will segfault if the register hasn't been saved. */
if (size == sizeof(_Unwind_Ptr))
- return * (_Unwind_Ptr *) ptr;
+ return * (_Unwind_Ptr *) (_Unwind_Internal_Ptr) val;
else
{
gcc_assert (size == sizeof(_Unwind_Word));
- return * (_Unwind_Word *) ptr;
+ return * (_Unwind_Word *) (_Unwind_Internal_Ptr) val;
}
}
@@ -209,11 +239,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] = _Unwind_Get_Unwind_Context_Reg_Val (val);
return;
}
- ptr = context->reg[index];
+ ptr = (void *) (_Unwind_Internal_Ptr) context->reg[index];
if (size == sizeof(_Unwind_Ptr))
* (_Unwind_Ptr *) ptr = val;
@@ -232,7 +262,7 @@ _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 *) (_Unwind_Internal_Ptr) context->reg[index];
}
/* Set the pointer to a register INDEX as saved in CONTEXT. */
@@ -243,7 +273,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_Context_Reg_Val) (_Unwind_Internal_Ptr) p;
}
/* Overwrite the saved value for register INDEX in CONTEXT with VAL. */
@@ -254,10 +284,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_Context_Reg_Val));
context->by_value[index] = 1;
- context->reg[index] = (void *) (_Unwind_Internal_Ptr) val;
+ context->reg[index] = _Unwind_Get_Unwind_Context_Reg_Val (val);
}
/* Return nonzero if register INDEX is stored by value rather than
@@ -1215,7 +1245,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 +1485,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);
@@ -1532,8 +1566,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 *) (_Unwind_Internal_Ptr) current->reg[i];
+ void *t = (void *) (_Unwind_Internal_Ptr)target->reg[i];
gcc_assert (current->by_value[i] == 0);
if (target->by_value[i] && c)