1From 9a66887179d28d696562dcac43ad05d67580cfdb Mon Sep 17 00:00:00 2001 2From: Ross Burton <ross.burton@intel.com> 3Date: Fri, 11 Mar 2016 15:35:55 +0000 4Subject: [PATCH] glib-2.0: relocate the GIO module directory for native builds 5 6Instead of hard-coding GIO_MODULE_PATH when glib is built, use dladdr() to 7determine where libglib.so is and use that path to calculate GIO_MODULES_DIR. 8 9This solves relocation problems with GIOModule for native builds of glib. 10 11Upstream-Status: Inappropriate 12Signed-off-by: Ross Burton <ross.burton@intel.com> 13 14Port patch to 2.48 15Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com> 16 17--- 18 gio/giomodule.c | 12 +++++++++++- 19 1 file changed, 11 insertions(+), 1 deletion(-) 20 21diff --git a/gio/giomodule.c b/gio/giomodule.c 22index 2a043cc..e2d2310 100644 23--- a/gio/giomodule.c 24+++ b/gio/giomodule.c 25@@ -56,6 +56,8 @@ 26 #ifdef G_OS_WIN32 27 #include "gregistrysettingsbackend.h" 28 #include "giowin32-priv.h" 29+#else 30+#include <dlfcn.h> 31 #endif 32 #include <glib/gstdio.h> 33 34@@ -1267,7 +1269,15 @@ get_gio_module_dir (void) 35 NULL); 36 g_free (install_dir); 37 #else 38- module_dir = g_strdup (GIO_MODULE_DIR); 39+ Dl_info info; 40+ 41+ if (dladdr (g_io_module_new, &info)) { 42+ char *libdir = g_path_get_dirname (info.dli_fname); 43+ module_dir = g_build_filename (libdir, "gio", "modules", NULL); 44+ g_free (libdir); 45+ } else { 46+ module_dir = g_strdup (GIO_MODULE_DIR); 47+ } 48 #endif 49 } 50 51