Changes in libcfa/src/interpose_thread.cfa [e10714a:7f81ef4]
- File:
-
- 1 edited
-
libcfa/src/interpose_thread.cfa (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/interpose_thread.cfa
re10714a r7f81ef4 14 14 // 15 15 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 16 #include <stdarg.h> // va_start, va_end 17 #include <stdio.h> 18 #include <string.h> // strlen 21 19 #include <signal.h> 22 20 #include <pthread.h> 23 #include <signal.h>24 21 extern "C" { 25 22 #include <dlfcn.h> // dlopen, dlsym 23 #include <execinfo.h> // backtrace, messages 26 24 } 27 25 26 #include "bits/debug.hfa" 28 27 #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 libcfa_publicinterpose_symbol(36 generic_fptr_t 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 ) {41 void * library;40 ) libcfa_public { 41 const char * error; 42 42 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() ); 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 50 55 } // if 51 #endif // RTLD_NEXT52 56 53 return do_interpose_symbol( library, symbol, version);57 return do_interpose_symbol(library, symbol, version); 54 58 } 55 59 … … 79 83 #pragma GCC diagnostic push 80 84 #pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" 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 );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 ); 91 95 #pragma GCC diagnostic pop 92 96 }
Note:
See TracChangeset
for help on using the changeset viewer.