Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/interpose.c

    r169d944 r3d5f2ef1  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  8 16:18:09 2018
    13 // Update Count     : 75
     12// Last Modified On : Wed Feb  7 09:05:18 2018
     13// Update Count     : 59
    1414//
    1515
     
    2828}
    2929
     30#define __NO_ABORT_OVERLOAD // no abort overload avoid ambiguities
    3031#include "bits/debug.h"
    3132#include "bits/defs.h"
     
    5051                        error = dlerror();
    5152                        if ( error ) {
    52                                 abort( "interpose_symbol : failed to open libc, %s\n", error );
     53                                abortf( "interpose_symbol : failed to open libc, %s\n", error );
    5354                        }
    5455                #endif
     
    6869
    6970        error = dlerror();
    70         if ( error ) abort( "interpose_symbol : internal error, %s\n", error );
     71        if ( error ) abortf( "interpose_symbol : internal error, %s\n", error );
    7172
    7273        return originalFunc.fptr;
     
    9798
    9899struct {
    99         void (* exit)( int ) __attribute__ (( __noreturn__ ));
    100         void (* abort)( void ) __attribute__ (( __noreturn__ ));
     100        __typeof__( exit  ) exit  __attribute__(( noreturn ));
     101        __typeof__( abort ) abort __attribute__(( noreturn ));
    101102} __cabi_libc;
    102103
     
    122123
    123124// Forward declare abort after the __typeof__ call to avoid ambiguities
    124 void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    125 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     125void abort ( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__));
    126126
    127127extern "C" {
    128         void abort( void ) __attribute__ (( __nothrow__, __leaf__, __noreturn__ )) {
    129                 abort( NULL );
    130         }
    131 
    132         void __cabi_abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) {
     128        void abort( void ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
     129                abortf( NULL );
     130        }
     131
     132        void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
    133133                va_list argp;
    134134                va_start( argp, fmt );
     
    137137        }
    138138
    139         void exit( int status ) __attribute__ (( __nothrow__, __leaf__, __noreturn__ )) {
    140                 __cabi_libc.exit( status );
    141         }
    142 }
    143 
    144 void * kernel_abort    ( void ) __attribute__ (( __nothrow__, __leaf__, __weak__ )) { return NULL; }
    145 void   kernel_abort_msg( void * data, char * buffer, int size ) __attribute__ (( __nothrow__, __leaf__, __weak__ )) {}
    146 int kernel_abort_lastframe( void ) __attribute__ (( __nothrow__, __leaf__, __weak__ )) { return 4; }
     139        void exit( int __status ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
     140                __cabi_libc.exit(__status);
     141        }
     142}
     143
     144void * kernel_abort    ( void ) __attribute__ ((__nothrow__, __leaf__, __weak__)) { return NULL; }
     145void   kernel_abort_msg( void * data, char * buffer, int size ) __attribute__ ((__nothrow__, __leaf__, __weak__)) {}
     146int kernel_abort_lastframe( void ) __attribute__ ((__nothrow__, __leaf__, __weak__)) { return 4; }
    147147
    148148enum { abort_text_size = 1024 };
     
    150150static int abort_lastframe;
    151151
    152 void exit( int status, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ )) {
    153     va_list args;
    154     va_start( args, fmt );
    155     vfprintf( stderr, fmt, args );
    156     va_end( args );
    157         __cabi_libc.exit( status );
    158 }
    159 
    160 void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) {
     152void abort( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
    161153        void * kernel_data = kernel_abort();                    // must be done here to lock down kernel
    162154        int len;
     
    234226
    235227void sigHandler_segv( __CFA_SIGPARMS__ ) {
    236         abort( "Addressing invalid memory at location %p\n"
     228        abortf( "Addressing invalid memory at location %p\n"
    237229                        "Possible cause is reading outside the address space or writing to a protected area within the address space with an invalid pointer or subscript.\n",
    238230                        sfp->si_addr );
     
    240232
    241233void sigHandler_ill( __CFA_SIGPARMS__ ) {
    242         abort( "Executing illegal instruction at location %p.\n"
     234        abortf( "Executing illegal instruction at location %p.\n"
    243235                        "Possible cause is stack corruption.\n",
    244236                        sfp->si_addr );
     
    256248          default: msg = "unknown";
    257249        } // choose
    258         abort( "Computation error %s at location %p.\n", msg, sfp->si_addr );
     250        abortf( "Computation error %s at location %p.\n", msg, sfp->si_addr );
    259251}
    260252
Note: See TracChangeset for help on using the changeset viewer.