1 // ld.c -- linker main function
11 #include "workqueue.h"
12 #include "dirsearch.h"
19 const char* program_name
;
22 gold_exit(bool status
)
24 exit(status
? EXIT_SUCCESS
: EXIT_FAILURE
);
28 gold_fatal(const char* msg
, bool perrno
)
30 fprintf(stderr
, "%s: ", program_name
);
34 fprintf(stderr
, "%s\n", msg
);
41 // We are out of memory, so try hard to print a reasonable message.
42 // Note that we don't try to translate this message, since the
43 // translation process itself will require memory.
44 write(2, program_name
, strlen(program_name
));
45 const char* const s
= ": out of memory\n";
46 write(2, s
, strlen(s
));
56 } // End namespace gold.
63 // Queue up the initial set of tasks for this link job.
66 queue_initial_tasks(const General_options
& options
,
67 const Dirsearch
& search_path
,
68 const Command_line::Input_argument_list
& inputs
,
69 Workqueue
* workqueue
, Symbol_table
* symtab
)
72 gold_fatal(_("no input files"), false);
74 // Read the input files. We have to add the symbols to the symbol
75 // table in order. We do this by creating a separate blocker for
76 // each input file. We associate the blocker with the following
77 // input file, to give us a convenient place to delete it.
78 Task_token
* this_blocker
= NULL
;
79 for (Command_line::Input_argument_list::const_iterator p
= inputs
.begin();
83 Task_token
* next_blocker
= new Task_token();
84 next_blocker
->add_blocker();
85 workqueue
->queue(new Read_symbols(options
, symtab
, search_path
,
86 *p
, this_blocker
, next_blocker
));
87 this_blocker
= next_blocker
;
90 // workqueue->queue(new Layout(options, inputs, this_blocker));
93 } // end anonymous namespace.
96 main(int argc
, char** argv
)
98 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
99 setlocale (LC_MESSAGES
, "");
101 #if defined (HAVE_SETLOCALE)
102 setlocale (LC_CTYPE
, "");
104 bindtextdomain (PACKAGE
, LOCALEDIR
);
105 textdomain (PACKAGE
);
107 gold::program_name
= argv
[0];
109 // Handle the command line options.
110 gold::Command_line command_line
;
111 command_line
.process(argc
- 1, argv
+ 1);
114 gold::Workqueue
workqueue(command_line
.options());
119 // Get the search path from the -L options.
120 Dirsearch search_path
;
121 search_path
.add(&workqueue
, command_line
.options().search_path());
123 // Queue up the first set of tasks.
124 queue_initial_tasks(command_line
.options(), search_path
,
125 command_line
.inputs(), &workqueue
, &symtab
);
127 // Run the main task processing loop.
130 gold::gold_exit(true);