Remove Andrew's e-mail address.
[deliverable/binutils-gdb.git] / gold / main.cc
CommitLineData
5a6f7e2d
ILT
1// main.cc -- gold main function.
2
6cb15b7f
ILT
3// Copyright 2006, 2007 Free Software Foundation, Inc.
4// Written by Ian Lance Taylor <iant@google.com>.
5
6// This file is part of gold.
7
8// This program is free software; you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21// MA 02110-1301, USA.
22
5a6f7e2d
ILT
23#include "gold.h"
24
e44fcf3b
ILT
25#ifdef HAVE_MALLINFO
26#include <malloc.h>
27#endif
28#include "libiberty.h"
29
5a6f7e2d 30#include "options.h"
7e1edb90 31#include "parameters.h"
75f2446e 32#include "errors.h"
5a6f7e2d
ILT
33#include "dirsearch.h"
34#include "workqueue.h"
35#include "object.h"
36#include "symtab.h"
37#include "layout.h"
38
39using namespace gold;
40
41int
42main(int argc, char** argv)
43{
44#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
45 setlocale (LC_MESSAGES, "");
46#endif
47#if defined (HAVE_SETLOCALE)
48 setlocale (LC_CTYPE, "");
49#endif
50 bindtextdomain (PACKAGE, LOCALEDIR);
51 textdomain (PACKAGE);
52
53 program_name = argv[0];
54
75f2446e
ILT
55 Errors errors(program_name);
56
3c2fafa5
ILT
57 // Initialize the global parameters, to let random code get to the
58 // errors object.
59 initialize_parameters(&errors);
60
5a6f7e2d
ILT
61 // Handle the command line options.
62 Command_line command_line;
63 command_line.process(argc - 1, argv + 1);
e44fcf3b
ILT
64
65 long start_time = 0;
66 if (command_line.options().print_stats())
67 start_time = get_run_time();
68
3c2fafa5
ILT
69 // Store some options in the globally accessible parameters.
70 set_parameters_from_options(&command_line.options());
5a6f7e2d
ILT
71
72 // The work queue.
73 Workqueue workqueue(command_line.options());
74
75 // The list of input objects.
76 Input_objects input_objects;
77
6d013333
ILT
78 // The symbol table. We're going to guess here how many symbols
79 // we're going to see based on the number of input files. Even when
80 // this is off, it means at worse we don't quite optimize hashtable
81 // resizing as well as we could have (perhap using more memory).
82 Symbol_table symtab(command_line.number_of_input_files() * 1024);
5a6f7e2d
ILT
83
84 // The layout object.
85 Layout layout(command_line.options());
86
87 // Get the search path from the -L options.
88 Dirsearch search_path;
ad2d6943 89 search_path.initialize(&workqueue, &command_line.options().search_path());
5a6f7e2d
ILT
90
91 // Queue up the first set of tasks.
92 queue_initial_tasks(command_line.options(), search_path,
93 command_line, &workqueue, &input_objects,
94 &symtab, &layout);
95
96 // Run the main task processing loop.
17a1d0a9 97 workqueue.process(0);
5a6f7e2d 98
e44fcf3b
ILT
99 if (command_line.options().print_stats())
100 {
101 long run_time = get_run_time() - start_time;
102 fprintf(stderr, _("%s: total run time: %ld.%06ld seconds\n"),
103 program_name, run_time / 1000000, run_time % 1000000);
104#ifdef HAVE_MALLINFO
105 struct mallinfo m = mallinfo();
106 fprintf(stderr, _("%s: total space allocated by malloc: %d bytes\n"),
107 program_name, m.arena);
108#endif
109 File_read::print_stats();
110 fprintf(stderr, _("%s: output file size: %lld bytes\n"),
111 program_name, static_cast<long long>(layout.output_file_size()));
abaa3995 112 symtab.print_stats();
ad8f37d1 113 layout.print_stats();
e44fcf3b
ILT
114 }
115
75f2446e 116 gold_exit(errors.error_count() == 0);
5a6f7e2d 117}
This page took 0.078123 seconds and 4 git commands to generate.