mirror of
https://github.com/rofl0r/proxychains-ng.git
synced 2024-12-21 11:48:57 +00:00
disable lazy init if compiler supports GCC constructor attribute
before we started to use the gcc constructor attribute to load our initialization code, each function hook used to check whether the initialization was already done, and if not, do it at that point. this workaround is quite ugly, and creates a circular reference if the startup code calls any of the hooked functions. now we only do the lazy init if the compiler used is not GCC compatible.
This commit is contained in:
parent
66f99b19dd
commit
2d265582a2
@ -105,9 +105,6 @@ static void* load_sym(char* symname, void* proxyfunc, int is_mandatory) {
|
||||
return funcptr;
|
||||
}
|
||||
|
||||
#define INIT() init_lib_wrapper(__FUNCTION__)
|
||||
|
||||
|
||||
#include "allocator_thread.h"
|
||||
|
||||
const char *proxychains_get_version(void);
|
||||
@ -165,16 +162,19 @@ static void init_lib_wrapper(const char* caller) {
|
||||
pthread_once(&init_once, do_init);
|
||||
}
|
||||
|
||||
/* if we use gcc >= 3, we can instruct the dynamic loader
|
||||
/* if we use gcc >= 3, we can instruct the dynamic loader
|
||||
* to call init_lib at link time. otherwise it gets loaded
|
||||
* lazily, which has the disadvantage that there's a potential
|
||||
* race condition if 2 threads call it before init_l is set
|
||||
* race condition if 2 threads call it before init_l is set
|
||||
* and PTHREAD support was disabled */
|
||||
#if __GNUC__ > 2
|
||||
#if __GNUC__+0 > 2
|
||||
__attribute__((constructor))
|
||||
static void gcc_init(void) {
|
||||
INIT();
|
||||
init_lib_wrapper(__FUNCTION__);
|
||||
}
|
||||
#define INIT() do {} while(0)
|
||||
#else
|
||||
#define INIT() init_lib_wrapper(__FUNCTION__)
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user