• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修订版c3e1c28ebfdb20ff4498bcc792228283b903d393 (tree)
时间2016-07-05 00:55:20
作者H.J. Lu <hjl.tools@gmai...>
CommiterH.J. Lu

Log Message

Warn and return for duplicated plugin

If a plugin has been loaded already, we should warn and return, instead
of adding it on the plugin list.

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.

更改概述

差异

--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,11 @@
1+2016-07-04 H.J. Lu <hongjiu.lu@intel.com>
2+
3+ PR ld/20321
4+ * plugin.c (plugin_opt_plugin): Warn and return if plugin has
5+ been loaded already.
6+ * testsuite/ld-plugin/lto.exp: Run PR ld/20321 test.
7+ * testsuite/ld-plugin/pr20321.c: New file.
8+
19 2016-07-04 Nick Clifton <nickc@redhat.com>
210
311 * scripttempl/ft32.sc (__PMSIZE_): If not defined, set to 256K.
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -237,6 +237,7 @@ void
237237 plugin_opt_plugin (const char *plugin)
238238 {
239239 plugin_t *newplug;
240+ plugin_t *curplug = plugins_list;
240241
241242 newplug = xmalloc (sizeof *newplug);
242243 memset (newplug, 0, sizeof *newplug);
@@ -245,6 +246,18 @@ plugin_opt_plugin (const char *plugin)
245246 if (!newplug->dlhandle)
246247 einfo (_("%P%F: %s: error loading plugin: %s\n"), plugin, dlerror ());
247248
249+ /* Check if plugin has been loaded already. */
250+ while (curplug)
251+ {
252+ if (newplug->dlhandle == curplug->dlhandle)
253+ {
254+ einfo (_("%P: %s: duplicated plugin\n"), plugin);
255+ free (newplug);
256+ return;
257+ }
258+ curplug = curplug->next;
259+ }
260+
248261 /* Chain on end, so when we run list it is in command-line order. */
249262 *plugins_tail_chain_ptr = newplug;
250263 plugins_tail_chain_ptr = &newplug->next;
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -198,6 +198,9 @@ set lto_link_tests [list \
198198 [list "Build libpr20267b.a" \
199199 "$plug_opt" "-flto $lto_no_fat" \
200200 {pr20267b.c} {} "libpr20267b.a"] \
201+ [list "Build pr20321" \
202+ "-Wl,-plugin,$plug_so" "-flto" \
203+ {pr20321.c} {} "pr20321" "c" ".*: duplicated plugin"] \
201204 ]
202205
203206 if { [at_least_gcc_version 4 7] } {
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr20321.c
@@ -0,0 +1,4 @@
1+int main(void)
2+{
3+ return 0;
4+}