+2016-07-04 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/20321
+ * plugin.c (plugin_opt_plugin): Warn and return if plugin has
+ been loaded already.
+ * testsuite/ld-plugin/lto.exp: Run PR ld/20321 test.
+ * testsuite/ld-plugin/pr20321.c: New file.
+
2016-07-04 Nick Clifton <nickc@redhat.com>
* scripttempl/ft32.sc (__PMSIZE_): If not defined, set to 256K.
plugin_opt_plugin (const char *plugin)
{
plugin_t *newplug;
+ plugin_t *curplug = plugins_list;
newplug = xmalloc (sizeof *newplug);
memset (newplug, 0, sizeof *newplug);
if (!newplug->dlhandle)
einfo (_("%P%F: %s: error loading plugin: %s\n"), plugin, dlerror ());
+ /* Check if plugin has been loaded already. */
+ while (curplug)
+ {
+ if (newplug->dlhandle == curplug->dlhandle)
+ {
+ einfo (_("%P: %s: duplicated plugin\n"), plugin);
+ free (newplug);
+ return;
+ }
+ curplug = curplug->next;
+ }
+
/* Chain on end, so when we run list it is in command-line order. */
*plugins_tail_chain_ptr = newplug;
plugins_tail_chain_ptr = &newplug->next;
[list "Build libpr20267b.a" \
"$plug_opt" "-flto $lto_no_fat" \
{pr20267b.c} {} "libpr20267b.a"] \
+ [list "Build pr20321" \
+ "-Wl,-plugin,$plug_so" "-flto" \
+ {pr20321.c} {} "pr20321" "c" ".*: duplicated plugin"] \
]
if { [at_least_gcc_version 4 7] } {