blob: 65d5b43f9b6fb6b46b5288cfd89e38f5897a2515 [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001Instead of hard-coding GIO_MODULE_PATH when glib is built, use dladdr() to
2determine where libglib.so is and use that path to calculate GIO_MODULES_DIR.
3
4This solves relocation problems with GIOModule for native builds of glib.
5
6Upstream-Status: Inappropriate
7Signed-off-by: Ross Burton <ross.burton@intel.com>
8
Patrick Williamsc0f7c042017-02-23 20:41:17 -06009Port patch to 2.48
10Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
11---
12 gio/giomodule.c | 12 +++++++++++-
13 1 file changed, 11 insertions(+), 1 deletion(-)
14
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050015diff --git a/gio/giomodule.c b/gio/giomodule.c
Patrick Williamsc0f7c042017-02-23 20:41:17 -060016index da7c167..cc0bc7c 100644
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050017--- a/gio/giomodule.c
18+++ b/gio/giomodule.c
Patrick Williamsc0f7c042017-02-23 20:41:17 -060019@@ -40,6 +40,8 @@
20 #include "gnetworkmonitor.h"
21 #ifdef G_OS_WIN32
22 #include "gregistrysettingsbackend.h"
23+#else
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050024+#include <dlfcn.h>
Patrick Williamsc0f7c042017-02-23 20:41:17 -060025 #endif
26 #include <glib/gstdio.h>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050027
Patrick Williamsc0f7c042017-02-23 20:41:17 -060028@@ -1036,7 +1038,15 @@ get_gio_module_dir (void)
29 #endif
30 g_free (install_dir);
31 #else
32- module_dir = g_strdup (GIO_MODULE_DIR);
33+ Dl_info info;
34+
35+ if (dladdr (g_io_module_new, &info)) {
36+ char *libdir = g_path_get_dirname (info.dli_fname);
37+ module_dir = g_build_filename (libdir, "gio", "modules", NULL);
38+ g_free (libdir);
39+ } else {
40+ module_dir = g_strdup (GIO_MODULE_DIR);
41+ }
42 #endif
43 }
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050044
Patrick Williamsc0f7c042017-02-23 20:41:17 -060045--
462.1.4
47