1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
$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);
|