Mike Frysinger | f2e27cf | 2009-11-06 06:09:22 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Stub dlfcn implementation for systems that lack shared library support |
| 3 | * but obviously can still reference compiled-in symbols. |
| 4 | */ |
| 5 | |
| 6 | #ifndef NO_SHARED_LIBS |
| 7 | #include_next <dlfcn.h> |
| 8 | #else |
| 9 | |
| 10 | #define RTLD_LAZY 0 |
Stephen Hemminger | e7b24b6 | 2013-03-13 08:29:59 -0700 | [diff] [blame] | 11 | #define RTLD_GLOBAL 1 |
Mike Frysinger | f2e27cf | 2009-11-06 06:09:22 -0500 | [diff] [blame] | 12 | #define _FAKE_DLFCN_HDL (void *)0xbeefcafe |
| 13 | |
| 14 | static inline void *dlopen(const char *file, int flag) |
| 15 | { |
| 16 | if (file == NULL) |
| 17 | return _FAKE_DLFCN_HDL; |
| 18 | else |
| 19 | return NULL; |
| 20 | } |
| 21 | |
Stephen Hemminger | 892e212 | 2015-08-13 14:09:58 -0700 | [diff] [blame] | 22 | void *_dlsym(const char *sym); |
Mike Frysinger | f2e27cf | 2009-11-06 06:09:22 -0500 | [diff] [blame] | 23 | static inline void *dlsym(void *handle, const char *sym) |
| 24 | { |
| 25 | if (handle != _FAKE_DLFCN_HDL) |
| 26 | return NULL; |
| 27 | return _dlsym(sym); |
| 28 | } |
| 29 | |
| 30 | static inline char *dlerror(void) |
| 31 | { |
| 32 | return NULL; |
| 33 | } |
| 34 | |
| 35 | static inline int dlclose(void *handle) |
| 36 | { |
| 37 | return (handle == _FAKE_DLFCN_HDL) ? 0 : 1; |
| 38 | } |
| 39 | |
| 40 | #endif |