IA64 HP-UX Unwind patch
Steve Ellcey
sje@cup.hp.com
Thu Aug 15 09:47:00 GMT 2002
> > The other changes that would be needed to make this work would be to
> > modify catchTemp in the __cxa_exception in cxx-unwind.h to be
> > _Unwind_Ptr instead of void* and get rid of the void* casts when
> > assigning to catchTemp. Does this look like a better approach?
>
> Dunno. Probably better, but I'm not sure how many warnings you'll
> get for casting between pointer and integer of different size.
It looks like I can do it with only one warning. It comes from the
first call to _Unwind_SetGR in PERSONALITY_FUNCTION. &xh->unwindHeader
is 32 bits and we cast it to a 64 bit value. While I do get this
warning and the conversion is not getting done with addp4 (extend_ptr)
everything seems to work fine, here is a patch that might be considered
cleaner then the last one. The main concern I have is whether or not
changing catchTemp in the __cxa_exception structure from void* to
_Unwind_Ptr would have any effect on other platforms.
Steve Ellcey
sje@cup.hp.com
2002-08-15 Steve Ellcey <sje@cup.hp.com>
* gcc/unwind.h (_Unwind_Ptr): Make 64 bits on IA64 HP-UX.
(_Unwind_Internal_Ptr): 32 bit version for use in
read_encoded_value_with_base.
* gcc/unwind-pe.h (read_encoded_value_with_base): Use
_Unwind_Internal_Ptr instead of _Unwind_Ptr in order to get the
right size.
* libstdc++-v3/libsupc++/unwind-cxx.h (__cxa_exception):
Change catchTemp type from void* to _Unwind_Ptr.
* libstdc++-v3/libsupc++/eh_personality.cc (PERSONALITY_FUNCTION):
Do not cast landing_pad or base_of_encoded_value to (void *).
* libstdc++-v3/libsupc++/eh_throw.cc (__gxx_exception_cleanup):
Accept _URC_NO_REASON as a valid reason code.
*** gcc.orig/gcc/unwind.h Thu Aug 15 08:40:06 2002
--- gcc/gcc/unwind.h Thu Aug 15 08:48:06 2002
*************** extern "C" {
*** 31,37 ****
--- 31,42 ----
inefficient for 32-bit and smaller machines. */
typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
+ #if defined(__ia64__) && defined(__hpux__)
+ typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__)));
+ #else
typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
+ #endif
+ typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
/* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and
consumer of an exception. We'll go along with this for now even on
*** gcc.orig/gcc/unwind-pe.h Thu Aug 15 08:39:56 2002
--- gcc/gcc/unwind-pe.h Thu Aug 15 08:50:40 2002
*************** read_encoded_value_with_base (unsigned c
*** 179,191 ****
} __attribute__((__packed__));
union unaligned *u = (union unaligned *) p;
! _Unwind_Ptr result;
if (encoding == DW_EH_PE_aligned)
{
! _Unwind_Ptr a = (_Unwind_Ptr) p;
a = (a + sizeof (void *) - 1) & - sizeof(void *);
! result = *(_Unwind_Ptr *) a;
p = (const unsigned char *) (a + sizeof (void *));
}
else
--- 179,191 ----
} __attribute__((__packed__));
union unaligned *u = (union unaligned *) p;
! _Unwind_Internal_Ptr result;
if (encoding == DW_EH_PE_aligned)
{
! _Unwind_Internal_Ptr a = (_Unwind_Internal_Ptr) p;
a = (a + sizeof (void *) - 1) & - sizeof(void *);
! result = *(_Unwind_Internal_Ptr *) a;
p = (const unsigned char *) (a + sizeof (void *));
}
else
*************** read_encoded_value_with_base (unsigned c
*** 193,199 ****
switch (encoding & 0x0f)
{
case DW_EH_PE_absptr:
! result = (_Unwind_Ptr) u->ptr;
p += sizeof (void *);
break;
--- 193,199 ----
switch (encoding & 0x0f)
{
case DW_EH_PE_absptr:
! result = (_Unwind_Internal_Ptr) u->ptr;
p += sizeof (void *);
break;
*************** read_encoded_value_with_base (unsigned c
*** 201,207 ****
{
_Unwind_Word tmp;
p = read_uleb128 (p, &tmp);
! result = (_Unwind_Ptr) tmp;
}
break;
--- 201,207 ----
{
_Unwind_Word tmp;
p = read_uleb128 (p, &tmp);
! result = (_Unwind_Internal_Ptr) tmp;
}
break;
*************** read_encoded_value_with_base (unsigned c
*** 209,215 ****
{
_Unwind_Sword tmp;
p = read_sleb128 (p, &tmp);
! result = (_Unwind_Ptr) tmp;
}
break;
--- 209,215 ----
{
_Unwind_Sword tmp;
p = read_sleb128 (p, &tmp);
! result = (_Unwind_Internal_Ptr) tmp;
}
break;
*************** read_encoded_value_with_base (unsigned c
*** 246,254 ****
if (result != 0)
{
result += ((encoding & 0x70) == DW_EH_PE_pcrel
! ? (_Unwind_Ptr) u : base);
if (encoding & DW_EH_PE_indirect)
! result = *(_Unwind_Ptr *) result;
}
}
--- 246,254 ----
if (result != 0)
{
result += ((encoding & 0x70) == DW_EH_PE_pcrel
! ? (_Unwind_Internal_Ptr) u : base);
if (encoding & DW_EH_PE_indirect)
! result = *(_Unwind_Internal_Ptr *) result;
}
}
*** gcc.orig/libstdc++-v3/libsupc++/unwind-cxx.h Thu Aug 15 08:41:04 2002
--- gcc/libstdc++-v3/libsupc++/unwind-cxx.h Thu Aug 15 08:41:44 2002
*************** struct __cxa_exception
*** 70,76 ****
int handlerSwitchValue;
const unsigned char *actionRecord;
const unsigned char *languageSpecificData;
! void *catchTemp;
void *adjustedPtr;
// The generic exception header. Must be last.
--- 70,76 ----
int handlerSwitchValue;
const unsigned char *actionRecord;
const unsigned char *languageSpecificData;
! _Unwind_Ptr catchTemp;
void *adjustedPtr;
// The generic exception header. Must be last.
*** gcc.orig/libstdc++-v3/libsupc++/eh_personality.cc Thu Aug 15 08:40:45 2002
--- gcc/libstdc++-v3/libsupc++/eh_personality.cc Thu Aug 15 08:46:43 2002
*************** PERSONALITY_FUNCTION (int version,
*** 394,400 ****
// ??? Completely unknown what this field is supposed to be for.
// ??? Need to cache TType encoding base for call_unexpected.
! xh->catchTemp = (void *) (_Unwind_Ptr) landing_pad;
}
return _URC_HANDLER_FOUND;
}
--- 394,400 ----
// ??? Completely unknown what this field is supposed to be for.
// ??? Need to cache TType encoding base for call_unexpected.
! xh->catchTemp = landing_pad;
}
return _URC_HANDLER_FOUND;
}
*************** PERSONALITY_FUNCTION (int version,
*** 411,417 ****
if (handler_switch_value < 0)
{
parse_lsda_header (context, xh->languageSpecificData, &info);
! xh->catchTemp = (void *) base_of_encoded_value (info.ttype_encoding,
context);
}
--- 411,417 ----
if (handler_switch_value < 0)
{
parse_lsda_header (context, xh->languageSpecificData, &info);
! xh->catchTemp = base_of_encoded_value (info.ttype_encoding,
context);
}
*** gcc.orig/libstdc++-v3/libsupc++/eh_throw.cc Thu Aug 15 08:40:58 2002
--- gcc/libstdc++-v3/libsupc++/eh_throw.cc Thu Aug 15 08:44:47 2002
*************** __gxx_exception_cleanup (_Unwind_Reason_
*** 42,48 ****
// If we haven't been caught by a foreign handler, then this is
// some sort of unwind error. In that case just die immediately.
! if (code != _URC_FOREIGN_EXCEPTION_CAUGHT)
__terminate (header->terminateHandler);
if (header->exceptionDestructor)
--- 42,51 ----
// If we haven't been caught by a foreign handler, then this is
// some sort of unwind error. In that case just die immediately.
! // _Unwind_DeleteException in the HP-UX IA64 libunwind library
! // returns _URC_NO_REASON and not _URC_FOREIGN_EXCEPTION_CAUGHT
! // like the GCC _Unwind_DeleteException function does.
! if (code != _URC_FOREIGN_EXCEPTION_CAUGHT && code != _URC_NO_REASON)
__terminate (header->terminateHandler);
if (header->exceptionDestructor)
More information about the Libstdc++
mailing list