2010-02-01 Doug Kwan <dougkwan@google.com>
[deliverable/binutils-gdb.git] / gold / gold.cc
index ac2f62c5d809fc606007d19dad6c2ec10295a490..825198120ce59518468883a66b82f973706af19b 100644 (file)
@@ -1,6 +1,6 @@
 // gold.cc -- main linker functions
 
-// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -41,6 +41,7 @@
 #include "reloc.h"
 #include "defstd.h"
 #include "plugin.h"
+#include "gc.h"
 #include "icf.h"
 #include "incremental.h"
 
@@ -220,13 +221,15 @@ queue_initial_tasks(const General_options& options,
     }
 
   if (parameters->options().relocatable()
-      && (parameters->options().gc_sections() || parameters->options().icf()))
+      && (parameters->options().gc_sections()
+         || parameters->options().icf_enabled()))
     gold_error(_("cannot mix -r with --gc-sections or --icf"));
 
-  if (parameters->options().gc_sections() || parameters->options().icf())
+  if (parameters->options().gc_sections()
+      || parameters->options().icf_enabled())
     {
       workqueue->queue(new Task_function(new Gc_runner(options,
-                                                       input_objects,
+                                                      input_objects,
                                                        symtab,
                                                        layout,
                                                        mapfile),
@@ -270,8 +273,8 @@ queue_middle_gc_tasks(const General_options& options,
     {
       // We can read and process the relocations in any order.  
       blocker->add_blocker();
-      workqueue->queue(new Read_relocs(options, symtab, layout, *p,
-                                      symtab_lock, blocker));
+      workqueue->queue(new Read_relocs(symtab, layout, *p, symtab_lock,
+                                      blocker));
     }
 
   Task_token* this_blocker = new Task_token(true);
@@ -311,7 +314,7 @@ queue_middle_tasks(const General_options& options,
         start_sym = symtab->lookup(parameters->options().entry());
       else
         start_sym = symtab->lookup("_start");
-      if (start_sym !=NULL)
+      if (start_sym != NULL)
         {
           bool is_ordinary;
           unsigned int shndx = start_sym->shndx(&is_ordinary);
@@ -331,7 +334,7 @@ queue_middle_tasks(const General_options& options,
   // If identical code folding (--icf) is chosen it makes sense to do it 
   // only after garbage collection (--gc-sections) as we do not want to 
   // be folding sections that will be garbage.
-  if (parameters->options().icf())
+  if (parameters->options().icf_enabled())
     {
       symtab->icf()->find_identical_sections(input_objects, symtab);
     }
@@ -341,7 +344,8 @@ queue_middle_tasks(const General_options& options,
   // --gc-sections or --icf is turned on, Object::layout is 
   // called twice.  It is called the first time when the 
   // symbols are added.
-  if (parameters->options().gc_sections() || parameters->options().icf())
+  if (parameters->options().gc_sections()
+      || parameters->options().icf_enabled())
     {
       for (Input_objects::Relobj_iterator p = input_objects->relobj_begin();
            p != input_objects->relobj_end();
@@ -359,7 +363,8 @@ queue_middle_tasks(const General_options& options,
       plugins->layout_deferred_objects();
     }     
 
-  if (parameters->options().gc_sections() || parameters->options().icf())
+  if (parameters->options().gc_sections()
+      || parameters->options().icf_enabled())
     {
       for (Input_objects::Relobj_iterator p = input_objects->relobj_begin();
            p != input_objects->relobj_end();
@@ -391,8 +396,9 @@ queue_middle_tasks(const General_options& options,
   workqueue->set_thread_count(thread_count);
 
   // Now we have seen all the input files.
-  const bool doing_static_link = (!input_objects->any_dynamic()
-                                 && !parameters->options().shared());
+  const bool doing_static_link =
+    (!input_objects->any_dynamic()
+     && !parameters->options().output_is_position_independent());
   set_parameters_doing_static_link(doing_static_link);
   if (!doing_static_link && options.is_static())
     {
@@ -437,6 +443,13 @@ queue_middle_tasks(const General_options& options,
   // TODO: if this is too slow, do this as a task, rather than inline.
   symtab->detect_odr_violations(task, options.output_file_name());
 
+  // Do the --no-undefined-version check.
+  if (!parameters->options().undefined_version())
+    {
+      Script_options* so = layout->script_options();
+      so->version_script_info()->check_unmatched_names(symtab);
+    }
+
   // Create any automatic note sections.
   layout->create_notes();
 
@@ -471,15 +484,17 @@ queue_middle_tasks(const General_options& options,
 
   // If doing garbage collection, the relocations have already been read.
   // Otherwise, read and scan the relocations.
-  if (parameters->options().gc_sections() || parameters->options().icf())
+  if (parameters->options().gc_sections()
+      || parameters->options().icf_enabled())
     {
       for (Input_objects::Relobj_iterator p = input_objects->relobj_begin();
            p != input_objects->relobj_end();
            ++p)
         {
           blocker->add_blocker();
-          workqueue->queue(new Scan_relocs(options, symtab, layout, *p, 
-                           (*p)->get_relocs_data(),symtab_lock, blocker));
+          workqueue->queue(new Scan_relocs(symtab, layout, *p, 
+                                          (*p)->get_relocs_data(),
+                                          symtab_lock, blocker));
         }
     }
   else
@@ -505,8 +520,8 @@ queue_middle_tasks(const General_options& options,
           // relocations.  That task will in turn queue a task to wait
           // until it can write to the symbol table.
           blocker->add_blocker();
-          workqueue->queue(new Read_relocs(options, symtab, layout, *p,
-                   symtab_lock, blocker));
+          workqueue->queue(new Read_relocs(symtab, layout, *p, symtab_lock,
+                                          blocker));
         }
     }
 
@@ -593,7 +608,7 @@ queue_final_tasks(const General_options& options,
       if (input_sections_blocker != NULL)
        input_sections_blocker->add_blocker();
       final_blocker->add_blocker();
-      workqueue->queue(new Relocate_task(options, symtab, layout, *p, of,
+      workqueue->queue(new Relocate_task(symtab, layout, *p, of,
                                         input_sections_blocker,
                                         output_sections_blocker,
                                         final_blocker));
This page took 0.025966 seconds and 4 git commands to generate.