Skip to content

Commit

Permalink
DWARF EH cleanups.
Browse files Browse the repository at this point in the history
Update the C++ ABI for the C++11 ABI and fix the missing ARM-specific
bits.  Work around a bug in ARM.
  • Loading branch information
davidchisnall committed Mar 30, 2019
1 parent 959a0f1 commit 0889776
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 8 additions & 5 deletions eh_personality.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static void saveLandingPad(struct _Unwind_Context *context,
int selector,
dw_eh_ptr_t landingPad)
{
#ifdef __arm__
#ifdef __arm__ && !defined(__ARM_DWARF_EH__)
// On ARM, we store the saved exception in the generic part of the structure
ucb->barrier_cache.sp = _Unwind_GetGR(context, 13);
ucb->barrier_cache.bitpattern[1] = (uint32_t)selector;
Expand All @@ -116,7 +116,7 @@ static int loadLandingPad(struct _Unwind_Context *context,
unsigned long *selector,
dw_eh_ptr_t *landingPad)
{
#ifdef __arm__
#ifdef __arm__ && !defined(__ARM_DWARF_EH__)
*selector = ucb->barrier_cache.bitpattern[1];
*landingPad = (dw_eh_ptr_t)ucb->barrier_cache.bitpattern[3];
return 1;
Expand All @@ -134,7 +134,7 @@ static int loadLandingPad(struct _Unwind_Context *context,
static inline _Unwind_Reason_Code continueUnwinding(struct _Unwind_Exception *ex,
struct _Unwind_Context *context)
{
#ifdef __arm__
#ifdef __arm__ && !defined(__ARM_DWARF_EH__)
if (__gnu_unwind_frame(ex, context) != _URC_OK) { return _URC_FAILURE; }
#endif
return _URC_CONTINUE_UNWIND;
Expand Down Expand Up @@ -418,14 +418,17 @@ static inline _Unwind_Reason_Code internal_objc_personality(int version,
handler_type handler = check_action_record(context, foreignException,
&lsda, action.action_record, thrown_class, &selector);
DEBUG_LOG("handler! %d %d\n", (int)handler, (int)selector);
// On ARM, we occasionally get called to install a handler without
// phase 1 running (no idea why, I suspect a bug in the generic
// unwinder), so skip this check.
#ifdef __arm__ && !defined(__ARM_DWARF_EH__)
// If this is not a cleanup, ignore it and keep unwinding.
//if (check_action_record(context, foreignException, &lsda,
//action.action_record, thrown_class, &selector) != handler_cleanup)
if ((handler != handler_cleanup) && !objcxxException)
{
DEBUG_LOG("Ignoring handler! %d\n",handler);
return continueUnwinding(exceptionObject, context);
}
#endif
DEBUG_LOG("Installing cleanup...\n");
// If there is a cleanup, we need to return the exception structure
// (not the object) to the calling frame. The exception object
Expand Down
10 changes: 10 additions & 0 deletions objcxx_eh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,27 @@ static BOOL isKindOfClass(Class thrown, Class type)
*/
struct __cxa_exception
{
#if __LP64__
uintptr_t referenceCount;
#endif
std::type_info *exceptionType;
void (*exceptionDestructor) (void *);
unexpected_handler unexpectedHandler;
terminate_handler terminateHandler;
__cxa_exception *nextException;
int handlerCount;
#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
_Unwind_Exception *nextCleanup;
int cleanupCount;
#endif
int handlerSwitchValue;
const char *actionRecord;
const char *languageSpecificData;
void *catchTemp;
void *adjustedPtr;
#if !__LP64__
uintptr_t referenceCount;
#endif
_Unwind_Exception unwindHeader;
};

Expand Down

0 comments on commit 0889776

Please sign in to comment.