source: zzuf/trunk/src/libzzuf/lib-load.h @ 4809

Revision 4809, 1.5 KB checked in by sam, 13 months ago (diff)

Fix a weird problem with lib6 versioned symbols.

  • Property svn:keywords set to Id
Line 
1/*
2 *  zzuf - general purpose fuzzer
3 *  Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net>
4 *                All Rights Reserved
5 *
6 *  This program is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
12
13/*
14 *  lib-load.h: preload library functions
15 */
16
17/* Symbol loading stuff */
18#define STR(x) #x
19#define ORIG(x) x##_orig
20
21#if defined HAVE_DLFCN_H
22#   include <dlfcn.h>
23#   define NEW(x) x
24#   define LOADSYM(x) \
25        do { \
26            if(!ORIG(x)) \
27            { \
28                /* XXX: we try to initialise libzzuf as soon as possible, \
29                 * otherwise we may miss a lot of stuff if we wait for \
30                 * the linker to load us fully. */ \
31                _zz_init(); \
32                extern void *_zz_dl_lib; \
33                ORIG(x) = dlsym(_zz_dl_lib, STR(x)); \
34            } \
35            if(!ORIG(x)) \
36                abort(); \
37        } while(0)
38#elif defined _WIN32
39#   define NEW(x) x##_new
40#   define LOADSYM(x) \
41        do { \
42            /* Nothing to do under Windows, everything is done as soon \
43             * as the process is launched. */ \
44        } while(0)
45
46typedef struct
47{
48    char const *lib, *name;
49    void **old;
50    void *new;
51}
52zzuf_table_t;
53
54extern zzuf_table_t table_win32[];
55
56#else
57#   error no function diversion system for this platform
58#endif
59
Note: See TracBrowser for help on using the repository browser.