[PATCH 4/5] Don't check the plugin target twice
H.J. Lu
hjl.tools@gmail.com
Wed Oct 21 11:35:10 GMT 2020
If the plugin target is explicitly specified when a BFD file is opened,
don't check it twice.
* format.c: Include "plugin-api.h" and "plugin.h" if
BFD_SUPPORTS_PLUGINS is defined.
(bfd_check_format_matches): Don't check the plugin target twice
if the plugin target is explicitly specified.
---
bfd/format.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/bfd/format.c b/bfd/format.c
index 26171992fca..ec044d10574 100644
--- a/bfd/format.c
+++ b/bfd/format.c
@@ -48,6 +48,8 @@ SUBSECTION
#include "libbfd.h"
#if BFD_SUPPORTS_PLUGINS
#include "libiberty.h"
+#include "plugin-api.h"
+#include "plugin.h"
#endif
/* IMPORT from targets.c. */
@@ -299,9 +301,6 @@ bfd_boolean
bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
{
extern const bfd_target binary_vec;
-#if BFD_SUPPORTS_PLUGINS
- extern const bfd_target plugin_vec;
-#endif
const bfd_target * const *target;
const bfd_target **matching_vector = NULL;
const bfd_target *save_targ, *right_targ, *ar_right_targ, *match_targ;
@@ -393,11 +392,18 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
check the default target twice. */
if (*target == &binary_vec
#if BFD_SUPPORTS_PLUGINS
- || (match_count != 0 && *target == &plugin_vec)
+ || (match_count != 0 && bfd_plugin_target_p (*target))
#endif
|| (!abfd->target_defaulted && *target == save_targ))
continue;
+#if BFD_SUPPORTS_PLUGINS
+ /* If the plugin target is explicitly specified when a BFD file
+ is opened, don't check it twice. */
+ if (bfd_plugin_specified_p () && bfd_plugin_target_p (*target))
+ continue;
+#endif
+
/* If we already tried a match, the bfd is modified and may
have sections attached, which will confuse the next
_bfd_check_format call. */
@@ -426,7 +432,7 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
lowest priority; objects both handled by a plugin and
with an underlying object format will be claimed
separately by the plugin. */
- if (*target == &plugin_vec)
+ if (bfd_plugin_target_p (*target))
match_priority = (*target)->match_priority;
#endif
--
2.26.2
More information about the Binutils
mailing list