summaryrefslogtreecommitdiff
path: root/gcc/plugin.c
diff options
context:
space:
mode:
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-18 19:48:35 +0000
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-18 19:48:35 +0000
commit8e6de413fd07b372b9243521ed3144af8e2e7bdb (patch)
tree79b33d246f25f2bed1420ec88101b2b444ad38fd /gcc/plugin.c
parent7f78414b49b493be11c50abba0e278296143efa9 (diff)
downloadgcc-8e6de413fd07b372b9243521ed3144af8e2e7bdb.tar.gz
* doc/plugins.texi: Document plugin_is_GPL_compatible.
* plugin.c (str_license): Declare. (try_init_one_plugin): Assert that the symbol 'plugin_is_GPL_compatible' exists. testsuite/ChangeLog * gcc.dg/plugin/selfassign.c: Declare plugin_is_GPL_compatible. * gcc.dg/plugin/ggcplug.c: Likewise. * gcc.dg/plugin/one_time_plugin.c: Likewise. * g++.dg/plugin/selfassign.c: Likewise. * g++.dg/plugin/attribute_plugin.c: Likewise. * g++.dg/plugin/dumb_plugin.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148667 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/plugin.c')
-rw-r--r--gcc/plugin.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/plugin.c b/gcc/plugin.c
index 93151f8a8a7..396850a3a97 100644
--- a/gcc/plugin.c
+++ b/gcc/plugin.c
@@ -25,7 +25,7 @@ along with GCC; see the file COPYING3. If not see
/* If plugin support is not enabled, do not try to execute any code
that may reference libdl. The generic code is still compiled in to
- avoid including to many conditional compilation paths in the rest
+ avoid including too many conditional compilation paths in the rest
of the compiler. */
#ifdef ENABLE_PLUGIN
#include <dlfcn.h>
@@ -95,6 +95,10 @@ static struct pass_list_node *prev_added_pass_node;
/* Each plugin should define an initialization function with exactly
this name. */
static const char *str_plugin_init_func_name = "plugin_init";
+
+/* Each plugin should define this symbol to assert that it is
+ distributed under a GPL-compatible license. */
+static const char *str_license = "plugin_is_GPL_compatible";
#endif
/* Helper function for the hash table that compares the base_name of the
@@ -595,6 +599,11 @@ try_init_one_plugin (struct plugin_name_args *plugin)
/* Clear any existing error. */
dlerror ();
+ /* Check the plugin license. */
+ if (dlsym (dl_handle, str_license) == NULL)
+ fatal_error ("plugin %s is not licensed under a GPL-compatible license\n"
+ "%s", plugin->full_name, dlerror ());
+
PTR_UNION_AS_VOID_PTR (plugin_init_union) =
dlsym (dl_handle, str_plugin_init_func_name);
plugin_init = PTR_UNION_AS_CAST_PTR (plugin_init_union);