aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Spengler <spender@grsecurity.net>2017-03-21 11:50:18 +0000
committerRichard Biener <rguenther@suse.de>2017-03-21 11:50:18 +0000
commit6e517cd1102f34c7ea9b846d97d6d7e381db9e66 (patch)
treeb3ca195c919e915f7ddb405fa8152ddfae854333
parentdce221e16ffb829fa95a2159d7f2a84e51f74782 (diff)
2017-03-21 Brad Spengler <spender@grsecurity.net>
PR plugins/80094 * plugin.c (htab_hash_plugin): New function. (add_new_plugin): Use it and adjust. (parse_plugin_arg_opt): Adjust. (init_one_plugin): Likewise. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@246315 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/plugin.c24
2 files changed, 27 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d679a5c014e..225b189d080 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2017-03-21 Brad Spengler <spender@grsecurity.net>
+
+ PR plugins/80094
+ * plugin.c (htab_hash_plugin): New function.
+ (add_new_plugin): Use it and adjust.
+ (parse_plugin_arg_opt): Adjust.
+ (init_one_plugin): Likewise.
+
2017-03-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/80032
diff --git a/gcc/plugin.c b/gcc/plugin.c
index 1996c9af43f..cfd6ef25036 100644
--- a/gcc/plugin.c
+++ b/gcc/plugin.c
@@ -114,6 +114,16 @@ static const char *str_plugin_init_func_name = "plugin_init";
static const char *str_license = "plugin_is_GPL_compatible";
#endif
+/* Helper function for hashing the base_name of the plugin_name_args
+ structure to be inserted into the hash table. */
+
+static hashval_t
+htab_hash_plugin (const PTR p)
+{
+ const struct plugin_name_args *plugin = (const struct plugin_name_args *) p;
+ return htab_hash_string (plugin->base_name);
+ }
+
/* Helper function for the hash table that compares the base_name of the
existing entry (S1) with the given string (S2). */
@@ -183,10 +193,11 @@ add_new_plugin (const char* plugin_name)
/* If this is the first -fplugin= option we encounter, create
'plugin_name_args_tab' hash table. */
if (!plugin_name_args_tab)
- plugin_name_args_tab = htab_create (10, htab_hash_string, htab_str_eq,
+ plugin_name_args_tab = htab_create (10, htab_hash_plugin, htab_str_eq,
NULL);
- slot = htab_find_slot (plugin_name_args_tab, base_name, INSERT);
+ slot = htab_find_slot_with_hash (plugin_name_args_tab, base_name,
+ htab_hash_string (base_name), INSERT);
/* If the same plugin (name) has been specified earlier, either emit an
error or a warning message depending on if they have identical full
@@ -273,7 +284,8 @@ parse_plugin_arg_opt (const char *arg)
/* Check if the named plugin has already been specified earlier in the
command-line. */
if (plugin_name_args_tab
- && ((slot = htab_find_slot (plugin_name_args_tab, name, NO_INSERT))
+ && ((slot = htab_find_slot_with_hash (plugin_name_args_tab, name,
+ htab_hash_string (name), NO_INSERT))
!= NULL))
{
struct plugin_name_args *plugin = (struct plugin_name_args *) *slot;
@@ -329,7 +341,8 @@ parse_plugin_arg_opt (const char *arg)
static void
register_plugin_info (const char* name, struct plugin_info *info)
{
- void **slot = htab_find_slot (plugin_name_args_tab, name, NO_INSERT);
+ void **slot = htab_find_slot_with_hash (plugin_name_args_tab, name,
+ htab_hash_string (name), NO_INSERT);
struct plugin_name_args *plugin;
if (slot == NULL)
@@ -635,7 +648,8 @@ init_one_plugin (void **slot, void * ARG_UNUSED (info))
bool ok = try_init_one_plugin (plugin);
if (!ok)
{
- htab_remove_elt (plugin_name_args_tab, plugin->base_name);
+ htab_remove_elt_with_hash (plugin_name_args_tab, plugin->base_name,
+ htab_hash_string (plugin->base_name));
XDELETE (plugin);
}
return 1;