* plugin.h (plugin_active_plugins_p): New prototype.
authorDave Korn <dave.korn@artimi.com>
Fri, 5 Nov 2010 07:20:07 +0000 (07:20 +0000)
committerDave Korn <dave.korn@artimi.com>
Fri, 5 Nov 2010 07:20:07 +0000 (07:20 +0000)
(is_ir_dummy_bfd): Delete prototype.
* plugin.c: Fix formatting issues.
(is_ir_dummy_bfd): Make static.
(plugin_active_plugins_p): New function.
* ldfile.c (ldfile_try_open_bfd): Use it to save work if no plugins
are loaded.  Always close file descriptor after claim handler returns.
* ldmain.c (add_archive_element): Likewise.

ld/ChangeLog
ld/ldfile.c
ld/ldmain.c
ld/plugin.c
ld/plugin.h

index e3620b93ef650725fa4f2bfd78fa359597e91980..873da69c490623d9c5721f58dd66b97948d1117c 100644 (file)
@@ -1,3 +1,14 @@
+2010-11-05  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+       * plugin.h (plugin_active_plugins_p): New prototype.
+       (is_ir_dummy_bfd): Delete prototype.
+       * plugin.c: Fix formatting issues.
+       (is_ir_dummy_bfd): Make static.
+       (plugin_active_plugins_p): New function.
+       * ldfile.c (ldfile_try_open_bfd): Use it to save work if no plugins
+       are loaded.  Always close file descriptor after claim handler returns.
+       * ldmain.c (add_archive_element): Likewise.
+
 2010-11-05  Alan Modra  <amodra@gmail.com>
 
        * ldlang.c (lang_add_section): Distinguish ELF treatment of NOLOAD.
index 701b3803cad1b2fd8eade09993f18d14e0cc3e20..6364469071fff9597eea4de5d4b8168f88cd5a8d 100644 (file)
@@ -312,7 +312,8 @@ success:
      bfd_object that it sets the bfd's arch and mach, which
      will be needed when and if we want to bfd_create a new
      one using this one as a template.  */
-  if (bfd_check_format (entry->the_bfd, bfd_object))
+  if (bfd_check_format (entry->the_bfd, bfd_object)
+       && plugin_active_plugins_p ())
     {
       int fd = open (attempt, O_RDONLY | O_BINARY);
       if (fd >= 0)
@@ -330,6 +331,8 @@ success:
          if (plugin_call_claim_file (&file, &claimed))
            einfo (_("%P%F: %s: plugin reported error claiming file\n"),
              plugin_error_plugin ());
+         /* fd belongs to us, not the plugin; but we don't need it.  */
+         close (fd);
          if (claimed)
            {
              /* Discard the real file's BFD and substitute the dummy one.  */
@@ -340,10 +343,9 @@ success:
            }
          else
            {
-             /* If plugin didn't claim the file, we don't need the fd or the
-                dummy bfd.  Can't avoid speculatively creating it, alas.  */
+             /* If plugin didn't claim the file, we don't need the dummy
+                bfd.  Can't avoid speculatively creating it, alas.  */
              bfd_close_all_done (file.handle);
-             close (fd);
              entry->claimed = FALSE;
            }
        }
index 04b56335e87cff50f130309b8053fde151f0b650..e9b804a9e6fff35794633b5d9367e810c194b149 100644 (file)
@@ -809,7 +809,7 @@ add_archive_element (struct bfd_link_info *info,
      BFD, but we still want to output the original BFD filename.  */
   orig_input = *input;
 #ifdef ENABLE_PLUGINS
-  if (bfd_my_archive (abfd) != NULL)
+  if (bfd_my_archive (abfd) != NULL && plugin_active_plugins_p ())
     {
       /* We must offer this archive member to the plugins to claim.  */
       int fd = open (bfd_my_archive (abfd)->filename, O_RDONLY | O_BINARY);
@@ -831,6 +831,8 @@ add_archive_element (struct bfd_link_info *info,
          if (plugin_call_claim_file (&file, &claimed))
            einfo (_("%P%F: %s: plugin reported error claiming file\n"),
              plugin_error_plugin ());
+         /* fd belongs to us, not the plugin; but we don't need it.  */
+         close (fd);
          if (claimed)
            {
              /* Substitute the dummy BFD.  */
@@ -843,7 +845,6 @@ add_archive_element (struct bfd_link_info *info,
            {
              /* Abandon the dummy BFD.  */
              bfd_close_all_done (file.handle);
-             close (fd);
              input->claimed = FALSE;
            }
        }
index 1e280e4cd21c9aac2a16a4cc5dd070bd60cae3f7..ea647886fcc6c87b2bf2c13a556b50c25cb3d8ba 100644 (file)
@@ -172,13 +172,15 @@ plugin_error_p (void)
 }
 
 /* Return name of plugin which caused an error if any.  */
-const char *plugin_error_plugin (void)
+const char *
+plugin_error_plugin (void)
 {
   return error_plugin ? error_plugin : _("<no plugin>");
 }
 
 /* Handle -plugin arg: find and load plugin, or return error.  */
-int plugin_opt_plugin (const char *plugin)
+int
+plugin_opt_plugin (const char *plugin)
 {
   plugin_t *newplug;
 
@@ -201,7 +203,8 @@ int plugin_opt_plugin (const char *plugin)
 
 /* Accumulate option arguments for last-loaded plugin, or return
    error if none.  */
-int plugin_opt_plugin_arg (const char *arg)
+int
+plugin_opt_plugin_arg (const char *arg)
 {
   plugin_arg_t *newarg;
 
@@ -241,8 +244,8 @@ plugin_get_ir_dummy_bfd (const char *name, bfd *srctemplate)
   return abfd;
 }
 
-/* Check if the BFD is an IR dummy.  */
-bfd_boolean
+/* Check if the BFD passed in is an IR dummy object file.  */
+static bfd_boolean
 is_ir_dummy_bfd (const bfd *abfd)
 {
   size_t namlen;
@@ -615,8 +618,17 @@ set_tv_plugin_args (plugin_t *plugin, struct ld_plugin_tv *tv)
   tv->tv_u.tv_val = 0;
 }
 
+/* Return true if any plugins are active this run.  Only valid
+   after options have been processed.  */
+bfd_boolean
+plugin_active_plugins_p (void)
+{
+  return plugins_list != NULL;
+}
+
 /* Load up and initialise all plugins after argument parsing.  */
-int plugin_load_plugins (void)
+int
+plugin_load_plugins (void)
 {
   struct ld_plugin_tv *my_tv;
   unsigned int max_args = 0;
index 5bd083f0607c5bfe543587916a4edc967c67a608..b79e739223e487b0d61b7b3b6dd80259c1230491 100644 (file)
@@ -33,6 +33,10 @@ extern int plugin_opt_plugin (const char *plugin);
    error if none.  */
 extern int plugin_opt_plugin_arg (const char *arg);
 
+/* Return true if any plugins are active this run.  Only valid
+   after options have been processed.  */
+extern bfd_boolean plugin_active_plugins_p (void);
+
 /* Load up and initialise all plugins after argument parsing.  */
 extern int plugin_load_plugins (void);
 
@@ -56,9 +60,6 @@ extern int plugin_call_cleanup (void);
    add_symbols hook has been called so that it can be read when linking.  */
 extern bfd *plugin_get_ir_dummy_bfd (const char *name, bfd *template);
 
-/* Check if the BFD passed in is an IR dummy object file.  */
-extern bfd_boolean is_ir_dummy_bfd (const bfd *abfd);
-
 /* Notice-symbol bfd linker callback hook.  */
 extern bfd_boolean plugin_notice (struct bfd_link_info *info,
                const char *name, bfd *abfd, asection *section,
This page took 0.0293 seconds and 4 git commands to generate.