From 62277b81067fc1d622a7ba445597d3fe1aefa674 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 13 May 2013 15:15:21 +0200 Subject: src: Implement a more portable libc loader. --- src/socket_wrapper.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') 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 -#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); } -- cgit