Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/exception.c

    r8f910430 red395761  
    2727#include "stdhdr/assert.h"
    2828#include "virtual.h"
    29 
    30 #if defined( __ARM_ARCH )
    31 #warning FIX ME: temporary hack to keep ARM build working
    32 #ifndef _URC_FATAL_PHASE1_ERROR
    33 #define _URC_FATAL_PHASE1_ERROR 3
    34 #endif // ! _URC_FATAL_PHASE1_ERROR
    35 #ifndef _URC_FATAL_PHASE2_ERROR
    36 #define _URC_FATAL_PHASE2_ERROR 2
    37 #endif // ! _URC_FATAL_PHASE2_ERROR
    38 #endif // __ARM_ARCH
    39 
    4029#include "lsda.h"
    4130
     
    267256        // the whole stack.
    268257
     258#if defined( __x86_64 ) || defined( __i386 )
    269259        // We did not simply reach the end of the stack without finding a handler. This is an error.
    270260        if ( ret != _URC_END_OF_STACK ) {
     261#else // defined( __ARM_ARCH )
     262        // The return code from _Unwind_RaiseException seems to be corrupt on ARM at end of stack.
     263        // This workaround tries to keep default exception handling working.
     264        if ( ret == _URC_FATAL_PHASE1_ERROR || ret == _URC_FATAL_PHASE2_ERROR ) {
     265#endif
    271266                printf("UNWIND ERROR %d after raise exception\n", ret);
    272267                abort();
     
    301296}
    302297
    303 #if defined( __x86_64 ) || defined( __i386 )
     298#if defined( __x86_64 ) || defined( __i386 ) || defined( __ARM_ARCH )
    304299// This is our personality routine. For every stack frame annotated with
    305300// ".cfi_personality 0x3,__gcfa_personality_v0" this function will be called twice when unwinding.
     
    419414                                    _Unwind_GetCFA(unwind_context) + 24;
    420415#                               elif defined( __ARM_ARCH )
    421 #                                   warning FIX ME: check if anything needed for ARM
    422                                     42;
     416                                    _Unwind_GetCFA(unwind_context) + 40;
    423417#                               endif
    424418                                int (*matcher)(exception_t *) = *(int(**)(exception_t *))match_pos;
     
    537531        // HEADER
    538532        ".LFECFA1:\n"
     533#if defined( __x86_64 ) || defined( __i386 )
    539534        "       .globl  __gcfa_personality_v0\n"
     535#else // defined( __ARM_ARCH )
     536        "       .global __gcfa_personality_v0\n"
     537#endif
    540538        "       .section        .gcc_except_table,\"a\",@progbits\n"
    541539        // TABLE HEADER (important field is the BODY length at the end)
     
    569567        // No clue what this does specifically
    570568        "       .section        .data.rel.local.CFA.ref.__gcfa_personality_v0,\"awG\",@progbits,CFA.ref.__gcfa_personality_v0,comdat\n"
     569#if defined( __x86_64 ) || defined( __i386 )
    571570        "       .align 8\n"
     571#else // defined( __ARM_ARCH )
     572        "       .align 3\n"
     573#endif
    572574        "       .type CFA.ref.__gcfa_personality_v0, @object\n"
    573575        "       .size CFA.ref.__gcfa_personality_v0, 8\n"
     
    575577#if defined( __x86_64 )
    576578        "       .quad __gcfa_personality_v0\n"
    577 #else // then __i386
     579#elif defined( __i386 )
    578580        "       .long __gcfa_personality_v0\n"
     581#else // defined( __ARM_ARCH )
     582        "       .xword __gcfa_personality_v0\n"
    579583#endif
    580584);
     
    583587        // HEADER
    584588        ".LFECFA1:\n"
     589#if defined( __x86_64 ) || defined( __i386 )
    585590        "       .globl  __gcfa_personality_v0\n"
     591#else // defined( __ARM_ARCH )
     592        "       .global __gcfa_personality_v0\n"
     593#endif
    586594        "       .section        .gcc_except_table,\"a\",@progbits\n"
    587595        // TABLE HEADER (important field is the BODY length at the end)
     
    612620#pragma GCC pop_options
    613621
    614 #elif defined( __ARM_ARCH )
    615 _Unwind_Reason_Code __gcfa_personality_v0(
    616                 int version,
    617                 _Unwind_Action actions,
    618                 unsigned long long exception_class,
    619                 struct _Unwind_Exception * unwind_exception,
    620                 struct _Unwind_Context * unwind_context) {
    621         return _URC_CONTINUE_UNWIND;
    622 }
    623 
    624 __attribute__((noinline))
    625 void __cfaehm_try_terminate(void (*try_block)(),
    626                 void (*catch_block)(int index, exception_t * except),
    627                 __attribute__((unused)) int (*match_block)(exception_t * except)) {
    628 }
    629622#else
    630623        #error unsupported hardware architecture
    631 #endif // __x86_64 || __i386
     624#endif // __x86_64 || __i386 || __ARM_ARCH
Note: See TracChangeset for help on using the changeset viewer.