$NetBSD: patch-aa,v 1.14 2006/10/08 18:40:23 ben Exp $ --- src/loadso/dlopen/SDL_sysloadso.c.orig 2006-05-01 01:02:37.000000000 -0700 +++ src/loadso/dlopen/SDL_sysloadso.c @@ -31,9 +31,32 @@ #include "SDL_loadso.h" +static void *get_dlopen_handle(const char *sofile) +{ + static const char * const libdirs[] = { + PREFIX "/lib/", + X11BASE "/lib/", + }; + unsigned i; + void *handle; + + for (i = 0; i < sizeof libdirs / sizeof libdirs[0]; i++) { + char buf[1024]; + + strncpy(buf, libdirs[i], sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; + strncat(buf, sofile, sizeof(buf) - strlen(buf) - 1); + + handle = dlopen(buf, RTLD_NOW); + if (handle) + break; + } + return handle; +} + void *SDL_LoadObject(const char *sofile) { - void *handle = dlopen(sofile, RTLD_NOW); + void *handle = get_dlopen_handle(sofile); const char *loaderror = (char *)dlerror(); if ( handle == NULL ) { SDL_SetError("Failed loading %s: %s", sofile, loaderror);