diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2013-05-13 15:15:21 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2013-05-13 15:15:21 +0200 |
commit | 62277b81067fc1d622a7ba445597d3fe1aefa674 (patch) | |
tree | b97019e88e0ebfb1c2c4145a37ab91c533947265 /src | |
parent | 7614d2da3f67976b77781a02f0fb78b930782c65 (diff) | |
download | socket_wrapper-62277b81067fc1d622a7ba445597d3fe1aefa674.tar.gz socket_wrapper-62277b81067fc1d622a7ba445597d3fe1aefa674.tar.xz socket_wrapper-62277b81067fc1d622a7ba445597d3fe1aefa674.zip |
src: Implement a more portable libc loader.
Diffstat (limited to 'src')
-rw-r--r-- | src/socket_wrapper.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 5b4711f..5005162 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -143,18 +143,27 @@ #include <dlfcn.h> -#define LIBC_NAME "libc.so.6" +#define LIBC_NAME "libc.so" static void *libc_hnd; static int libc_dlopen(void) { + unsigned int i; + if (libc_hnd != NULL) { return 0; } - libc_hnd = dlopen(LIBC_NAME, RTLD_LAZY); + + 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, RTLD_LAZY); + } + if (libc_hnd == NULL) { - printf("Failed to dlopen %s: %s\n", LIBC_NAME, dlerror()); + printf("Failed to dlopen %s.%u: %s\n", LIBC_NAME, i, dlerror()); exit(-1); } |