* aix5ppc-core.c: Define macros for the default architecture and
[deliverable/binutils-gdb.git] / gold / gold.cc
index f067557cb249b2254ecbd34db2a6c33f5ef09dd2..d150db76d997b6aae306e744f876f91e37f884dd 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "options.h"
 #include "debug.h"
-#include "target-select.h"
 #include "workqueue.h"
 #include "dirsearch.h"
 #include "readsyms.h"
@@ -51,7 +50,7 @@ void
 gold_exit(bool status)
 {
   if (!status && parameters != NULL && parameters->options_valid())
-    unlink_if_ordinary(parameters->output_file_name());
+    unlink_if_ordinary(parameters->options().output_file_name());
   exit(status ? EXIT_SUCCESS : EXIT_FAILURE);
 }
 
@@ -167,15 +166,7 @@ queue_middle_tasks(const General_options& options,
   // pass an empty archive to the linker and get an empty object file
   // out.  In order to do this we need to use a default target.
   if (input_objects->number_of_input_objects() == 0)
-    {
-      // The GOLD_xx macros are defined by the configure script.
-      Target* target = select_target(elfcpp::GOLD_DEFAULT_MACHINE,
-                                    GOLD_DEFAULT_SIZE,
-                                    GOLD_DEFAULT_BIG_ENDIAN,
-                                    0, 0);
-      gold_assert(target != NULL);
-      set_parameters_target(target);
-    }
+    set_parameters_target(&parameters->default_target());
 
   int thread_count = options.thread_count_middle();
   if (thread_count == 0)
@@ -184,7 +175,7 @@ queue_middle_tasks(const General_options& options,
 
   // Now we have seen all the input files.
   const bool doing_static_link = (!input_objects->any_dynamic()
-                                 && !parameters->output_is_shared());
+                                 && !parameters->options().shared());
   set_parameters_doing_static_link(doing_static_link);
   if (!doing_static_link && options.is_static())
     {
@@ -192,9 +183,13 @@ queue_middle_tasks(const General_options& options,
       gold_error(_("cannot mix -static with dynamic object %s"),
                 (*input_objects->dynobj_begin())->name().c_str());
     }
-  if (!doing_static_link && parameters->output_is_object())
+  if (!doing_static_link && parameters->options().relocatable())
     gold_error(_("cannot mix -r with dynamic object %s"),
               (*input_objects->dynobj_begin())->name().c_str());
+  if (!doing_static_link
+      && options.oformat_enum() != General_options::OBJECT_FORMAT_ELF)
+    gold_fatal(_("cannot use non-ELF output format with dynamic object %s"),
+              (*input_objects->dynobj_begin())->name().c_str());
 
   if (is_debugging_enabled(DEBUG_SCRIPT))
     layout->script_options()->print(stderr);
@@ -207,6 +202,9 @@ 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());
 
+  // Create any output sections required by any linker script.
+  layout->create_script_sections();
+
   // Define some sections and symbols needed for a dynamic link.  This
   // handles some cases we want to see before we read the relocs.
   layout->create_initial_dynamic_sections(symtab);
@@ -214,7 +212,10 @@ queue_middle_tasks(const General_options& options,
   // Define symbols from any linker scripts.
   layout->define_script_symbols(symtab);
 
-  if (!parameters->output_is_object())
+  // Attach sections to segments.
+  layout->attach_sections_to_segments();
+
+  if (!parameters->options().relocatable())
     {
       // Predefine standard symbols.
       define_standard_symbols(symtab, layout);
@@ -256,20 +257,21 @@ queue_middle_tasks(const General_options& options,
 
   // Allocate common symbols.  This requires write access to the
   // symbol table, but is independent of the relocation processing.
-  // FIXME: We should have an option to do this even for a relocatable
-  // link.
-  if (!parameters->output_is_object())
+  if (parameters->options().define_common())
     {
       blocker->add_blocker();
-      workqueue->queue(new Allocate_commons_task(options, symtab, layout,
-                                                symtab_lock, blocker));
+      workqueue->queue(new Allocate_commons_task(symtab, layout, symtab_lock,
+                                                blocker));
     }
 
   // When all those tasks are complete, we can start laying out the
   // output file.
+  // TODO(csilvers): figure out a more principled way to get the target
+  Target* target = const_cast<Target*>(&parameters->target());
   workqueue->queue(new Task_function(new Layout_task_runner(options,
                                                            input_objects,
                                                            symtab,
+                                                            target,
                                                            layout),
                                     blocker,
                                     "Task_function Layout_task_runner"));
@@ -365,7 +367,8 @@ queue_final_tasks(const General_options& options,
 
   // Queue a task to close the output file.  This will be blocked by
   // FINAL_BLOCKER.
-  workqueue->queue(new Task_function(new Close_task_runner(of),
+  workqueue->queue(new Task_function(new Close_task_runner(&options, layout,
+                                                          of),
                                     final_blocker,
                                     "Task_function Close_task_runner"));
 }
This page took 0.049215 seconds and 4 git commands to generate.