GNU Binutils with patches for OS216
修订版 | c3e1c28ebfdb20ff4498bcc792228283b903d393 (tree) |
---|---|
时间 | 2016-07-05 00:55:20 |
作者 | H.J. Lu <hjl.tools@gmai...> |
Commiter | H.J. Lu |
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.
@@ -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 | + | |
1 | 9 | 2016-07-04 Nick Clifton <nickc@redhat.com> |
2 | 10 | |
3 | 11 | * scripttempl/ft32.sc (__PMSIZE_): If not defined, set to 256K. |
@@ -237,6 +237,7 @@ void | ||
237 | 237 | plugin_opt_plugin (const char *plugin) |
238 | 238 | { |
239 | 239 | plugin_t *newplug; |
240 | + plugin_t *curplug = plugins_list; | |
240 | 241 | |
241 | 242 | newplug = xmalloc (sizeof *newplug); |
242 | 243 | memset (newplug, 0, sizeof *newplug); |
@@ -245,6 +246,18 @@ plugin_opt_plugin (const char *plugin) | ||
245 | 246 | if (!newplug->dlhandle) |
246 | 247 | einfo (_("%P%F: %s: error loading plugin: %s\n"), plugin, dlerror ()); |
247 | 248 | |
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 | + | |
248 | 261 | /* Chain on end, so when we run list it is in command-line order. */ |
249 | 262 | *plugins_tail_chain_ptr = newplug; |
250 | 263 | plugins_tail_chain_ptr = &newplug->next; |
@@ -198,6 +198,9 @@ set lto_link_tests [list \ | ||
198 | 198 | [list "Build libpr20267b.a" \ |
199 | 199 | "$plug_opt" "-flto $lto_no_fat" \ |
200 | 200 | {pr20267b.c} {} "libpr20267b.a"] \ |
201 | + [list "Build pr20321" \ | |
202 | + "-Wl,-plugin,$plug_so" "-flto" \ | |
203 | + {pr20321.c} {} "pr20321" "c" ".*: duplicated plugin"] \ | |
201 | 204 | ] |
202 | 205 | |
203 | 206 | if { [at_least_gcc_version 4 7] } { |
@@ -0,0 +1,4 @@ | ||
1 | +int main(void) | |
2 | +{ | |
3 | + return 0; | |
4 | +} |