2016-01-21 23:40:00 +01:00

47 lines
1.2 KiB
Plaintext

$NetBSD: patch-aa,v 1.16 2014/08/17 09:24:47 wiz Exp $
Try to dlopen the libraries straight from the directories they are in.
--- src/loadso/dlopen/SDL_sysloadso.c.orig 2012-01-19 06:30:06.000000000 +0000
+++ src/loadso/dlopen/SDL_sysloadso.c
@@ -31,9 +31,38 @@
#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;
+
+ /* first, try file name directly */
+ handle = dlopen(sofile, RTLD_NOW);
+ if (handle)
+ return handle;
+
+ /* if that didn't work, prefix known locations and try again */
+ 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);