PR gas/7025
[deliverable/binutils-gdb.git] / gold / gold.cc
index 27b93bb760503a7975c46297686e07df8b32e7c5..ac321be33fa0299983b1abc0ca9fc806b7b5c8c6 100644 (file)
@@ -40,6 +40,7 @@
 #include "layout.h"
 #include "reloc.h"
 #include "defstd.h"
+#include "plugin.h"
 
 namespace gold
 {
@@ -60,9 +61,18 @@ gold_nomem()
   // We are out of memory, so try hard to print a reasonable message.
   // Note that we don't try to translate this message, since the
   // translation process itself will require memory.
-  write(2, program_name, strlen(program_name));
-  const char* const s = ": out of memory\n";
-  write(2, s, strlen(s));
+
+  // LEN only exists to avoid a pointless warning when write is
+  // declared with warn_use_result, as when compiling with
+  // -D_USE_FORTIFY on GNU/Linux.  Casting to void does not appear to
+  // work, at least not with gcc 4.3.0.
+
+  ssize_t len = write(2, program_name, strlen(program_name));
+  if (len >= 0)
+    {
+      const char* const s = ": out of memory\n";
+      len = write(2, s, strlen(s));
+    }
   gold_exit(false);
 }
 
@@ -85,9 +95,9 @@ class Middle_runner : public Task_function_runner
   Middle_runner(const General_options& options,
                const Input_objects* input_objects,
                Symbol_table* symtab,
-               Layout* layout)
+               Layout* layout, Mapfile* mapfile)
     : options_(options), input_objects_(input_objects), symtab_(symtab),
-      layout_(layout)
+      layout_(layout), mapfile_(mapfile)
   { }
 
   void
@@ -98,13 +108,14 @@ class Middle_runner : public Task_function_runner
   const Input_objects* input_objects_;
   Symbol_table* symtab_;
   Layout* layout_;
+  Mapfile* mapfile_;
 };
 
 void
 Middle_runner::run(Workqueue* workqueue, const Task* task)
 {
   queue_middle_tasks(this->options_, task, this->input_objects_, this->symtab_,
-                    this->layout_, workqueue);
+                    this->layout_, workqueue, this->mapfile_);
 }
 
 // Queue up the initial set of tasks for this link job.
@@ -114,7 +125,7 @@ queue_initial_tasks(const General_options& options,
                    Dirsearch& search_path,
                    const Command_line& cmdline,
                    Workqueue* workqueue, Input_objects* input_objects,
-                   Symbol_table* symtab, Layout* layout)
+                   Symbol_table* symtab, Layout* layout, Mapfile* mapfile)
 {
   if (cmdline.begin() == cmdline.end())
     gold_fatal(_("no input files"));
@@ -136,15 +147,26 @@ queue_initial_tasks(const General_options& options,
       Task_token* next_blocker = new Task_token(true);
       next_blocker->add_blocker();
       workqueue->queue(new Read_symbols(options, input_objects, symtab, layout,
-                                       &search_path, &*p, NULL, this_blocker,
-                                       next_blocker));
+                                       &search_path, mapfile, &*p, NULL,
+                                       this_blocker, next_blocker));
+      this_blocker = next_blocker;
+    }
+
+  if (options.has_plugins())
+    {
+      Task_token* next_blocker = new Task_token(true);
+      next_blocker->add_blocker();
+      workqueue->queue(new Plugin_hook(options, input_objects, symtab, layout,
+                                      &search_path, mapfile, this_blocker,
+                                      next_blocker));
       this_blocker = next_blocker;
     }
 
   workqueue->queue(new Task_function(new Middle_runner(options,
                                                       input_objects,
                                                       symtab,
-                                                      layout),
+                                                      layout,
+                                                      mapfile),
                                     this_blocker,
                                     "Task_function Middle_runner"));
 }
@@ -159,7 +181,8 @@ queue_middle_tasks(const General_options& options,
                   const Input_objects* input_objects,
                   Symbol_table* symtab,
                   Layout* layout,
-                  Workqueue* workqueue)
+                  Workqueue* workqueue,
+                  Mapfile* mapfile)
 {
   // We have to support the case of not seeing any input objects, and
   // generate an empty file.  Existing builds depend on being able to
@@ -180,6 +203,7 @@ queue_middle_tasks(const General_options& options,
   if (!doing_static_link && options.is_static())
     {
       // We print out just the first .so we see; there may be others.
+      gold_assert(input_objects->dynobj_begin() != input_objects->dynobj_end());
       gold_error(_("cannot mix -static with dynamic object %s"),
                 (*input_objects->dynobj_begin())->name().c_str());
     }
@@ -212,6 +236,9 @@ queue_middle_tasks(const General_options& options,
   // Define symbols from any linker scripts.
   layout->define_script_symbols(symtab);
 
+  // Add any symbols named with -u options to the symbol table.
+  symtab->add_undefined_symbols_from_command_line();
+
   // Attach sections to segments.
   layout->attach_sections_to_segments();
 
@@ -260,7 +287,7 @@ queue_middle_tasks(const General_options& options,
   if (parameters->options().define_common())
     {
       blocker->add_blocker();
-      workqueue->queue(new Allocate_commons_task(options, symtab, layout,
+      workqueue->queue(new Allocate_commons_task(symtab, layout, mapfile,
                                                 symtab_lock, blocker));
     }
 
@@ -272,7 +299,8 @@ queue_middle_tasks(const General_options& options,
                                                            input_objects,
                                                            symtab,
                                                             target,
-                                                           layout),
+                                                           layout,
+                                                           mapfile),
                                     blocker,
                                     "Task_function Layout_task_runner"));
 }
@@ -310,7 +338,8 @@ queue_final_tasks(const General_options& options,
 
   // Queue a task to write out the symbol table.
   final_blocker->add_blocker();
-  workqueue->queue(new Write_symbols_task(symtab,
+  workqueue->queue(new Write_symbols_task(layout,
+                                         symtab,
                                          input_objects,
                                          layout->sympool(),
                                          layout->dynpool(),
This page took 0.024799 seconds and 4 git commands to generate.