diff options
| author | Andreas Schneider <asn@cryptomilk.org> | 2013-11-14 17:53:32 +0100 |
|---|---|---|
| committer | Andreas Schneider <asn@cryptomilk.org> | 2013-11-14 17:53:32 +0100 |
| commit | 6aa24a27e11e8a992d50a9e84e7a8bf70fe096a1 (patch) | |
| tree | c8770ed40d5f8822cc8a1dc6857fe7cf560da5c3 | |
| parent | 5a2f2088a19bf89945aec9f466080eb22eb6b62b (diff) | |
| download | socket_wrapper-6aa24a27e11e8a992d50a9e84e7a8bf70fe096a1.tar.gz socket_wrapper-6aa24a27e11e8a992d50a9e84e7a8bf70fe096a1.tar.xz socket_wrapper-6aa24a27e11e8a992d50a9e84e7a8bf70fe096a1.zip | |
swrap: Fix symbol loading on OSX.
| -rw-r--r-- | src/socket_wrapper.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 0031cb7..d4a565a 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -271,6 +271,7 @@ static void swrap_log(enum swrap_dbglvl_e dbglvl, const char *format, ...) #define LIBC_NAME "libc.so" +#ifndef HAVE_APPLE static void *libc_hnd; static int libc_dlopen(void) @@ -286,18 +287,12 @@ static int libc_dlopen(void) return 0; } -#ifdef HAVE_APPLE - if (libc_hnd == NULL) { - libc_hnd = dlopen("libc.dylib", flags); - } -#else for (libc_hnd = NULL, i = 10; libc_hnd == NULL; i--) { char soname[256] = {0}; snprintf(soname, sizeof(soname), "%s.%u", LIBC_NAME, i); libc_hnd = dlopen(soname, flags); } -#endif if (libc_hnd == NULL) { SWRAP_LOG(SWRAP_LOG_ERROR, @@ -308,21 +303,21 @@ static int libc_dlopen(void) return 0; } +#endif static void *libc_dlsym(const char *name) { void *func; - char sym_name[256]; libc_dlopen(); #ifdef HAVE_APPLE - snprintf(sym_name, sizeof(sym_name), "_%s", name); + func = dlsym(RTLD_NEXT, name); #else - snprintf(sym_name, sizeof(sym_name), "%s", name); -#endif + libc_dlopen(); - func = dlsym(libc_hnd, sym_name); + func = dlsym(libc_hnd, name); +#endif if (func == NULL) { SWRAP_LOG(SWRAP_LOG_ERROR, |
