Try to call _zz_init() as soon as possible. Otherwise, preloaded libraries
might be confused about half the calls actually working.
This commit is contained in:
@@ -26,7 +26,13 @@
|
||||
# define LOADSYM(x) \
|
||||
do { \
|
||||
if(!ORIG(x)) \
|
||||
{ \
|
||||
/* XXX: we try to initialise libzzuf as soon as possible, \
|
||||
* otherwise we may miss a lot of stuff if we wait for \
|
||||
* the linker to load us fully. */ \
|
||||
_zz_init(); \
|
||||
ORIG(x) = dlsym(RTLD_NEXT, STR(x)); \
|
||||
} \
|
||||
if(!ORIG(x)) \
|
||||
abort(); \
|
||||
} while(0)
|
||||
@@ -34,7 +40,8 @@
|
||||
# define NEW(x) x##_new
|
||||
# define LOADSYM(x) \
|
||||
do { \
|
||||
/* Nothing to do */ \
|
||||
/* Nothing to do under Windows, everything is done as soon \
|
||||
* as the process is launched. */ \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
+12
-9
@@ -48,15 +48,6 @@
|
||||
#include "sys.h"
|
||||
#include "fuzz.h"
|
||||
|
||||
/* Library initialisation shit */
|
||||
#if defined __GNUC__
|
||||
void _zz_init(void) __attribute__((constructor));
|
||||
void _zz_fini(void) __attribute__((destructor));
|
||||
#elif defined HAVE_PRAGMA_INIT
|
||||
# pragma INIT "_zz_init"
|
||||
# pragma FINI "_zz_fini"
|
||||
#endif
|
||||
|
||||
#if defined HAVE_WINDOWS_H
|
||||
BOOL WINAPI DllMain(HINSTANCE, DWORD, PVOID);
|
||||
#endif
|
||||
@@ -114,8 +105,13 @@ int _zz_network = 0;
|
||||
*/
|
||||
void _zz_init(void)
|
||||
{
|
||||
static int initializing = 0;
|
||||
char *tmp, *tmp2;
|
||||
|
||||
/* Make sure we don't get initialised more than once */
|
||||
if (initializing++)
|
||||
return;
|
||||
|
||||
tmp = getenv("ZZUF_DEBUG");
|
||||
if(tmp)
|
||||
_zz_debuglevel = atoi(tmp);
|
||||
@@ -208,8 +204,15 @@ void _zz_init(void)
|
||||
*/
|
||||
void _zz_fini(void)
|
||||
{
|
||||
if (!_zz_ready)
|
||||
return;
|
||||
|
||||
debug("libzzuf finishing for PID %li", (long int)getpid());
|
||||
|
||||
_zz_fd_fini();
|
||||
_zz_network_fini();
|
||||
|
||||
_zz_ready = 0;
|
||||
}
|
||||
|
||||
#if defined HAVE_WINDOWS_H
|
||||
|
||||
@@ -26,6 +26,15 @@ extern int _zz_memory;
|
||||
extern int _zz_network;
|
||||
extern int _zz_autoinc;
|
||||
|
||||
/* Library initialisation shit */
|
||||
#if defined __GNUC__
|
||||
extern void _zz_init(void) __attribute__((constructor));
|
||||
extern void _zz_fini(void) __attribute__((destructor));
|
||||
#elif defined HAVE_PRAGMA_INIT
|
||||
# pragma INIT "_zz_init"
|
||||
# pragma FINI "_zz_fini"
|
||||
#endif
|
||||
|
||||
/* This function is needed to initialise memory functions */
|
||||
extern void _zz_mem_init(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user