Full support for --sysroot.
[external/binutils.git] / gold / main.cc
1 // main.cc -- gold main function.
2
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
23 #include "gold.h"
24
25 #include "options.h"
26 #include "parameters.h"
27 #include "dirsearch.h"
28 #include "workqueue.h"
29 #include "object.h"
30 #include "symtab.h"
31 #include "layout.h"
32
33 using namespace gold;
34
35 int
36 main(int argc, char** argv)
37 {
38 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
39   setlocale (LC_MESSAGES, "");
40 #endif
41 #if defined (HAVE_SETLOCALE)
42   setlocale (LC_CTYPE, "");
43 #endif
44   bindtextdomain (PACKAGE, LOCALEDIR);
45   textdomain (PACKAGE);
46
47   program_name = argv[0];
48
49   // Handle the command line options.
50   Command_line command_line;
51   command_line.process(argc - 1, argv + 1);
52   initialize_parameters(&command_line.options());
53
54   // The work queue.
55   Workqueue workqueue(command_line.options());
56
57   // The list of input objects.
58   Input_objects input_objects;
59
60   // The symbol table.
61   Symbol_table symtab;
62
63   // The layout object.
64   Layout layout(command_line.options());
65
66   // Get the search path from the -L options.
67   Dirsearch search_path;
68   search_path.initialize(&workqueue, &command_line.options().search_path());
69
70   // Queue up the first set of tasks.
71   queue_initial_tasks(command_line.options(), search_path,
72                       command_line, &workqueue, &input_objects,
73                       &symtab, &layout);
74
75   // Run the main task processing loop.
76   workqueue.process();
77
78   gold_exit(true);
79 }