gplugin/gplugin

Parents 9930711e7f29
Children 5c70c93d2727
Convert the logical for the native load to bind symbols locally first. Fixes GPLUGIN-119

Testing Done:
Built and ran the tests locally.

Reviewed at https://reviews.imfreedom.org/r/108/
--- a/gplugin-query/gplugin-query.c Sun Sep 06 01:35:55 2020 -0500
+++ b/gplugin-query/gplugin-query.c Sun Sep 06 01:36:08 2020 -0500
@@ -118,7 +118,7 @@
for(l = plugins; l; l = l->next) {
GPluginPlugin *plugin = GPLUGIN_PLUGIN(l->data);
GPluginPluginInfo *info = gplugin_plugin_get_info(plugin);
- gboolean internal, loq;
+ gboolean internal, loq, bind_global;
guint32 abi_version;
gchar *name, *version;
gchar *license_id, *license_text, *license_url;
@@ -153,6 +153,7 @@
"authors", &authors,
"website", &website,
"dependencies", &dependencies,
+ "bind-global", &bind_global,
NULL);
/* clang-format on */
@@ -193,6 +194,7 @@
printf(MAIN_FORMAT_NEL "%08x\n", "abi version", abi_version);
printf(MAIN_FORMAT, "internal", (internal) ? "yes" : "no");
printf(MAIN_FORMAT, "load on query", (loq) ? "yes" : "no");
+ printf(MAIN_FORMAT, "bind globally", (bind_global) ? "yes" : "no");
printf(MAIN_FORMAT, "loader", G_OBJECT_TYPE_NAME(loader));
g_object_unref(G_OBJECT(loader));
--- a/gplugin/gplugin-native-loader.c Sun Sep 06 01:35:55 2020 -0500
+++ b/gplugin/gplugin-native-loader.c Sun Sep 06 01:36:08 2020 -0500
@@ -181,7 +181,7 @@
info = gplugin_native_loader_open_and_query(
filename,
&module,
- 0,
+ G_MODULE_BIND_LOCAL,
&query,
error);
if(!GPLUGIN_IS_PLUGIN_INFO(info)) {
@@ -197,14 +197,14 @@
return NULL;
}
- if(gplugin_plugin_info_get_bind_local(info)) {
+ if(gplugin_plugin_info_get_bind_global(info)) {
g_module_close(module);
g_object_unref(G_OBJECT(info));
info = gplugin_native_loader_open_and_query(
filename,
&module,
- G_MODULE_BIND_LOCAL,
+ 0,
&query,
error);
if(!GPLUGIN_IS_PLUGIN_INFO(info)) {
--- a/gplugin/gplugin-plugin-info.c Sun Sep 06 01:35:55 2020 -0500
+++ b/gplugin/gplugin-plugin-info.c Sun Sep 06 01:36:08 2020 -0500
@@ -75,7 +75,7 @@
gboolean internal;
gboolean load_on_query;
- gboolean bind_local;
+ gboolean bind_global;
} GPluginPluginInfoPrivate;
/******************************************************************************
@@ -87,7 +87,7 @@
PROP_ABI_VERSION,
PROP_INTERNAL,
PROP_LOQ,
- PROP_BIND_LOCAL,
+ PROP_BIND_GLOBAL,
PROP_NAME,
PROP_VERSION,
PROP_LICENSE_ID,
@@ -154,12 +154,14 @@
}
static void
-gplugin_plugin_info_set_bind_local(GPluginPluginInfo *info, gboolean bind_local)
+gplugin_plugin_info_set_bind_global(
+ GPluginPluginInfo *info,
+ gboolean bind_global)
{
GPluginPluginInfoPrivate *priv =
gplugin_plugin_info_get_instance_private(info);
- priv->bind_local = bind_local;
+ priv->bind_global = bind_global;
}
static void
@@ -325,10 +327,10 @@
value,
gplugin_plugin_info_get_load_on_query(info));
break;
- case PROP_BIND_LOCAL:
+ case PROP_BIND_GLOBAL:
g_value_set_boolean(
value,
- gplugin_plugin_info_get_bind_local(info));
+ gplugin_plugin_info_get_bind_global(info));
break;
case PROP_NAME:
g_value_set_string(value, gplugin_plugin_info_get_name(info));
@@ -404,8 +406,8 @@
info,
g_value_get_boolean(value));
break;
- case PROP_BIND_LOCAL:
- gplugin_plugin_info_set_bind_local(
+ case PROP_BIND_GLOBAL:
+ gplugin_plugin_info_set_bind_global(
info,
g_value_get_boolean(value));
break;
@@ -575,16 +577,16 @@
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
/**
- * GPluginPluginInfo:bind-local:
+ * GPluginPluginInfo:bind-global:
*
- * Determines whether the plugin should be have its symbols bound locally.
+ * Determines whether the plugin should be have its symbols bound globally.
*
* Note: This should only be used by the native plugin loader.
*/
- properties[PROP_BIND_LOCAL] = g_param_spec_boolean(
- "bind-local",
- "bind-local",
- "Whether symbols should be bound locally",
+ properties[PROP_BIND_GLOBAL] = g_param_spec_boolean(
+ "bind-global",
+ "bind-global",
+ "Whether symbols should be bound globally",
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
@@ -1099,16 +1101,17 @@
}
/**
- * gplugin_plugin_info_get_bind_local:
+ * gplugin_plugin_info_get_bind_global:
* @info: The #GPluginPluginInfo instance.
*
- * This function is only used by the native plugin loader.
+ * This propoerty and therefore function is only used by the native plugin
+ * loader.
*
* Returns: %TRUE if the plugin has requested to be loaded with its symbols
- * bound locally, %FALSE if they should be bound globally.
+ * bound global, %FALSE if they should be bound locally.
*/
gboolean
-gplugin_plugin_info_get_bind_local(GPluginPluginInfo *info)
+gplugin_plugin_info_get_bind_global(GPluginPluginInfo *info)
{
GPluginPluginInfoPrivate *priv = NULL;
@@ -1116,5 +1119,5 @@
priv = gplugin_plugin_info_get_instance_private(info);
- return priv->bind_local;
+ return priv->bind_global;
}
--- a/gplugin/gplugin-plugin-info.h Sun Sep 06 01:35:55 2020 -0500
+++ b/gplugin/gplugin-plugin-info.h Sun Sep 06 01:36:08 2020 -0500
@@ -71,6 +71,7 @@
const gchar *gplugin_plugin_info_get_website(GPluginPluginInfo *info);
const gchar *const *gplugin_plugin_info_get_dependencies(
GPluginPluginInfo *info);
+gboolean gplugin_plugin_info_get_bind_global(GPluginPluginInfo *info);
G_END_DECLS
--- a/gplugin/gplugin-private.h Sun Sep 06 01:35:55 2020 -0500
+++ b/gplugin/gplugin-private.h Sun Sep 06 01:36:08 2020 -0500
@@ -39,8 +39,6 @@
const GValue *handler_return,
gpointer data);
-gboolean gplugin_plugin_info_get_bind_local(GPluginPluginInfo *info);
-
G_END_DECLS
#endif /* GPLUGIN_PRIVATE_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/bind-global/bind-global.c Sun Sep 06 01:36:08 2020 -0500
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gplugin.h>
+#include <gplugin-native.h>
+
+G_MODULE_EXPORT GPluginPluginInfo *
+gplugin_query(G_GNUC_UNUSED GError **error)
+{
+ /* clang-format off */
+ return gplugin_plugin_info_new(
+ "gplugin/bind-global",
+ 0x04030201,
+ "bind-global", TRUE,
+ NULL);
+ /* clang-format on */
+}
+
+G_MODULE_EXPORT gboolean
+gplugin_load(
+ G_GNUC_UNUSED GPluginNativePlugin *plugin,
+ G_GNUC_UNUSED GError **error)
+{
+ return TRUE;
+}
+
+G_MODULE_EXPORT gboolean
+gplugin_unload(
+ G_GNUC_UNUSED GPluginNativePlugin *plugin,
+ G_GNUC_UNUSED GError **error)
+{
+ return TRUE;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/bind-global/meson.build Sun Sep 06 01:36:08 2020 -0500
@@ -0,0 +1,3 @@
+shared_library('bind-global', 'bind-global.c',
+ name_prefix : '',
+ dependencies : [gplugin_dep, GLIB])
--- a/gplugin/tests/bind-local/bind-local.c Sun Sep 06 01:35:55 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <gplugin.h>
-#include <gplugin-native.h>
-
-G_MODULE_EXPORT GPluginPluginInfo *
-gplugin_query(G_GNUC_UNUSED GError **error)
-{
- /* clang-format off */
- return gplugin_plugin_info_new(
- "gplugin/bind-local",
- 0x04030201,
- "bind-local", TRUE,
- NULL);
- /* clang-format on */
-}
-
-G_MODULE_EXPORT gboolean
-gplugin_load(
- G_GNUC_UNUSED GPluginNativePlugin *plugin,
- G_GNUC_UNUSED GError **error)
-{
- return TRUE;
-}
-
-G_MODULE_EXPORT gboolean
-gplugin_unload(
- G_GNUC_UNUSED GPluginNativePlugin *plugin,
- G_GNUC_UNUSED GError **error)
-{
- return TRUE;
-}
--- a/gplugin/tests/bind-local/meson.build Sun Sep 06 01:35:55 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-shared_library('bind-local', 'bind-local.c',
- name_prefix : '',
- dependencies : [gplugin_dep, GLIB])
--- a/gplugin/tests/dynamic-type/dynamic-type-provider.c Sun Sep 06 01:35:55 2020 -0500
+++ b/gplugin/tests/dynamic-type/dynamic-type-provider.c Sun Sep 06 01:36:08 2020 -0500
@@ -44,6 +44,8 @@
return gplugin_plugin_info_new(
"gplugin/dynamic-type-provider",
GPLUGIN_NATIVE_PLUGIN_ABI_VERSION,
+ "bind-global",
+ TRUE,
NULL);
}
--- a/gplugin/tests/meson.build Sun Sep 06 01:35:55 2020 -0500
+++ b/gplugin/tests/meson.build Sun Sep 06 01:36:08 2020 -0500
@@ -2,7 +2,7 @@
# Subdirectories
###############################################################################
subdir('bad-plugins')
-subdir('bind-local')
+subdir('bind-global')
subdir('dynamic-type')
subdir('id-collision')
subdir('load-on-query-fail')
@@ -131,9 +131,9 @@
###############################################################################
# Bind Local
###############################################################################
-e = executable('test-bind-local', 'test-bind-local.c',
+e = executable('test-bind-global', 'test-bind-global.c',
c_args : [
- '-DTEST_BIND_LOCAL_DIR="@0@/bind-local/"'.format(
+ '-DTEST_BIND_GLOBAL_DIR="@0@/bind-global/"'.format(
meson.current_build_dir()),
'-DTEST_BAD_DIR="@0@/bad-plugins/"'.format(
meson.current_build_dir()),
@@ -141,7 +141,7 @@
meson.current_build_dir()),
],
dependencies : [gplugin_dep, GLIB, GOBJECT])
-test('Bind Local', e)
+test('Bind Global', e)
###############################################################################
# Unresolved Symbol
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/test-bind-global.c Sun Sep 06 01:36:08 2020 -0500
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+
+#include <glib.h>
+
+#include <gplugin.h>
+#include <gplugin-native.h>
+
+/******************************************************************************
+ * Tests
+ *****************************************************************************/
+
+/* This test kind of sucks because theres no way for us to lookup whether or
+ * not a module handle has had its symbols bound globally. Therefore, right
+ * now we have to settle to see if it was loaded correctly.
+ */
+static void
+test_bind_global(void)
+{
+ GPluginPlugin *plugin = NULL;
+
+ gplugin_manager_remove_paths();
+ gplugin_manager_append_path(TEST_BIND_GLOBAL_DIR);
+ gplugin_manager_refresh();
+
+ plugin = gplugin_manager_find_plugin("gplugin/bind-global");
+ g_assert_nonnull(plugin);
+ g_assert_true(GPLUGIN_IS_PLUGIN(plugin));
+ g_assert_true(GPLUGIN_IS_NATIVE_PLUGIN(plugin));
+}
+
+/******************************************************************************
+ * Main
+ *****************************************************************************/
+gint
+main(gint argc, gchar **argv)
+{
+
+ g_test_init(&argc, &argv, NULL);
+
+ gplugin_init();
+
+ /* test the load on query flag */
+ g_test_add_func("/loaders/native/bind-global", test_bind_global);
+
+ return g_test_run();
+}
--- a/gplugin/tests/test-bind-local.c Sun Sep 06 01:35:55 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2011-2014 Gary Kramlich <grim@reaperworld.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdlib.h>
-
-#include <glib.h>
-
-#include <gplugin.h>
-#include <gplugin-native.h>
-
-/******************************************************************************
- * Tests
- *****************************************************************************/
-
-/* This test kind of sucks because theres no way for us to lookup whether or
- * not a module handle has had its symbols bound locally. Therefore, right
- * now we have to settle to see if it was loaded correctly.
- */
-static void
-test_bind_local(void)
-{
- GPluginPlugin *plugin = NULL;
-
- gplugin_manager_remove_paths();
- gplugin_manager_append_path(TEST_BIND_LOCAL_DIR);
- gplugin_manager_refresh();
-
- plugin = gplugin_manager_find_plugin("gplugin/bind-local");
- g_assert_nonnull(plugin);
- g_assert_true(GPLUGIN_IS_PLUGIN(plugin));
- g_assert_true(GPLUGIN_IS_NATIVE_PLUGIN(plugin));
-}
-
-/******************************************************************************
- * Main
- *****************************************************************************/
-gint
-main(gint argc, gchar **argv)
-{
-
- g_test_init(&argc, &argv, NULL);
-
- gplugin_init();
-
- /* test the load on query flag */
- g_test_add_func("/loaders/native/bind-local", test_bind_local);
-
- return g_test_run();
-}
--- a/lua/gplugin-lua-core.c Sun Sep 06 01:35:55 2020 -0500
+++ b/lua/gplugin-lua-core.c Sun Sep 06 01:36:08 2020 -0500
@@ -48,6 +48,7 @@
"authors", authors,
"website", GPLUGIN_WEBSITE,
"category", "loaders",
+ "bind-global", TRUE,
NULL);
/* clang-format on */
}
--- a/perl5/gplugin-perl5-core.c Sun Sep 06 01:35:55 2020 -0500
+++ b/perl5/gplugin-perl5-core.c Sun Sep 06 01:36:08 2020 -0500
@@ -47,6 +47,7 @@
"authors", authors,
"website", GPLUGIN_WEBSITE,
"category", "loaders",
+ "bind-global", TRUE,
NULL);
/* clang-format on */
}
--- a/python3/gplugin-python3-core.c Sun Sep 06 01:35:55 2020 -0500
+++ b/python3/gplugin-python3-core.c Sun Sep 06 01:36:08 2020 -0500
@@ -48,6 +48,7 @@
"authors", authors,
"website", GPLUGIN_WEBSITE,
"category", "loaders",
+ "bind-global", TRUE,
NULL);
/* clang-format on */
}