GIOModule: Use unique names for load/unload symbols

GIO modules should include their name into their exported symbols to
make them unique. This avoids symbol clash when building modules
statically.

extract_name() function is copied from GStreamer which recently
switched to the same symbol naming scheme.

https://bugzilla.gnome.org/show_bug.cgi?id=684282
This commit is contained in:
Xavier Claessens
2017-11-30 15:36:21 -05:00
parent e91c118418
commit 7f69b828fc
7 changed files with 153 additions and 9 deletions

View File

@@ -20,6 +20,7 @@
#include "config.h"
#include "giomodule.h"
#include "giomodule-priv.h"
#include <gstdio.h>
#include <errno.h>
@@ -83,7 +84,20 @@ query_dir (const char *dirname)
if (module)
{
g_module_symbol (module, "g_io_module_query", (gpointer) &query);
gchar *modulename;
gchar *symname;
modulename = _g_io_module_extract_name (name);
symname = g_strconcat ("g_io_", modulename, "_query", NULL);
g_module_symbol (module, symname, (gpointer) &query);
g_free (symname);
g_free (modulename);
if (!query)
{
/* Fallback to old name */
g_module_symbol (module, "g_io_module_query", (gpointer) &query);
}
if (query)
{