Changeset 4152


Ignore:
Timestamp:
Dec 20, 2009, 1:24:56 PM (11 years ago)
Author:
Sam Hocevar
Message:

Try to call _zz_init() as soon as possible. Otherwise, preloaded libraries
might be confused about half the calls actually working.

Location:
zzuf/trunk/src/libzzuf
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/libzzuf/lib-load.h

    r4112 r4152  
    2727        do { \
    2828            if(!ORIG(x)) \
     29            { \
     30                /* XXX: we try to initialise libzzuf as soon as possible, \
     31                 * otherwise we may miss a lot of stuff if we wait for \
     32                 * the linker to load us fully. */ \
     33                _zz_init(); \
    2934                ORIG(x) = dlsym(RTLD_NEXT, STR(x)); \
     35            } \
    3036            if(!ORIG(x)) \
    3137                abort(); \
     
    3541#   define LOADSYM(x) \
    3642        do { \
    37             /* Nothing to do */ \
     43            /* Nothing to do under Windows, everything is done as soon \
     44             * as the process is launched. */ \
    3845        } while(0)
    3946#endif
  • zzuf/trunk/src/libzzuf/libzzuf.c

    r4112 r4152  
    4949#include "fuzz.h"
    5050
    51 /* Library initialisation shit */
    52 #if defined __GNUC__
    53 void _zz_init(void) __attribute__((constructor));
    54 void _zz_fini(void) __attribute__((destructor));
    55 #elif defined HAVE_PRAGMA_INIT
    56 #   pragma INIT "_zz_init"
    57 #   pragma FINI "_zz_fini"
    58 #endif
    59 
    6051#if defined HAVE_WINDOWS_H
    6152BOOL WINAPI DllMain(HINSTANCE, DWORD, PVOID);
     
    115106void _zz_init(void)
    116107{
     108    static int initializing = 0;
    117109    char *tmp, *tmp2;
     110
     111    /* Make sure we don't get initialised more than once */
     112    if (initializing++)
     113        return;
    118114
    119115    tmp = getenv("ZZUF_DEBUG");
     
    209205void _zz_fini(void)
    210206{
     207    if (!_zz_ready)
     208        return;
     209
     210    debug("libzzuf finishing for PID %li", (long int)getpid());
     211
    211212    _zz_fd_fini();
    212213    _zz_network_fini();
     214
     215    _zz_ready = 0;
    213216}
    214217
  • zzuf/trunk/src/libzzuf/libzzuf.h

    r4112 r4152  
    2727extern int _zz_autoinc;
    2828
     29/* Library initialisation shit */
     30#if defined __GNUC__
     31extern void _zz_init(void) __attribute__((constructor));
     32extern void _zz_fini(void) __attribute__((destructor));
     33#elif defined HAVE_PRAGMA_INIT
     34#   pragma INIT "_zz_init"
     35#   pragma FINI "_zz_fini"
     36#endif
     37
    2938/* This function is needed to initialise memory functions */
    3039extern void _zz_mem_init(void);
Note: See TracChangeset for help on using the changeset viewer.