plugin: Search bfd-plugins directories only once

try_load_plugin is updated to take either plugin name or plugin entry.
load_plugin is updated to search bfd-plugins directories first to build
a list of plugins and call try_load_plugin with each plugin on the list.
When --plugin is used, the plugin list only has one entry.

	* plugin.c (try_load_plugin): Make plugin_list_iter an argument
	and use it if it isn't NULL.  Remove has_plugin_p argument.  Add
	a build_list_p argument.  Don't search plugin_list.  Short circuit
	when building the plugin list.
	(has_plugin): Renamed to has_plugin_list.
	(bfd_plugin_set_plugin): Don't set has_plugin.
	(bfd_plugin_specified_p): Check plugin_list instead.
	(build_plugin_list): New function.
	(load_plugin): Call build_plugin_list and use plugin_list.

(cherry picked from commit 99845b3b77ed1248b6fb94707f88868bde358ccc)
1 file changed