* gold.cc (gold_exit): Call plugin cleanup handlers on exit.
authorCary Coutant <ccoutant@google.com>
Wed, 24 Dec 2008 06:17:18 +0000 (06:17 +0000)
committerCary Coutant <ccoutant@google.com>
Wed, 24 Dec 2008 06:17:18 +0000 (06:17 +0000)
* plugin.cc (Plugin_manager::finish): Rename as
layout_deferred_objects.  Move cleanup to separate function.
(Plugin_manager::cleanup): New function.
(Plugin_finish::run): Call layout_deferred_objects and cleanup
separately.
* plugin.h (Plugin_manager::finish): Rename as
layout_deferred_objects.
(Plugin_manager::cleanup): New function.
(Plugin_manager::cleanup_done): New field.

gold/ChangeLog
gold/gold.cc
gold/plugin.cc
gold/plugin.h

index 9ce8cfd5a81a532b312a2549918aba7a33df5749..626532a9ab14e265fe940ad14467067a991366ec 100644 (file)
@@ -1,3 +1,16 @@
+2008-12-23  Cary Coutant  <ccoutant@google.com>
+
+       * gold.cc (gold_exit): Call plugin cleanup handlers on exit.
+       * plugin.cc (Plugin_manager::finish): Rename as
+       layout_deferred_objects.  Move cleanup to separate function.
+       (Plugin_manager::cleanup): New function.
+       (Plugin_finish::run): Call layout_deferred_objects and cleanup
+       separately.
+       * plugin.h (Plugin_manager::finish): Rename as
+       layout_deferred_objects.
+       (Plugin_manager::cleanup): New function.
+       (Plugin_manager::cleanup_done): New field.
+
 2008-12-23  Cary Coutant  <ccoutant@google.com>
 
        * plugin.cc (is_visible_from_outside): New function.
index ac321be33fa0299983b1abc0ca9fc806b7b5c8c6..8d86a1bbb474bea9c9d3bb0cdf6c1772b219bbea 100644 (file)
@@ -50,6 +50,10 @@ const char* program_name;
 void
 gold_exit(bool status)
 {
+  if (parameters != NULL
+      && parameters->options_valid()
+      && parameters->options().has_plugins())
+    parameters->options().plugins()->cleanup();
   if (!status && parameters != NULL && parameters->options_valid())
     unlink_if_ordinary(parameters->options().output_file_name());
   exit(status ? EXIT_SUCCESS : EXIT_FAILURE);
index c624ef1a9af62035f20f8b56b5bd0198f0742291..e2a9e60010caf6f9226916cfbba3f68344e359e6 100644 (file)
@@ -306,10 +306,10 @@ Plugin_manager::all_symbols_read(Workqueue* workqueue,
   *last_blocker = this->this_blocker_;
 }
 
-// Layout deferred sections and call the cleanup handlers.
+// Layout deferred objects.
 
 void
-Plugin_manager::finish()
+Plugin_manager::layout_deferred_objects()
 {
   Deferred_layout_list::iterator obj;
 
@@ -317,11 +317,20 @@ Plugin_manager::finish()
        obj != this->deferred_layout_objects_.end();
        ++obj)
     (*obj)->layout_deferred_sections(this->layout_);
+}
+
+// Call the cleanup handlers.
 
+void
+Plugin_manager::cleanup()
+{
+  if (this->cleanup_done_)
+    return;
   for (this->current_ = this->plugins_.begin();
        this->current_ != this->plugins_.end();
        ++this->current_)
     (*this->current_)->cleanup();
+  this->cleanup_done_ = true;
 }
 
 // Make a new Pluginobj object.  This is called when the plugin calls
@@ -766,7 +775,12 @@ class Plugin_finish : public Task
 
   void
   run(Workqueue*)
-  { parameters->options().plugins()->finish(); }
+  {
+    Plugin_manager* plugins = parameters->options().plugins();
+    gold_assert(plugins != NULL);
+    plugins->layout_deferred_objects();
+    plugins->cleanup();
+  }
 
   std::string
   get_name() const
index 20d416aac7ea708c6791fbcc336e0a451954020a..2ea0370878c3a3797adac6938460e33c00b47e5d 100644 (file)
@@ -121,9 +121,9 @@ class Plugin_manager
  public:
   Plugin_manager(const General_options& options)
     : plugins_(), objects_(), deferred_layout_objects_(), input_file_(NULL),
-      plugin_input_file_(), in_replacement_phase_(false), options_(options),
-      workqueue_(NULL), input_objects_(NULL), symtab_(NULL), layout_(NULL),
-      dirpath_(NULL), mapfile_(NULL), this_blocker_(NULL)
+      plugin_input_file_(), in_replacement_phase_(false), cleanup_done_(false),
+      options_(options), workqueue_(NULL), input_objects_(NULL), symtab_(NULL),
+      layout_(NULL), dirpath_(NULL), mapfile_(NULL), this_blocker_(NULL)
   { this->current_ = plugins_.end(); }
 
   ~Plugin_manager();
@@ -155,9 +155,13 @@ class Plugin_manager
                    Symbol_table* symtab, Layout* layout, Dirsearch* dirpath,
                    Mapfile* mapfile, Task_token** last_blocker);
 
-  // Run deferred layout and call the cleanup handlers.
+  // Run deferred layout.
   void
-  finish();
+  layout_deferred_objects();
+
+  // Call the cleanup handlers.
+  void
+  cleanup();
 
   // Register a claim-file handler.
   void
@@ -248,6 +252,9 @@ class Plugin_manager
   // placeholder symbols from the Pluginobj objects.
   bool in_replacement_phase_;
 
+  // TRUE if the cleanup handlers have been called.
+  bool cleanup_done_;
+
   const General_options& options_;
   Workqueue* workqueue_;
   Input_objects* input_objects_;
This page took 0.032439 seconds and 4 git commands to generate.