Changes in libcfa/src/interpose_thread.cfa [7f81ef4:e10714a]
- File:
-
- 1 edited
-
libcfa/src/interpose_thread.cfa (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/interpose_thread.cfa
r7f81ef4 re10714a 14 14 // 15 15 16 #include <stdarg.h> // va_start, va_end 17 #include <stdio.h> 18 #include <string.h> // strlen 16 // BUG in 32-bit gcc with interpose: fixed in >= gcc-9.5, gcc-10.4, gcc-12.2 17 #ifdef __i386__ // 32-bit architecture 18 #undef _GNU_SOURCE 19 #endif // __i386__ 20 19 21 #include <signal.h> 20 22 #include <pthread.h> 23 #include <signal.h> 21 24 extern "C" { 22 25 #include <dlfcn.h> // dlopen, dlsym 23 #include <execinfo.h> // backtrace, messages24 26 } 25 27 26 #include "bits/debug.hfa"27 28 #include "bits/defs.hfa" 28 #include <assert.h>29 29 30 30 //============================================================================================= … … 34 34 typedef void (* generic_fptr_t)(void); 35 35 36 generic_fptr_t interpose_symbol(36 generic_fptr_t libcfa_public interpose_symbol( 37 37 generic_fptr_t (*do_interpose_symbol)( void * library, const char symbol[], const char version[] ), 38 38 const char symbol[], 39 39 const char version[] 40 ) libcfa_public{41 const char * error;40 ) { 41 void * library; 42 42 43 static void * library; 44 if ( ! library ) { 45 #if defined( RTLD_NEXT ) 46 library = RTLD_NEXT; 47 #else 48 // missing RTLD_NEXT => must hard-code library name, assuming libstdc++ 49 library = dlopen( "libpthread.so", RTLD_LAZY ); 50 error = dlerror(); 51 if ( error ) { 52 abort( "interpose_symbol : failed to open libpthread, %s\n", error ); 53 } 54 #endif 43 #if defined( RTLD_NEXT ) 44 library = RTLD_NEXT; 45 #else 46 // missing RTLD_NEXT => must hard-code library name, assuming libstdc++ 47 library = dlopen( "libpthread.so", RTLD_LAZY ); 48 if ( ! library ) { // == nullptr 49 abort( "interpose_symbol : failed to open libpthread, %s\n", dlerror() ); 55 50 } // if 51 #endif // RTLD_NEXT 56 52 57 return do_interpose_symbol( library, symbol, version);53 return do_interpose_symbol( library, symbol, version ); 58 54 } 59 55 … … 83 79 #pragma GCC diagnostic push 84 80 #pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" 85 INTERPOSE( pthread_create , version );86 INTERPOSE( pthread_join , version );87 INTERPOSE( pthread_self , version );88 INTERPOSE( pthread_attr_init , version );89 INTERPOSE( pthread_attr_destroy , version );90 INTERPOSE( pthread_attr_setstack , version );91 INTERPOSE( pthread_attr_getstacksize , version );92 INTERPOSE( pthread_sigmask , version );93 INTERPOSE( pthread_sigqueue , version );94 INTERPOSE( pthread_once , version );81 INTERPOSE( pthread_create, version ); 82 INTERPOSE( pthread_join, version ); 83 INTERPOSE( pthread_self, version ); 84 INTERPOSE( pthread_attr_init, version ); 85 INTERPOSE( pthread_attr_destroy, version ); 86 INTERPOSE( pthread_attr_setstack, version ); 87 INTERPOSE( pthread_attr_getstacksize, version ); 88 INTERPOSE( pthread_sigmask, version ); 89 INTERPOSE( pthread_sigqueue, version ); 90 INTERPOSE( pthread_once, version ); 95 91 #pragma GCC diagnostic pop 96 92 }
Note:
See TracChangeset
for help on using the changeset viewer.