diff options
| author | Andreas Schneider <asn@cryptomilk.org> | 2013-07-05 11:29:22 +0200 |
|---|---|---|
| committer | Andreas Schneider <asn@cryptomilk.org> | 2013-07-05 11:29:22 +0200 |
| commit | 1421501bca3d407b9e5e8680b44014fd73034054 (patch) | |
| tree | b6e8340ec0e3a4a5efa9110767628ab5ef0924b1 /src | |
| parent | 471fd3d71d17210ca0dc583272f757e48bdb9cef (diff) | |
| download | socket_wrapper-1421501bca3d407b9e5e8680b44014fd73034054.tar.gz socket_wrapper-1421501bca3d407b9e5e8680b44014fd73034054.tar.xz socket_wrapper-1421501bca3d407b9e5e8680b44014fd73034054.zip | |
src: Correctly load symbols on APPLE.
Diffstat (limited to 'src')
| -rw-r--r-- | src/socket_wrapper.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index dbf20ac..2412c66 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -282,18 +282,18 @@ 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); } - - /* Maybe we're on MacOSX */ - if (libc_hnd == NULL) { - libc_hnd = dlopen("libc.dylib", flags); - } +#endif if (libc_hnd == NULL) { SWRAP_LOG(SWRAP_LOG_ERROR, @@ -308,10 +308,17 @@ static int libc_dlopen(void) static void *libc_dlsym(const char *name) { void *func; + char sym_name[256]; libc_dlopen(); - func = dlsym(libc_hnd, name); +#ifdef HAVE_APPLE + snprintf(sym_name, sizeof(sym_name), "_%s", name); +#else + snprintf(sym_name, sizeof(sym_name), "%s", name); +#endif + + func = dlsym(libc_hnd, sym_name); if (func == NULL) { SWRAP_LOG(SWRAP_LOG_ERROR, |
