elfcpp/ChangeLog:
[external/binutils.git] / gold / main.cc
index d8ef582..91d5193 100644 (file)
@@ -1,6 +1,6 @@
 // main.cc -- gold main function.
 
-// 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.
@@ -46,6 +46,7 @@
 #include "gc.h"
 #include "icf.h"
 #include "incremental.h"
+#include "timer.h"
 
 using namespace gold;
 
@@ -161,9 +162,9 @@ main(int argc, char** argv)
   Command_line command_line;
   command_line.process(argc - 1, const_cast<const char**>(argv + 1));
 
-  long start_time = 0;
+  Timer timer;
   if (command_line.options().stats())
-    start_time = get_run_time();
+    timer.start();
 
   // Store some options in the globally accessible parameters.
   set_parameters_options(&command_line.options());
@@ -220,7 +221,7 @@ main(int argc, char** argv)
   if (parameters->options().gc_sections())
     symtab.set_gc(&gc);
 
-  if (parameters->options().icf())
+  if (parameters->options().icf_enabled())
     symtab.set_icf(&icf);
 
   // The layout object.
@@ -228,10 +229,10 @@ main(int argc, char** argv)
                &command_line.script_options());
 
   if (layout.incremental_inputs() != NULL)
-    {
-      layout.incremental_inputs()->report_command_line(argc, argv);
-      layout.incremental_inputs()->report_inputs(command_line.inputs());
-    }
+    layout.incremental_inputs()->report_command_line(argc, argv);
+
+  if (parameters->options().section_ordering_file())
+    layout.read_layout_from_file();
 
   // Get the search path from the -L options.
   Dirsearch search_path;
@@ -247,9 +248,15 @@ main(int argc, char** argv)
 
   if (command_line.options().stats())
     {
-      long run_time = get_run_time() - start_time;
-      fprintf(stderr, _("%s: total run time: %ld.%06ld seconds\n"),
-             program_name, run_time / 1000000, run_time % 1000000);
+      Timer::TimeStats elapsed = timer.get_elapsed_time();
+      fprintf(stderr,
+             _("%s: total run time: " \
+               "(user: %ld.%06ld sys: %ld.%06ld wall: %ld.%06ld)\n"),
+              program_name,
+              elapsed.user / 1000, (elapsed.user % 1000) * 1000,
+              elapsed.sys / 1000, (elapsed.sys % 1000) * 1000,
+              elapsed.wall / 1000, (elapsed.wall % 1000) * 1000);
+
 #ifdef HAVE_MALLINFO
       struct mallinfo m = mallinfo();
       fprintf(stderr, _("%s: total space allocated by malloc: %d bytes\n"),
@@ -257,19 +264,25 @@ main(int argc, char** argv)
 #endif
       File_read::print_stats();
       Archive::print_stats();
+      Lib_group::print_stats();
       fprintf(stderr, _("%s: output file size: %lld bytes\n"),
              program_name, static_cast<long long>(layout.output_file_size()));
       symtab.print_stats();
       layout.print_stats();
     }
 
-  if (mapfile != NULL)
-    mapfile->close();
-
   // Issue defined symbol report.
   if (command_line.options().user_set_print_symbol_counts())
     input_objects.print_symbol_counts(&symtab);
 
+  // Output cross reference table.
+  if (command_line.options().cref())
+    input_objects.print_cref(&symtab,
+                            mapfile == NULL ? stdout : mapfile->file());
+
+  if (mapfile != NULL)
+    mapfile->close();
+
   if (parameters->options().fatal_warnings()
       && errors.warning_count() > 0
       && errors.error_count() == 0)